errordialog.java
来自「熟悉非常简单CPU模拟器 1、将所给模拟器的源程序编译成执行程序。 2、运行并观」· Java 代码 · 共 78 行
JAVA
78 行
import java.awt.*;
import java.awt.event.*;
public
class ErrorDialog
extends Dialog
implements ActionListener
{
public ErrorDialog( Frame parent, String title, boolean modal, String
errorString )
{
super( parent, title, modal );
setLayout( new GridBagLayout() );
GridBagConstraints gbc = new GridBagConstraints();
Label errorLabel = new Label( errorString, Label.CENTER );
errorLabel.setFont( new Font( "SansSerif", Font.BOLD, 12 ) );
gbc.anchor = GridBagConstraints.CENTER;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets( 5, 5, 5, 5 );
gbc.weightx = 0;
gbc.weighty = 0;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridheight = 2;
add( errorLabel, gbc );
okButton = new Button( "OK" );
okButton.addActionListener( this );
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridheight = GridBagConstraints.REMAINDER;
add( okButton, gbc );
addWindowListener(
new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
dispose();
}
}
);
setResizable( false );
pack();
}
public void actionPerformed( ActionEvent evt )
{
Object eventSource = evt.getSource();
if ( eventSource == okButton )
{
dispose();
}
}
private Button okButton;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?