0

我正在尝试创建子 JInternalFrames,以便子框架不会遮挡父框架的标题栏。我什至不确定这是否可能,如果不是,请告诉我如果您有创意,我会非常感激听到它,TYIA -Roland

    **
     * @(#)rebuiltgui.java
     *
     * rebuiltgui Applet application
     *
     * @author 
     * @version 1.00 2013/1/21
     */

    //package components;
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    //import javax.swing.JMenu;
    //import javax.swing.JMenuItem;
    //import javax.swing.JMenuBar;
    //import javax.swing.JFrame;
    //import javax.swing.KeyStroke;
    //import java.awt.event.*;

    import javax.swing.plaf.basic.BasicInternalFrameUI;

    import java.awt.event.*;

    import java.awt.Desktop;
    import javax.swing.*;

    import javax.swing.BoxLayout;

    import java.awt.*;
    import java.applet.*;

    public class rebuiltgui extends JApplet {

        public void init() {

            javax.swing.SwingUtilities.invokeLater(new Runnable() {

                public void run() {

                    createAndShowGUI();
                }
            });
        }

        private void createAndShowGUI() {

            JLayeredPane layerz = new JLayeredPane();
            JPanel loginpane = new JPanel();

    //      Dimension appletdim = Toolkit.getDefaultToolkit().getScreenSize();
            Dimension appletdim = this.getSize();


    //      this.setLayout( new BoxLayout( this, BoxLayout.X_AXIS ));

    //      content.add(desktop, BorderLayout.CENTER);

            appletdim.height += 15;

            JDesktopPane desktop = new JDesktopPane();
            desktop.setPreferredSize(new Dimension( appletdim.width, appletdim.height ));
            this.add( desktop );

            JInternalFrame mainframe = new JInternalFrame(("Mainframe"), false, false, false, false);

            mainframe.setBounds( 0, 0, appletdim.width, appletdim.height );

            BasicInternalFrameUI ui = (BasicInternalFrameUI) mainframe.getUI();
            Component north = ui.getNorthPane();
            MouseMotionListener[] actions = (MouseMotionListener[]) north.getListeners(MouseMotionListener.class);

            for (int i = 0; i < actions.length; i++) {

                north.removeMouseMotionListener(actions[i]);
            }


    //      loginframe.setSize(200, 150);
            mainframe.setBackground(Color.lightGray);
            desktop.add(mainframe);
    //      loginframe.moveToFront();


    //      desktop.add( loginframe );

            mainframe.setVisible(true);

            JInternalFrame loginframe;

            loginframe = new JInternalFrame( "Login Screen.", false, false, false, false );
            loginframe.setBounds( 0, 0, appletdim.width, appletdim.height );

            BasicInternalFrameUI uilogin = (BasicInternalFrameUI) loginframe.getUI();
            Component northli = uilogin.getNorthPane();
            MouseMotionListener[] actionsli = (MouseMotionListener[]) northli.getListeners(MouseMotionListener.class);

            for (int i = 0; i < actionsli.length; i++) {

                northli.removeMouseMotionListener(actions[i]);
            }

desktop.add( loginframe );

            loginframe.setVisible(true);
        }
    }
4

0 回答 0