-
first game help
hey guys I have an idea for a game and so far I have making it all to be played using commands in terminal or cmdprompt.
I have been trying to make it in windows using the JOptionPane commands.
but i dont know how to do what I want to do.
here is a screen shot of what my goal is.
and my code that I have so far.
http://img508.imageshack.us/img508/2193/idea0.png
Code:
import javax.swing.*;
import java.lang.*;
import java.io.*;
import java.awt.*;
public class RPG extends JFrame {
public static void main(String[] args) {
Icon icon = new ImageIcon("http://www.java-forums.org/images/Icon.png");
Icon warrior = new ImageIcon("http://www.java-forums.org/images/Warrior.png");
Icon ranger = new ImageIcon("http://www.java-forums.org/images/Ranger.png");
Icon magician = new ImageIcon("http://www.java-forums.org/images/Magician.png");
Icon character = new ImageIcon();
String name = (String)JOptionPane.showInputDialog(null, "What is your name?", "RPG Game by --------", JOptionPane.PLAIN_MESSAGE, icon, null, null);
Object[] selectionRaces = {"Human", "Elf", "Dwarf" };
String initialRace = "Human";
Object race = JOptionPane.showInputDialog(null, "What race are you?",
"RPG Game by -------", JOptionPane.PLAIN_MESSAGE, icon, selectionRaces, initialRace);
Object[] selectionType = { "Warrior", "Ranger", "Magician" };
String initialType = "Warrior";
Object type = JOptionPane.showInputDialog(null, "What class are you?",
"RPG Game by --------", JOptionPane.PLAIN_MESSAGE, icon, selectionType, initialType);
Object[] selectionSide = { "Neutral", "Good", "Evil" };
String initialSide = "Neutral";
Object side = JOptionPane.showInputDialog(null, "What side are you on?",
"RPG Game by -------", JOptionPane.PLAIN_MESSAGE, icon, selectionSide, initialSide);
if (type == "Warrior") {
character = warrior;
}
if (type == "Ranger") {
character = ranger;
}
if (type == "Magician") {
character = magician;
}
if (type == null) {
character = icon;
}
JOptionPane.showMessageDialog(null, "Name: " + name + "\n" +
"Race: " + race + "\n" +
"Type: " + type + "\n" +
"Side: " + side + "\n" , "RPG Game by --------", JOptionPane.PLAIN_MESSAGE, character);
System.exit(0);
}
}
thanks for any help. :)
relith
-
My suggestion is not to do a bunch of JOptionPane dialogs, but rather to study Swing and then build a Swing GUI app from the ground up. To learn how to do this, start here: Using Swing Components
Best of luck!
-
wow
that looks like exactly what I was looking for.
I have looked at swing before but i guess the sites i was using sucked.
ever thought a site through oracle could be so thorough and newbie friendly.
thanks a bunch! :)
ps - dig the name fubarable. :P