1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
package wg.view.utilities;
import java.awt.BorderLayout;
@SuppressWarnings("serial")
public class JInternalFrameExemple extends JFrame {
private JLayeredPane oLayeredPane;
public JInternalFrameExemple(){
this.setTitle("Exemple");
this.setSize(800, 600);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar oMenuBar = new JMenuBar();
JMenu oMenu = new JMenu("Test");
oMenuBar.add(oMenu);
JMenuItem oMenuItem = new JMenuItem(new AddInternalFrame("Ajouter une JInternalFrame"));
oMenu.add(oMenuItem);
this.setJMenuBar(oMenuBar);
this.oLayeredPane = new JLayeredPane();
this.oLayeredPane.setLayout(new BorderLayout());
this.setContentPane(this.oLayeredPane);
ScrollPane oScrollPane = new ScrollPane();
Canvas3D oCanvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
oCanvas.setSize(1000, 1000);
oScrollPane.add(oCanvas);
this.oLayeredPane.add(oScrollPane, BorderLayout.CENTER, JLayeredPane.DEFAULT_LAYER);
this.setVisible(true);
}
private class AddInternalFrame extends AbstractAction{
public AddInternalFrame(String sName){
super(sName);
}
public void actionPerformed(ActionEvent arg0) {
new MyInternalFrame();
}
}
private class MyInternalFrame extends JInternalFrame{
public MyInternalFrame(){
super("MyInternalFrame", false, true, false, false);
this.setSize(200, 100);
this.setVisible(true);
JInternalFrameExemple.this.oLayeredPane.add(this, JLayeredPane.PALETTE_LAYER);
}
}
public static void main(String[] args) {
new JInternalFrameExemple();
}
} |
Partager