Java Code Examples for javax.swing.JDesktopPane#add()

The following examples show how to use javax.swing.JDesktopPane#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NormalBoundsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void createUI(String lookAndFeelString) {
    internalFrame = new JInternalFrame("Internal", true, true, true, true);
    internalFrame.setDefaultCloseOperation(
            WindowConstants.DO_NOTHING_ON_CLOSE);
    internalFrame.setSize(200, 200);

    JDesktopPane desktopPane = new JDesktopPane();
    desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    desktopPane.add(internalFrame);

    mainFrame = new JFrame(lookAndFeelString);
    mainFrame.setSize(640, 480);
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setContentPane(desktopPane);

    mainFrame.setVisible(true);
    internalFrame.setVisible(true);

}
 
Example 2
Source File: Test6505027.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 3
Source File: DockIconRepaint.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void createUI() {
    frame = new JFrame();
    frame.setUndecorated(true);
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final JDesktopPane pane = new JDesktopPane();
    final JPanel panel = new JPanel() {
        @Override
        protected void paintComponent(Graphics g) {
            g.setColor(color);
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    jif = new JInternalFrame();
    jif.add(panel);
    jif.setVisible(true);
    jif.setSize(300, 300);
    pane.add(jif);
    frame.add(pane);
    frame.setVisible(true);
}
 
Example 4
Source File: JInternalFrameDraggingTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void createAndShowGUI() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());

        desktopPane = new JDesktopPane();
        desktopPane.setBackground(BACKGROUND_COLOR);

        frame.add(desktopPane, BorderLayout.CENTER);
        frame.setSize(FRAME_SIZE, FRAME_SIZE);
        frame.setVisible(true);

        internalFrame = new JInternalFrame("Test");
        internalFrame.setSize(FRAME_SIZE / 2, FRAME_SIZE / 2);
        desktopPane.add(internalFrame);
        internalFrame.setVisible(true);
        internalFrame.setResizable(true);

        frame.setVisible(true);
    }
 
Example 5
Source File: Test6505027.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 6
Source File: Test6802868.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Test6802868(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();

    this.frame = frame;
    this.frame.add(desktop);

    this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
    this.internal.setVisible(true);

    desktop.add(this.internal);
}
 
Example 7
Source File: Test6802868.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Test6802868(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();

    this.frame = frame;
    this.frame.add(desktop);

    this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
    this.internal.setVisible(true);

    desktop.add(this.internal);
}
 
Example 8
Source File: JInternalFrameOverlapping.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creating two JInternalFrames in JDesktopPanes. Put lightweight component into one frame and heavyweight into another.
 */
@Override
protected void prepareControls() {
    JDesktopPane desktopPane = new JDesktopPane();

    JFrame frame = new JFrame("Test Window");
    frame.setSize(300, 300);
    frame.setContentPane(desktopPane);
    frame.setVisible(true);
    JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
    bottomFrame.setSize(220, 220);
    desktopPane.add(bottomFrame);
    bottomFrame.setVisible(true);

    super.propagateAWTControls(bottomFrame);
    JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
    topFrame.setSize(200, 200);
    JButton jbutton = new JButton("LW Button") {{
            addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    lwClicked = true;
                }
            });
        }};
    topFrame.add(jbutton);
    desktopPane.add(topFrame);
    topFrame.setVisible(true);
    lLoc = jbutton.getLocationOnScreen();
    lLoc.translate(jbutton.getWidth()/2, jbutton.getWidth()/2); //click at middle of the button
}
 
Example 9
Source File: Test6802868.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Test6802868(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();

    this.frame = frame;
    this.frame.add(desktop);

    this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
    this.internal.setVisible(true);

    desktop.add(this.internal);
}
 
Example 10
Source File: bug8069348.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JDesktopPane desktopPane = new JDesktopPane();
        desktopPane.setBackground(DESKTOPPANE_COLOR);

        internalFrame = new JInternalFrame("Test") {

            @Override
            public void paint(Graphics g) {
                super.paint(g);
                g.setColor(FRAME_COLOR);
                g.fillRect(0, 0, getWidth(), getHeight());
            }
        };
        internalFrame.setSize(WIN_WIDTH / 3, WIN_HEIGHT / 3);
        internalFrame.setVisible(true);
        desktopPane.add(internalFrame);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.add(desktopPane, BorderLayout.CENTER);
        frame.add(panel);
        frame.setSize(WIN_WIDTH, WIN_HEIGHT);
        frame.setVisible(true);
        frame.requestFocus();
    }
 
Example 11
Source File: bug8069348.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JDesktopPane desktopPane = new JDesktopPane();
        desktopPane.setBackground(DESKTOPPANE_COLOR);

        internalFrame = new JInternalFrame("Test") {

            @Override
            public void paint(Graphics g) {
                super.paint(g);
                g.setColor(FRAME_COLOR);
                g.fillRect(0, 0, getWidth(), getHeight());
            }
        };
        internalFrame.setSize(WIN_WIDTH / 3, WIN_HEIGHT / 3);
        internalFrame.setVisible(true);
        desktopPane.add(internalFrame);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.add(desktopPane, BorderLayout.CENTER);
        frame.add(panel);
        frame.setSize(WIN_WIDTH, WIN_HEIGHT);
        frame.setVisible(true);
        frame.requestFocus();
    }
 
Example 12
Source File: GuiUtil.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Workaround for bug: can't re-show internal frames. See bug parade 4138031.
 */
public static void show(JInternalFrame internalFrame, JDesktopPane desktopPane)
    throws PropertyVetoException {
    if (!desktopPane.isAncestorOf(internalFrame))
        desktopPane.add(internalFrame);
    internalFrame.setClosed(false);
    internalFrame.setVisible(true);
    internalFrame.toFront();
}
 
Example 13
Source File: Test6802868.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Test6802868(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();

    this.frame = frame;
    this.frame.add(desktop);

    this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
    this.internal.setVisible(true);

    desktop.add(this.internal);
}
 
Example 14
Source File: Test6802868.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Test6802868(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();

    this.frame = frame;
    this.frame.add(desktop);

    this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
    this.internal.setVisible(true);

    desktop.add(this.internal);
}
 
Example 15
Source File: Test6802868.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Test6802868(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();

    this.frame = frame;
    this.frame.add(desktop);

    this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
    this.internal.setVisible(true);

    desktop.add(this.internal);
}
 
Example 16
Source File: Test6325652.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public Test6325652(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();
    desktop.add(create(0));
    desktop.add(this.internal = create(1));
    frame.add(desktop);
}
 
Example 17
Source File: Test6325652.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public Test6325652(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();
    desktop.add(create(0));
    desktop.add(this.internal = create(1));
    frame.add(desktop);
}
 
Example 18
Source File: Test6325652.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public Test6325652(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();
    desktop.add(create(0));
    desktop.add(this.internal = create(1));
    frame.add(desktop);
}
 
Example 19
Source File: Test6325652.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Test6325652(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();
    desktop.add(create(0));
    desktop.add(this.internal = create(1));
    frame.add(desktop);
}
 
Example 20
Source File: Test6325652.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Test6325652(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();
    desktop.add(create(0));
    desktop.add(this.internal = create(1));
    frame.add(desktop);
}