|
-
January 19th, 2011, 02:16 PM
#1
displaying alternate jpanels in a jframe
hi, i want to display the attack jpanel in the same frame when the button is clicked but instead it opens in a new frame
public void actionPerformed(ActionEvent e)
{
JFrame aFrame = new JFrame();
aFrame.setBounds(0,0,400,600);
Container contentPane = aFrame.getContentPane();
JButton s = (JButton)e.getSource();
if(s == attack)
{
contentPane.add(new Attack());
}
else if(s == defense)
{
contentPane.add(new Defense());
}
aFrame.setVisible(true);
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|