This is the most simple code that I found to show this error.
I have JFrame with a complex Content Pane (not this one). I'm trying to
recreate the Content pane for each File but after I set the new Content Pane
there is no Change, But if I try to resize the new Pane alredy apears.
What do I need to set this simple example to work?
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class Main {
static JFrame m_frame;
public static void main(String[] args) {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
m_frame = new JFrame("Teste");
m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_frame.setContentPane(createPanel(null));
m_frame.pack();
m_frame.setVisible(true);
}
static JPanel createPanel(File file) {
JPanel panel = new JPanel();
JButton bRecreate = new JButton("Recreate");
bRecreate.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showOpenDialog(m_frame) !=
JFileChooser.APPROVE_OPTION)
return;
m_frame.setContentPane(createPanel(fileChooser.getSelectedFile()));
}});
JLabel label = new JLabel();
if (file != null) {
label.setText(file.getPath());
}
panel.add(label);
panel.add(bRecreate);
return panel;
}
}
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing