|
Okay, here's the full code of an example I'm trying to get to work, just as a test program. Just paste the whole thing into TextPad or whatever, it should run.
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class X
{
private static JFrame xFrame;
public static void main(String[] args)
{
xFrame = new JFrame();
xFrame.setSize(100,100);
JButton xButton = new JButton("X");
xButton.addActionListener(new XListener());
xFrame.getContentPane().add(xButton);
xFrame.setVisible(true);
}
private static class XListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
xFrame.removeAll();
xFrame.validate();
xFrame.hide();
xFrame.show();
xFrame.getContentPane().add(new JLabel("Java is stupid"));
}
}
}
|