List of usage examples for javax.swing JDesktopPane getWidth
@BeanProperty(bound = false) public int getWidth()
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 . ja v a 2 s . c om*/ * @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 /> * /* w w w .j ava 2 s. 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 setted with calling <code>pack()</code>. <br /> * // w w w . ja v a 2 s .c o m * @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
/** * 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 w w . ja v a 2s .c o m * @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; }