Example usage for javax.swing JDesktopPane setPreferredSize

List of usage examples for javax.swing JDesktopPane setPreferredSize

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

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 a va  2  s.  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:org.jfree.chart.demo.InternalFrameDemo.java

/**
 * Creates a new instance of the demo./*from ww w . ja  va2s. c o m*/
 * 
 * @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);
}