Cool, that worked great. Although, I'm still having a problem, the problem is I have a button on the frame and when I click it it is suppose to basically close the frame and it works...the first that is and thats the only time. Can someone help me out. Heres my code:
Here's the frame:
java
public JFrame Extra()
{
extra = new JPanel();
Container zeb = Extra.getContentPane();
eASCII = new JLabel(new ImageIcon("eAsciiTable.jpg"));
Iwonder = new JLabel("I wonder what I could use these for!?!?!?");
exit = new JButton("Exit");
exit.addActionListener(this);
extra.add(Iwonder);
extra.add(eASCII);
extra.add(exit);
zeb.add(extra);
Extra.setTitle("Extended Ascii Table");
Extra.setBounds(475, 425, 600, 420);
Extra.setResizable(false);
Extra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Extra.setVisible(true);
return Extra;
}
And heres part of my actionPerformed method:
java
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
String men = e.getActionCommand();
if(source == start)
{
JOptionPane.showMessageDialog(null, "The Objective of the Game is to get the highest score!!!");
Stat();
Board();
Intro.setVisible(false);
}
else if(source == enter)
{
if(inputZ.getText().length() == 0 || inputZ.getText().length() > 1 || inputZ.getText().equals(" "))
{
JOptionPane.showMessageDialog(null, "Please use symbols that are of single digit length!");
inputZ.setText("");
}
else
{
inputZ.setVisible(false);
enter.setVisible(false);
symbol.setVisible(false);
for(int i = 0; i < btns.length && i < btnz.length && i < btnc.length; i++)
{
btns[i].setEnabled(true);
btnz[i].setEnabled(true);
btnc[i].setEnabled(true);
}
}
}
else if(men.equals("Extra's")) // using a menu that will open Extra frame
{
Extra.setVisible(true);
Extra();
}
else if(source == exit) // the exit button on the Extra frame, only works once
{
Extra.dispose();
}
else if(men.equals("Save Game"))
{
SaveGame();
}
else if(men.equals("Close"))
{
System.exit(0);
}
else if(men.equals("Instructions"))
{
JOptionPane.showMessageDialog(null, "Step 1: Put mouse over the 'New Game' menu.\nStep 2: Put your mouse over the desired Game Mode.\nStep 3: Select who is to go first!\nStep 4: Who ever is going first type in a desired symbol to use.\nStep 5: Get the highest score to win!");
}
else if(men.equals("About"))
{
JOptionPane.showMessageDialog(null, "Eradication Co.\nCopyright © 2008 Eradication Co.\nVersion 1.6\n3-D Tic-Tac-Toe\nCreated by Jeffrey Napier");
}
else if(men.equals("Human1") || men.equals("Human2"))
{
inputZ.setText("");
inputZ.setVisible(true);
symbol.setVisible(true);
enter.setVisible(true);
turn.setText("");
sc1 = 0;
sc2 = 0;
p1Score.setText("Player One Score: " + sc1 + "");
p2Score.setText("Player Two Score: " + sc2 + "");
for(int i = 0; i < btns.length && i < btnz.length && i < btnc.length; i++)
{
btns[i].setText("");
btnz[i].setText("");
btnc[i].setText("");
btns[i].setEnabled(false);
btnz[i].setEnabled(false);
btnc[i].setEnabled(false);
btns[i].setSelected(false);
btnz[i].setSelected(false);
btnc[i].setSelected(false);
}
if(men.equals("Human1"))
{
turn.setText("Human1's turn!");
p1 = true;
}
else if(men.equals("Human2"))
{
turn.setText("Human2's turn!");
p1 = false;
}
}
else{}
This post has been edited by Mastergeek666: 15 Mar, 2008 - 07:15 PM