public class Nada extends JFrame {
private static JPanel panel = new JPanel();
private static JFrame frame = new JFrame("Teste");
public static void main(String[] args) {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Menu");
JMenuItem menuItem = new JMenuItem("Selecione");
JMenuItem removerPainel = new JMenuItem("Remove o Painel");
JTextArea textArea = new JTextArea(10, 10);
textArea.setLineWrap(true);
panel.add(textArea);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 300);
menuItem.setAccelerator(KeyStroke.getKeyStroke("F1"));
menuBar.add(menu);
menu.add(menuItem);
menu.add(removerPainel);
frame.add(menuBar, BorderLayout.NORTH);
frame.add(panel, BorderLayout.CENTER);
frame.setVisible(true);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "Olá !");
} // actionPerformed
}); // inner class
removerPainel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.remove(panel);
panel = null;
frame.repaint();
} // actionPerformed
}); // inner class
} // main
} // class
Alguém sabe me dizer o porque ? E/ou como resolver isso ?