Attachment 2685Hey users I am trying to create a Java swing gui which has a picture in the background and a dialogue box in the front of the image which shows the text output and so i can input my text in it instead of showing it in my JDE (i use eclipse)
I have the Image done i just want some one to help me with the dialogue box and the input of my text
Please if you can Could you show me the code I need to input
Java Code:
Code:package Samurai;
import java.util.Scanner;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.PopupMenu;
import java.awt.event.*;
public class Samurai {
public static void main (String[] arg) {
//Displaying the Frame Created by MainScreenImage that Contains the Rules
new MainClassFrame();
//Displays a Dialogue Box Requesting for the User's Name from the Class Start Screen
startscreenimage frame = new startscreenimage();
frame.addWindowListener (new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
} );
//VARIABLES ONLY SECTION
String nameofwarrior=null,cityname,hit,faith;
int nameofcity,cityexplore,i,k,villan,boss;
int Mob1[]={1,1},Player[]={0,0},ninjalord[]={24,4};
String astricks[]= {"*","**","***","****","*****","******","*******","********","*********","**********","***********","************","*************","**************","***************","****************","*****************"};
String chooseyourdestiny[]= {"C","H","O","O","S","E"," ","Y","O","U","R"," ","D","E","S","T","I","N","Y"};
//VARIABLES ONLY SECTION ENDS
Scanner keyboard = new Scanner (System.in);
System.out.println("Follow the instructions on screen.\n When asked for a answer please use Y for yes or N for no. \n Also to explore Press Enter.And to continue press enter.");
hit =keyboard.nextLine();
System.out.println("Hey The Ol'e Wise Man Wishes to Know your NAME");
nameofwarrior=keyboard.nextLine();
if (nameofwarrior==null)
{
System.out.println("Please Type your Name");
nameofwarrior=keyboard.nextLine();
}
}
}
class MainClassFrame extends JFrame{
/**Purpose: To Create a Frame for the Image from MainClassRules
* Accepts: N/A
* Returns: N/A */
public MainClassFrame(){
add(new startscreenimage());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(680, 760);
setLocationRelativeTo(null);
setTitle("Samurai Game ");
setVisible(true);
}
/** @param args */
public static void main(String[] args) {
new MainClassFrame();
}
}
class startscreenimage extends JPanel{
Image one;
public startscreenimage (){
ImageIcon ii = new ImageIcon(this.getClass().getResource("SwordOfTheSamurai.png"));
one= ii.getImage();
}
public void addWindowListener(WindowAdapter windowAdapter) {
// TODO Auto-generated method stub
}
public void paint (Graphics g){
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(one,0,0,null);
}
}

