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

The following examples show how to use javax.swing.JInternalFrame#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: 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 2
Source File: TestViewer.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and shows a new internal frame for the given image.
 */
private void addImage(final RenderedImage image, final String title) {
    final JInternalFrame internal = new JInternalFrame(title, true, true);
    internal.add(new ImagePanel(image));
    internal.pack();
    internal.show();
    desktop.add(internal);
    if (location > min(desktop.getWidth()  - internal.getWidth(),
                       desktop.getHeight() - internal.getHeight()))
    {
        location = 0;
    }
    internal.setLocation(location, location);
    location += 30;
    internal.toFront();
}
 
Example 3
Source File: JInternalFrameMoveOverlapping.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void prepareControls() {


    JDesktopPane desktopPane = new JDesktopPane();

    JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
    bottomFrame.setSize(220, 220);
    super.propagateAWTControls(bottomFrame);
    desktopPane.add(bottomFrame);
    bottomFrame.setVisible(true);

    JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
    topFrame.setSize(200, 200);
    topFrame.add(new JButton("LW Button") {

        {
            addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    lwClicked = true;
                }
            });
        }
    });
    desktopPane.add(topFrame);
    topFrame.setVisible(true);

    JFrame frame = new JFrame("Test Window");
    frame.setSize(300, 300);
    frame.setContentPane(desktopPane);
    frame.setVisible(true);

    locTopFrame = topFrame.getLocationOnScreen();
    locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);
}
 
Example 4
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
}