Package javax.swing

Examples of javax.swing.JDesktopPane$ComponentPosition


public class JDPTest {
    public static void main(String[] args) {
        Frame wnd = new Frame();
        try {
            wnd.setSize(600, 400);
            JDesktopPane jdtp = new JDesktopPane();
            JInternalFrame jif = new JInternalFrame("Test");
            jif.setSize(100, 100);
            jif.setLocation(10, 10);
            jif.setResizable(true);
            jif.setClosable(true);
            jif.setIconifiable(true);
            jif.setMaximizable(true);
            jif.setSelected(true);
            jdtp.add(jif);
            wnd.add(jdtp, BorderLayout.CENTER);

            wnd.setVisible(true);
            jif.setVisible(true);
View Full Code Here


* @author Levente S\u00e1ntha
*/
public class JInternalFrameTest {
    public static void main(String[] argv) {
        JFrame f = new JFrame("Test");
        JDesktopPane dt = new JDesktopPane();
        f.getContentPane().add(dt, BorderLayout.CENTER);
        JInternalFrame ifr = new JInternalFrame("IF1");
        ifr.setLocation(0, 0);
        ifr.setSize(150, 150);
        ifr.setResizable(true);
        ifr.setClosable(true);
        ifr.setMaximizable(true);
        dt.add(ifr);
        ifr.setVisible(true);

        JInternalFrame ifr2 = new JInternalFrame("IF2");
        ifr2.setLocation(20, 20);
        ifr2.setSize(150, 150);
        ifr2.setResizable(true);
        ifr2.setClosable(true);
        ifr2.setMaximizable(true);
        dt.add(ifr2);
        ifr2.setVisible(true);

        JInternalFrame ifr3 = new JInternalFrame("IF3");
        ifr3.setLocation(40, 40);
        ifr3.setSize(150, 150);
        ifr3.setResizable(true);
        ifr3.setClosable(true);
        ifr3.setMaximizable(true);
        dt.add(ifr3);
        ifr3.setVisible(true);

        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        f.setLocation(0, 0);
        f.setSize(300, 300);
View Full Code Here

        }
        this.controlBar = new ControlBar(appsEP);

        final JNodeToolkit tk = JNodeToolkit.getJNodeToolkit();
        final JNodeAwtContext ctx = tk.getAwtContext();
        final JDesktopPane desktop = ctx.getDesktop();
        final Container awtRoot = ctx.getAwtRoot();

        controlBar.getApplicationBar().addApp("Halt", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JNodeToolkit.stopGui();
            }
        });

        controlBar.getApplicationBar().addApp("Reboot", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JNodeToolkit.stopGui();
                VmSystem.halt(true);
            }
        });

        awtRoot.removeAll();
        awtRoot.setLayout(null);
        awtRoot.add(desktop);
        final int h = awtRoot.getHeight();
        final int controlBarHeight = h / 8;
        final int w = awtRoot.getWidth();
        desktop.setBounds(0, 0, w, h - controlBarHeight);
        awtRoot.add(controlBar);
        controlBar.setBounds(0, h - controlBarHeight, w, controlBarHeight);

        awtRoot.invalidate();
        awtRoot.repaint();
        System.out.println("controlBar.bounds=" + controlBar.getBounds());
        System.out.println("desktop.bounds=" + desktop.getBounds());

        // Update desktopmanager
        desktop.setDesktopManager(new DesktopManagerImpl());
        desktop.addContainerListener(new DesktopContainerListener());

        // Set background info
        final int dx = 30;
        final int dy = dx;
        final JLabel welcomeLbl = new JLabel("Welcome to JNode");
        welcomeLbl.setForeground(Color.WHITE);
        welcomeLbl.setLocation(dx, dy);
        welcomeLbl.setFont(welcomeLbl.getFont().deriveFont(20.0f));
        welcomeLbl.setSize(welcomeLbl.getPreferredSize());
        desktop.add(welcomeLbl, (Integer) (JLayeredPane.DEFAULT_LAYER - 1));

        final JLabel versionLbl = new JLabel("version " + VmUtils.getVm().getVersion());
        versionLbl.setForeground(Color.WHITE);
        versionLbl.setFont(versionLbl.getFont().deriveFont(14.0f));
        versionLbl.setSize(versionLbl.getPreferredSize());
        versionLbl.setLocation(desktop.getWidth() - versionLbl.getWidth() - dy,
            desktop.getHeight() - versionLbl.getHeight() - dy);
        desktop.add(versionLbl, (Integer) (JLayeredPane.DEFAULT_LAYER - 1));

        // Update
        desktop.doLayout();
        desktop.repaint();
    }
View Full Code Here

        /**
         * @see javax.swing.DesktopManager#deiconifyFrame(javax.swing.JInternalFrame)
         */
        public void deiconifyFrame(JInternalFrame frame) {
            final JDesktopPane p = frame.getDesktopPane();
            frame.setVisible(true);
            if (p != null) {
                p.setSelectedFrame(frame);
            }
        }
View Full Code Here

        /**
         * @see javax.swing.DesktopManager#iconifyFrame(javax.swing.JInternalFrame)
         */
        public void iconifyFrame(JInternalFrame frame) {
            final JDesktopPane p = frame.getDesktopPane();
            frame.setVisible(false);
            if ((p != null) && (p.getSelectedFrame() == frame)) {
                p.setSelectedFrame(null);
            }
        }
View Full Code Here

                public void internalFrameClosed(InternalFrameEvent event) {
                    //empty
                }

                public void internalFrameClosing(InternalFrameEvent event) {
                    final JDesktopPane desktop = FrameWrapper.this.frame.getDesktopPane();
                    removeFrame(FrameWrapper.this.frame);
                    desktop.remove(FrameWrapper.this.frame);
                    selectNextFrame(desktop);
                    desktop.repaint();
                }

                public void internalFrameDeactivated(InternalFrameEvent event) {
                    FrameWrapper.this.setBackground(Color.LIGHT_GRAY);
                }
View Full Code Here

        /**
         * @see javax.swing.DesktopManager#deiconifyFrame(javax.swing.JInternalFrame)
         */
        public void deiconifyFrame(JInternalFrame frame) {
            final JDesktopPane p = frame.getDesktopPane();
            frame.setVisible(true);
            if (p != null) {
                p.setSelectedFrame(frame);
            }
        }
View Full Code Here

        /**
         * @see javax.swing.DesktopManager#iconifyFrame(javax.swing.JInternalFrame)
         */
        public void iconifyFrame(JInternalFrame frame) {
            final JDesktopPane p = frame.getDesktopPane();
            frame.setVisible(false);
            if ((p != null) && (p.getSelectedFrame() == frame)) {
                p.setSelectedFrame(null);
            }
        }
View Full Code Here

         */
        public void valueChanged(ListSelectionEvent event) {
            final FrameWrapper sel = (FrameWrapper) list.getSelectedValue();
            if ((sel != null) && !sel.getFrame().isSelected()) {
                final JInternalFrame frame = sel.getFrame();
                final JDesktopPane desktop = frame.getDesktopPane();
                desktop.setSelectedFrame(frame);
            }
        }
View Full Code Here

    /**
     * Creates a new picture frame on the desktop.
     */
    protected void newPicture() {
        JDesktopPane desktop = application.getDesktopPane();

        // Work out the next number to use for the default Untitled picture name.
        int maximumUntitledFrameNum = 0;
        for (JInternalFrame frame : desktop.getAllFrames()) {
            PictureFrame pictureFrame = (PictureFrame)frame;
            // Untitled picture frames are those without a picture file associated.
            if (pictureFrame.getEditStatus().getPictureFile() == null) {
                String frameTitle = pictureFrame.getTitle();
                if (frameTitle.contains("Untitled")) {
                    int untitledFrameNum = 1;
                    if (!frameTitle.endsWith("Untitled")) {
                        untitledFrameNum = Integer.parseInt(frameTitle.substring(frameTitle.indexOf("Untitled") + 9));
                        if (untitledFrameNum > maximumUntitledFrameNum) {
                            maximumUntitledFrameNum = untitledFrameNum;
                        }
                    }
                    if (untitledFrameNum > maximumUntitledFrameNum) {
                        maximumUntitledFrameNum = untitledFrameNum;
                    }
                }
            }
        }
        StringBuilder defaultPictureName = new StringBuilder("Untitled");
        if (maximumUntitledFrameNum > 0) {
            defaultPictureName.append(" ");
            defaultPictureName.append(maximumUntitledFrameNum + 1);
        }
       
        // Now create the new PictureFrame.
        PictureFrame newPictureFrame = new PictureFrame(application, application.getEditStatus().getZoomFactor(), defaultPictureName.toString());
        int initialFrameIndent = 20 + (desktop.getAllFrames().length * 25);
        newPictureFrame.setLocation(initialFrameIndent, initialFrameIndent);
       
        // Add to the desktop, start up the mouse motion timer and then autoselect.
        desktop.add(newPictureFrame);
        try {
            newPictureFrame.setSelected(true);
        } catch (PropertyVetoException e) {
        }
    }
View Full Code Here

TOP

Related Classes of javax.swing.JDesktopPane$ComponentPosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.