Example usage for javax.swing JInternalFrame setSize

List of usage examples for javax.swing JInternalFrame setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

Resizes this component so that it has width width and height height .

Usage

From source file:Main.java

public static void main(String[] args) {
    JDesktopPane dp = new JDesktopPane();
    JInternalFrame inf = new JInternalFrame("Help", true, true, true, true);
    inf.setSize(200, 200);
    inf.setVisible(true);//  w ww  .java  2 s  .co m
    dp.add(inf);

    JButton btn = new JButton("Click");
    btn.addActionListener(e -> JOptionPane.showInternalInputDialog(inf, "Hit me"));
    inf.add(btn);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new BorderLayout());
    f.add(dp);
    f.setSize(400, 400);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    boolean resizable = true;
    boolean closeable = true;
    boolean maximizable = true;
    boolean iconifiable = true;
    String title = "Frame Title";
    JInternalFrame iframe = new JInternalFrame(title, resizable, closeable, maximizable, iconifiable);

    iframe.setSize(300, 300);
    iframe.setVisible(true);//from  ww  w  . ja  v a2s  . c  o  m
    iframe.getContentPane().add(new JTextArea());
    JDesktopPane desktop = new JDesktopPane();
    desktop.add(iframe);

    JFrame frame = new JFrame();
    frame.getContentPane().add(desktop, BorderLayout.CENTER);
    frame.setSize(300, 300);
    frame.setVisible(true);
}

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/*from   w ww .j  ava  2  s. c  o  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[] a) {
    final JFrame jf = new JFrame("JIFrameDemo Main Window");

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    screenSize.width -= 42;/*  w w w. j av a 2  s  .  c om*/
    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: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  www .  j  a v  a2s  .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  ww w. j  a  v  a  2 s.c om*/
    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:FocusExample.java

public FocusExample() {

    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);// w  ww  .  j  ava2s . c om
    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() {
    JMenuBar bar = new JMenuBar();
    JMenu addMenu = new JMenu("Add");
    JMenuItem newFrame = new JMenuItem("Internal Frame");
    addMenu.add(newFrame);//from w  w  w . j a  v a  2s .  c o m
    bar.add(addMenu);
    setJMenuBar(bar);

    final JDesktopPane theDesktop = new JDesktopPane();
    getContentPane().add(theDesktop);

    newFrame.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JInternalFrame frame = new JInternalFrame("Internal Frame", true, true, true, true);

            Container c = frame.getContentPane();
            MyJPanel panel = new MyJPanel();

            c.add(panel, BorderLayout.CENTER);
            frame.setSize(200, 200);
            frame.setOpaque(true);
            theDesktop.add(frame);
        }
    });

    setSize(500, 400);
    setVisible(true);
}

From source file:KjellDirdalNotepad.java

public Component add(JInternalFrame frame) {
    JInternalFrame[] array = getAllFrames();
    Point p;/*  w  ww. ja va  2s .  c om*/
    int w;
    int h;

    Component retval = super.add(frame);
    checkDesktopSize();
    if (array.length > 0) {
        p = array[0].getLocation();
        p.x = p.x + FRAME_OFFSET;
        p.y = p.y + FRAME_OFFSET;
    } else {
        p = new Point(0, 0);
    }
    frame.setLocation(p.x, p.y);
    if (frame.isResizable()) {
        w = getWidth() - (getWidth() / 3);
        h = getHeight() - (getHeight() / 3);
        if (w < frame.getMinimumSize().getWidth())
            w = (int) frame.getMinimumSize().getWidth();
        if (h < frame.getMinimumSize().getHeight())
            h = (int) frame.getMinimumSize().getHeight();
        frame.setSize(w, h);
    }
    moveToFront(frame);
    frame.setVisible(true);
    try {
        frame.setSelected(true);
    } catch (PropertyVetoException e) {
        frame.toBack();
    }
    return retval;
}

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 .  j a v  a  2s. c om
    //      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);
}