📄 desktoptest.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DesktopTest extends JFrame {
private JDesktopPane Desktop;
public DesktopTest(){
super( "Using a JDesktopPane" );
JMenuBar bar = new JMenuBar();
JMenu addMenu = new JMenu( "Add" );
JMenuItem newFrame = new JMenuItem( "Internal Frame" );
addMenu.add( newFrame );
bar.add( addMenu );
setJMenuBar( bar );
Desktop = new JDesktopPane();
getContentPane().add( Desktop );
newFrame.addActionListener(new ActionListener() {
public void actionPerformed( ActionEvent event ) {
JInternalFrame f = new JInternalFrame("Internal Frame", true, true, true, true );
Container container = f.getContentPane();
f.pack();
Desktop.add( f );
f.setVisible( true );
}
}); // end call to addActionListener
setSize( 300, 220 );
setVisible( true );
} // end constructor
public static void main( String args[] ){
DesktopTest application = new DesktopTest();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -