List of usage examples for javax.swing JInternalFrame setLocation
public void setLocation(int x, int y)
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout()); gui.setPreferredSize(new Dimension(400, 100)); JDesktopPane dtp = new JDesktopPane(); gui.add(dtp, BorderLayout.CENTER); JButton newFrame = new JButton("Add Frame"); ActionListener listener = new ActionListener() { private int disp = 10; @Override/* ww w . ja v a 2 s. co m*/ public void actionPerformed(ActionEvent e) { JInternalFrame jif = new JInternalFrame(); dtp.add(jif); jif.setLocation(disp, disp); jif.setSize(100, 100); disp += 10; jif.setVisible(true); } }; newFrame.addActionListener(listener); gui.add(newFrame, BorderLayout.PAGE_START); JFrame f = new JFrame(); f.add(gui); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLocationByPlatform(true); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String TITLE = "Full Screen Test"; JFrame f = new JFrame(TITLE); JDesktopPane jdp = new JDesktopPane(); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice dev = env.getDefaultScreenDevice(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JInternalFrame jif = new JInternalFrame(TITLE, true, true, true); jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.NORTH); jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.CENTER); jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.SOUTH); jif.pack();//from w w w .java 2 s.co m jif.setLocation(100, 100); jif.setVisible(true); jdp.add(jif); f.add(jdp, BorderLayout.CENTER); dev.setFullScreenWindow(f); }
From source file:Main.java
public static void main(String[] a) { final JFrame jf = new JFrame("JIFrameDemo Main Window"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); screenSize.width -= 42;/* w ww.j a va 2 s .c o m*/ screenSize.height -= 42; jf.setSize(screenSize); jf.setLocation(20, 20); JMenuBar mb = new JMenuBar(); jf.setJMenuBar(mb); JMenu fm = new JMenu("File"); mb.add(fm); JMenuItem mi; fm.add(mi = new JMenuItem("Exit")); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); JDesktopPane dtp = new JDesktopPane(); //dtp.setBackground(Color.GREEN); jf.setContentPane(dtp); JInternalFrame mboxFrame = new JInternalFrame("Mail Reader", true, true, true, true); JLabel reader = new JLabel("Mail Reader Would Be Here"); mboxFrame.setContentPane(reader); mboxFrame.setSize(400, 300); mboxFrame.setLocation(50, 50); mboxFrame.setVisible(true); dtp.add(mboxFrame); JInternalFrame compFrame = new JInternalFrame("Compose Mail", true, true, true, true); JLabel composer = new JLabel("Mail Compose Would Be Here"); compFrame.setContentPane(composer); compFrame.setSize(300, 200); compFrame.setLocation(200, 200); compFrame.setVisible(true); dtp.add(compFrame); JInternalFrame listFrame = new JInternalFrame("Users", true, true, true, true); JLabel list = new JLabel("List of Users Would Be Here"); listFrame.setContentPane(list); listFrame.setLocation(400, 400); listFrame.setSize(500, 200); listFrame.setVisible(true); dtp.add(listFrame); jf.setVisible(true); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { jf.setVisible(false); jf.dispose(); System.exit(0); } }); }
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 . ja va 2 s.c om * @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 w w . j a v a2 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
/** * 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 . j a 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) { 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 av a 2s .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
private JInternalFrame createFrame(final Image image) { frames++;/*from w ww. ja va 2s. c om*/ final JInternalFrame frame = new JInternalFrame("Picture " + frames); frame.add(BorderLayout.CENTER, new JLabel(new ImageIcon(image))); frame.pack(); frame.setVisible(true); frame.setLocation(40 * frames, 40 * frames); return frame; }
From source file:org.jfree.chart.demo.InternalFrameDemo.java
/** * Creates a new instance of the demo./*from ww w.j ava2s . com*/ * * @param title the title. */ public InternalFrameDemo(final String title) { super(title); final JDesktopPane desktopPane = new JDesktopPane(); desktopPane.setPreferredSize(new Dimension(600, 400)); final JInternalFrame frame1 = createFrame1(); desktopPane.add(frame1); frame1.pack(); frame1.setVisible(true); final JInternalFrame frame2 = createFrame2(); desktopPane.add(frame2); frame2.pack(); frame2.setLocation(100, 200); frame2.setVisible(true); getContentPane().add(desktopPane); }
From source file:Main.java
public Main() { JInternalFrame frame1 = new JInternalFrame("Frame 1", true, true, true, true); JInternalFrame frame2 = new JInternalFrame("Frame 2", true, true, true, true); frame1.getContentPane().add(new JLabel("Frame 1 contents...")); frame1.pack();//from w ww . jav a2 s . c om frame1.setVisible(true); frame2.getContentPane().add(new JLabel("Frame 2 contents...")); frame2.pack(); frame2.setVisible(true); int x2 = frame1.getX() + frame1.getWidth() + 10; int y2 = frame1.getY(); frame2.setLocation(x2, y2); desktopPane.add(frame1); desktopPane.add(frame2); this.add(desktopPane, BorderLayout.CENTER); this.setMinimumSize(new Dimension(300, 300)); }