View Single Post
Old 04-07-2003, 07:41 PM   #9 (permalink)
SkittlesAreYum
Registered User
 
Join Date: Apr 2003
Posts: 8
SkittlesAreYum is on a distinguished road
I've tried remaking the Container (getContentPane()) for the frame, and it doesn't work either. However, check out this my teacher made:

public class Xnew
{
private static JFrame xFrame;
private static JPanel xPanel;
public static void main(String[] args)
{
xFrame = new JFrame();
xPanel = new JPanel();

xFrame.setSize(100,100);
JButton xButton = new JButton("X");
xButton.setEnabled(true);
xButton.addActionListener(new XListener());
xPanel.add(xButton);
xFrame.getContentPane().add(xPanel);
xFrame.setVisible(true);
}

private static class XListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
xPanel.removeAll();
xPanel.add(new JLabel("Java is stupid"));
xPanel.updateUI();
}
}
}

Making the label on a JPanel allows it to display after everything else is removed. To top it all off, the JPanel is NOT removed by removeAll().

Should we just give up now and say removeAll() is bugged?
SkittlesAreYum is offline   Reply With Quote