⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 j_mdi.java

📁 一个十分好的java基础学习的课件
💻 JAVA
字号:
// ////////////////////////////////////////////////////////
// 
// J_MDI.java
// 

// ////////////////////////////////////////////////////////

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

public class J_MDI extends JFrame
{

    private JDesktopPane m_desktop= new JDesktopPane( );
    private int m_count= 0;

    public J_MDI( )
    {
        super("MDI Example");
        JMenuBar  theMenuBar  = new JMenuBar( );
        JMenu     theMenuFile = new JMenu("File");
        JMenuItem theMenuItem = new JMenuItem("New");

        setJMenuBar(theMenuBar);
        theMenuBar.add(theMenuFile);
        theMenuFile.add(theMenuItem);
        theMenuFile.setMnemonic('F');
        theMenuItem.setMnemonic('N');

        Container theContainer= getContentPane( );
        theContainer.add(m_desktop);

        theMenuItem.addActionListener( new ActionListener( )
            {
                public void actionPerformed(ActionEvent e)
                {
                    String s= "Document " + m_count;
                    JInternalFrame theInternalFrame = new JInternalFrame( s, true, true, true, true );
                    m_count++;
                    J_Draw thePanel = new J_Draw( );
                    Container theInternalContainer = theInternalFrame.getContentPane( );
                    theInternalContainer.add( thePanel, BorderLayout.CENTER );
                    theInternalFrame.pack( );

                    m_desktop.add( theInternalFrame );
                    theInternalFrame.setVisible( true );
                } // End of method: actionPerformed
            } // End of the anonymous inner class, which implements ActionListener
        ); // End of invoking addActionListener
        
        setSize(400, 250);
        setVisible(true);
    } // End of constructor: J_MDI

    public static void main( String args[] )
    { 
        JFrame app = new J_MDI( );

        Container cp = app.getContentPane( );
        app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
    } // End of method: main

} // End of class: J_MDI

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -