How to set JFrame's LayeredPane?
Hello,eveyone!
I wat to set JFrame's LayeredPane by JFrame's setLayeredPane() method.
My code as follow:
import javax.swing.*;
import java.awt.*;
publicclass LayeredTest{
publicstaticvoid main(String[] args){
SwingUtilities.invokeLater(new Runnable(){
publicvoid run(){
new MyFrame().setVisible(true);
}
});
}
}
class MyFrameextends JFrame{
public MyFrame(){
super("LayeredTest");
setLayeredPane(new JLayeredPane());//this line, I want to set the LayeredPane myself;
//but it doesn't work.
JPanel panel =new JPanel();
panel.setPreferredSize(new Dimension(320,240));
panel.add(new JLabel("Label"));
panel.add(new JButton("Button"));
add(panel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
}
}
But the application runs abnormality.
Any one tells me why and how to modify?
thanks!
Message was edited by:
Eastsun

