List of usage examples for javax.swing JDesktopPane add
public Component add(String name, Component comp)
From source file:FocusExample.java
public FocusExample() { super("Focus Example"); setDefaultCloseOperation(EXIT_ON_CLOSE); MyPanel mypanel = new MyPanel(); JButton button1 = new JButton("One"); JButton button2 = new JButton("Two"); JButton button3 = new JButton("Three"); JButton button4 = new JButton("Four"); JButton button5 = new MyButton("Five*"); JButton button6 = new MyButton("Six*"); JButton button7 = new JButton("Seven"); mypanel.add(button2);// ww w . j a va2s. c o m mypanel.add(button3); JInternalFrame frame1 = new JInternalFrame("Internal Frame 1", true, true, true, true); frame1.setBackground(Color.lightGray); frame1.getContentPane().setLayout(new GridLayout(2, 3)); frame1.setSize(300, 200); frame1.getContentPane().add(button1); frame1.getContentPane().add(mypanel); frame1.getContentPane().add(button4); frame1.getContentPane().add(button5); frame1.getContentPane().add(button6); frame1.getContentPane().add(button7); JDesktopPane desktop = new JDesktopPane(); desktop.add(frame1, new Integer(1)); desktop.setOpaque(true); // Now set up the user interface window. Container contentPane = getContentPane(); contentPane.add(desktop, BorderLayout.CENTER); setSize(new Dimension(400, 300)); frame1.setVisible(true); setVisible(true); }
From source file:ScrollDesktop.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desk = new ScrollDesktop(); desk.setPreferredSize(new Dimension(1000, 1000)); getContentPane().add(new JScrollPane(desk), "Center"); JInternalFrame f1 = new JInternalFrame("Frame 1"); f1.getContentPane().add(new JLabel("This is frame f1")); f1.setResizable(true);//from ww w. j av a 2 s . com f1.pack(); f1.setVisible(true); desk.add(f1, new Integer(10)); JInternalFrame f2 = new JInternalFrame("Frame 2"); f2.getContentPane().add(new JLabel("Content for f2")); f2.setResizable(true); f2.pack(); f2.setVisible(true); desk.add(f2, new Integer(20)); JInternalFrame f3 = new JInternalFrame("Frame 3"); f3.getContentPane().add(new JLabel("Content for f3")); f3.setResizable(true); f3.pack(); f3.setVisible(true); desk.add(f3, new Integer(20)); f3.toFront(); try { f3.setSelected(true); } catch (java.beans.PropertyVetoException ignored) { } pack(); setSize(300, 300); setVisible(true); }