List of usage examples for javax.swing JInternalFrame setSelected
@BeanProperty(description = "Indicates whether this internal frame is currently the active frame.") public void setSelected(boolean selected) throws PropertyVetoException
From source file:GUIUtils.java
public static void moveToFront(final JInternalFrame fr) { if (fr != null) { processOnSwingEventThread(new Runnable() { public void run() { fr.moveToFront();//from ww w. j av a 2s. c o m fr.setVisible(true); try { fr.setSelected(true); if (fr.isIcon()) { fr.setIcon(false); } fr.setSelected(true); } catch (PropertyVetoException ex) { } fr.requestFocus(); } }); } }
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 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 /> * //from ww w . java 2 s .co 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; }
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 /> * // w ww. j av a 2 s . c o m * @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 ww .j a v a2 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: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);// w ww. jav a 2s . c o m 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); }
From source file:CascadeDemo.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JLabel label = new JLabel(EARTH); jif.getContentPane().add(new JScrollPane(label)); m_desktop.add(jif);/*from w w w. ja v a2s. c o m*/ try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }
From source file:KjellDirdalNotepad.java
private void buildChildMenus() { int i;/*from w w w. j a v a2 s.co m*/ ChildMenuItem menu; JInternalFrame[] array = desktop.getAllFrames(); add(cascade); add(tile); if (array.length > 0) addSeparator(); cascade.setEnabled(array.length > 0); tile.setEnabled(array.length > 0); for (i = 0; i < array.length; i++) { menu = new ChildMenuItem(array[i]); menu.setState(i == 0); menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JInternalFrame frame = ((ChildMenuItem) ae.getSource()).getFrame(); frame.moveToFront(); try { frame.setSelected(true); } catch (PropertyVetoException e) { e.printStackTrace(); } } }); menu.setIcon(array[i].getFrameIcon()); add(menu); } }
From source file:InternalFrameListenerDemo.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.addInternalFrameListener(this); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JLabel label = new JLabel(); label.setBackground(Color.white); label.setOpaque(true);/*from www . ja v a 2s . c om*/ jif.getContentPane().add(label); m_desktop.add(jif); try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }
From source file:DesktopManagerDemo.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JLabel label = new JLabel(); label.setBackground(Color.white); label.setOpaque(true);// ww w.ja v a 2s. c o m jif.getContentPane().add(label); m_desktop.add(jif); try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }