List of usage examples for javax.swing JDesktopPane add
public Component add(String name, Component comp)
From source file:InternalFramePaletteSample.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);//from w ww . j a va 2 s. c om frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:VetoableChangeListenerDemo.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, true, true, true); palette.addVetoableChangeListener(new IconPolice()); palette.setBounds(350, 150, 100, 100); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);/*from w w w.j av a 2 s . c o m*/ frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);/*from w w w. java 2 s .co m*/ frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, true, true, true); palette.addPropertyChangeListener(new InternalFramePropertyChangeHandler()); palette.setBounds(350, 150, 100, 100); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);//from w w w. ja va2s . c om frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
/** * Creates (and displays) a JInternalFrame for a specified component. <br /> * The size of the JInternalFrame will be setted with calling <code>pack()</code>. <br /> * /*from w w w .j a va 2 s. com*/ * @param desktop the JDesktopPane * @param comp the component to display in the created frame * @param title the title of the frame * @param frameSize the size of the frame * @return the created and displayed frame */ public static JInternalFrame showInternalFrame(JDesktopPane desktop, JComponent comp, String title) { JInternalFrame frm = new JInternalFrame(title); frm.setClosable(true); frm.setLayout(new BorderLayout()); frm.add(comp, BorderLayout.CENTER); desktop.add(frm, 0); frm.pack(); frm.setVisible(true); Dimension size = frm.getSize(); frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2); try { frm.setSelected(true); } catch (java.beans.PropertyVetoException e) { } return frm; }
From source file:Main.java
/** * Shows a specified JInternalFrame in the middle of the specified JDesktopPane. <br /> * The size of the JInternalFrame will be <code>frameSize</code>. <br /> * The frame is <i>just</i> closeable. <br /> * //from w w w .j a va2 s. com * @param desktop the JDesktopPane * @param frm the JInternalFrame * @param content the component which will be added to the JInternalFrame * @param frameSize the size of the JInternalFrame */ public static void showInternalFrame(JDesktopPane desktop, JInternalFrame frm, JComponent content, Dimension frameSize) { frm.setClosable(true); frm.setLayout(new BorderLayout()); frm.add(content, BorderLayout.CENTER); frm.setSize(frameSize); frm.setVisible(true); Dimension size = frm.getSize(); frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2); desktop.add(frm, 0); try { frm.setSelected(true); } catch (java.beans.PropertyVetoException e) { } }
From source file:Main.java
/** * Displays a specified <code>JFileChooser</code> in a JInternalFrame. <br /> * The JInternalFrame will close when the dialog is closed. <br /> * //from w w w . ja v a2s . c o m * @param desktop the JDesktopPane on which to display the JFileChooser * @param ch the JFileChooser to display */ public static void showInternalFileChooser(JDesktopPane desktop, final JFileChooser ch) { final JInternalFrame frm = new JInternalFrame(ch.getDialogTitle()); frm.setClosable(true); frm.setResizable(true); frm.setLayout(new BorderLayout()); frm.add(ch, BorderLayout.CENTER); frm.setVisible(true); frm.pack(); Dimension size = frm.getSize(); frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2); desktop.add(frm, 0); ch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { frm.dispose(); ch.removeActionListener(this); } }); try { frm.setSelected(true); } catch (java.beans.PropertyVetoException e) { } }
From source file:Main.java
/** * Creates (and displays) a JInternalFrame for a specified component. <br /> * The size of the JInternalFrame will be <code>frameSize</code>. <br /> * The frame is <i>just</i> closeable. <br /> * //w ww.j a va 2 s. c om * @param desktop the JDesktopPane * @param comp the component to display in the created frame * @param title the title of the frame * @param frameSize the size of the frame * @return the created and displayed frame */ public static JInternalFrame showInternalFrame(JDesktopPane desktop, JComponent comp, String title, Dimension frameSize) { JInternalFrame frm = new JInternalFrame(title); frm.setClosable(true); frm.setLayout(new BorderLayout()); frm.add(comp, BorderLayout.CENTER); frm.setSize(frameSize); frm.setVisible(true); Dimension size = frm.getSize(); frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2); desktop.add(frm, 0); try { frm.setSelected(true); } catch (java.beans.PropertyVetoException e) { } return frm; }
From source file:MainClass.java
public MainClass() { 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);/*from w w w. ja v a2 s . 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:Main.java
public Main() { 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);/*from w w w .ja v a 2 s. 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); }