Example usage for javax.swing JInternalFrame JInternalFrame

List of usage examples for javax.swing JInternalFrame JInternalFrame

Introduction

In this page you can find the example usage for javax.swing JInternalFrame JInternalFrame.

Prototype

public JInternalFrame(String title) 

Source Link

Document

Creates a non-resizable, non-closable, non-maximizable, non-iconifiable JInternalFrame with the specified title.

Usage

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 ww  w.  ja  v a  2s .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 />
 * /*from www  . j a  v a 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: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);/*ww  w. j av 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:Main.java

private JInternalFrame createFrame(final Image image) {
    frames++;//from   ww  w  .j a  v a2  s. c o  m
    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: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 ww  .  j a v a2  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) {
    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:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

protected JInternalFrame createFrame() {
    JInternalFrame frame = new JInternalFrame("Some frame");
    frame.setBounds(30, 30, 300, 300);/*from  w  ww . j a v  a  2  s.c om*/
    frame.setTitle("Some frame");
    frame.setVisible(true);
    return frame;
}

From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java

private void showInDialog(String title, Component ancestor) {

    //      final JDialog dialog;

    //      if (ancestor instanceof JFrame) {
    //         dialog = new JDialog((JFrame)ancestor);
    //      }/*from  www. ja  v  a  2  s .  c o  m*/
    //      else if (ancestor instanceof JDialog) {
    //         dialog = new JDialog((JDialog)ancestor);
    //      }
    //      else if (ancestor == null) {
    //         dialog = new JDialog();
    //      }
    //      else {
    //         throw new RuntimeException();
    //      }

    JInternalFrame dialog = new JInternalFrame(title);

    //      dialog.setTitle(client.url() + dbPath);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    //      dialog.setModal(false);
    dialog.getContentPane().add(ancestor);
    dialog.setSize(400, 300);
    //      dialog.setLocationRelativeTo(ancestor);
    dialog.setResizable(true);
    dialog.setClosable(true);
    dialog.setIconifiable(true);
    dialog.setMaximizable(true);
    getDesktopPane().add(dialog);
    try {
        dialog.setMaximum(true);
    } catch (PropertyVetoException e) {
        e.printStackTrace();
    }
    dialog.setVisible(true);
}