desktopanddialog.java
来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 45 行
JAVA
45 行
package examples.windows;
import javax.swing.*;
import java.awt.*;
/** An example class used to demonstrate the use of
* the JDesktopPane, JInternalFrame, and
* JOptionPane components
*/
public class DesktopAndDialog extends JFrame {
private static final boolean RESIZABLE = true;
private static final boolean CLOSABLE = true;
private static final boolean MAXIMIZABLE = true;
private static final boolean ICONIFIABLE = true;
private static final boolean MODAL = false;
/** Class constructor method
* @param titleText Window's title bar text
*/
public DesktopAndDialog( String titleText ) {
super( titleText );
addWindowListener( new WindowCloser() );
JInternalFrame ifrm = new JInternalFrame(
"Internal Frame",
RESIZABLE, CLOSABLE, MAXIMIZABLE, ICONIFIABLE );
ifrm.setPreferredSize( new Dimension( 375, 300 ) );
JDesktopPane dt = new JDesktopPane();
dt.setLayout( new FlowLayout() );
dt.add( ifrm );
getContentPane().add( dt, BorderLayout.CENTER );
setSize( 500, 400 );
setVisible( true );
JOptionPane.showMessageDialog(
ifrm, "This is a JOptionPane" );
}
/** The test method for the class
* @param args not used
*/
public static void main( String[] args ) {
new DesktopAndDialog(
"Example Desktop with Dialog" );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?