📄 cmpaboutbox.java
字号:
if ( purpose2 != null && purpose2.length() > 0 )
{
_purpose2 = new Label( purpose2, Label.CENTER );
_purpose2.setFont( FontFactory.build( "Dialog", Font.ITALIC, 12 ) );
_purpose2.setForeground( BLACK );
_purpose2.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets = new Insets( 0, 10, 0, 10 );
( ( GridBagLayout ) getLayout() ).setConstraints( _purpose2, gbc );
add( _purpose2 );
}
_status = new Label( status, Label.CENTER );
_status.setFont( FontFactory.build( "Dialog", Font.BOLD, 12 ) );
_status.setForeground( LABEL_FOREGROUND );
_status.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets = new Insets( 10, 10, 0, 10 );
( ( GridBagLayout ) getLayout() ).setConstraints( _status, gbc );
add( _status );
_released = new Label( "released: " + released, Label.CENTER );
_released.setFont( FontFactory.build( "Dialog", Font.PLAIN, 11 ) );
_released.setForeground( LABEL_FOREGROUND );
_released.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 4;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets = new Insets( 0, 10, 10, 10 );
( ( GridBagLayout ) getLayout() ).setConstraints( _released, gbc );
add( _released );
final String copyright;
if ( firstCopyrightYear == Build.THIS_COPYRIGHT_YEAR )
{
copyright = Integer.toString( Build.THIS_COPYRIGHT_YEAR );
}
else
{
copyright = firstCopyrightYear + "-" + Build.THIS_COPYRIGHT_YEAR;
}
_copyright = new Label( "copyright " + copyright, Label.LEFT );
_copyright.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
_copyright.setForeground( DARK_GREEN );
_copyright.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 5;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets( 5, 10, 0, 5 );
( ( GridBagLayout ) getLayout() ).setConstraints( _copyright, gbc );
add( _copyright );
_author = new Label( author, Label.LEFT );
_author.setFont( FontFactory.build( "Dialog", Font.BOLD + Font.ITALIC, 11 ) );
_author.setForeground( DARK_GREEN );
_author.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 6;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets( 0, 10, 0, 5 );
( ( GridBagLayout ) getLayout() ).setConstraints( _author, gbc );
add( _author );
_cmp = new Label( "Canadian Mind Products", Label.LEFT );
_cmp.setFont( FontFactory.build( "Dialog", Font.BOLD + Font.ITALIC, 11 ) );
_cmp.setForeground( DARK_GREEN );
_cmp.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 7;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets( 0, 10, 0, 5 );
( ( GridBagLayout ) getLayout() ).setConstraints( _cmp, gbc );
add( _cmp );
_addr1 = new Label( "#101 - 2536 Wark Street", Label.LEFT );
_addr1.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
_addr1.setForeground( DARK_GREEN );
_addr1.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 8;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets( 0, 10, 0, 5 );
( ( GridBagLayout ) getLayout() ).setConstraints( _addr1, gbc );
add( _addr1 );
_addr2 = new Label( "Victoria, BC Canada V8T 4G8", Label.LEFT );
_addr2.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
_addr2.setForeground( DARK_GREEN );
_addr2.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 9;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets( 0, 10, 0, 5 );
( ( GridBagLayout ) getLayout() ).setConstraints( _addr2, gbc );
add( _addr2 );
_phone = new Label( "phone:(250) 361-9093", Label.RIGHT );
_phone.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
_phone.setForeground( DARK_GREEN );
_phone.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 9;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets( 0, 5, 0, 10 );
( ( GridBagLayout ) getLayout() ).setConstraints( _phone, gbc );
add( _phone );
_mailto = new Label( "roedyg@mindprod.com", Label.LEFT );
_mailto.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
_mailto.setForeground( DARK_GREEN );
_mailto.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 10;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets( 0, 10, 0, 5 );
( ( GridBagLayout ) getLayout() ).setConstraints( _mailto, gbc );
add( _mailto );
_http =
new Label( "http://mindprod.com/products.html#" + masterSite,
Label.RIGHT );
_http.setFont( FontFactory.build( "Dialog", Font.ITALIC, 10 ) );
_http.setForeground( DARK_GREEN );
_http.setBackground( WHITE );
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 10;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets( 0, 5, 0, 10 );
( ( GridBagLayout ) getLayout() ).setConstraints( _http, gbc );
add( _http );
_dismissButton = new Button( "Dismiss" );
_dismissButton.setFont( FontFactory.build( "Dialog", Font.BOLD, 15 ) );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 11;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets = new Insets( 15, 10, 15, 10 );
( ( GridBagLayout ) getLayout() ).setConstraints( _dismissButton, gbc );
_dismissButton.requestFocus();
add( _dismissButton );
// hook up About box listeners
this.addFocusListener( new FocusAdapter()
{
/**
* Handle About Dialog getting focus, give to dismiss Button.
*
* @param e event giving details
*/
public void focusGained( FocusEvent e )
{
_dismissButton.requestFocus();
}// end focusGained
}// end anonymous class
);// end addFocusListenerline
this.addWindowListener( new WindowAdapter()
{
/**
* Handle request to close about box
*
* @param e event giving details of closing.
*/
public void windowClosing( WindowEvent e )
{
dismiss();
}// end WindowClosing
}// end anonymous class
);// end addWindowListener line
_dismissButton.addActionListener( new ActionListener()
{
/**
* close down the About box when user clicks Dismiss
*/
public void actionPerformed( ActionEvent e )
{
Object object = e.getSource();
if ( object == _dismissButton )
{
dismiss();
}// end if
}// end actionPerformed
}// end anonymous class
);// end addActionListener line
// The following code is only necessary if you want
// any keystroke while the Dismiss button has focus
// to simulate clicking the Dismiss button.
_dismissButton.addKeyListener( new KeyAdapter()
{
/**
* Handle Dismiss button getting a function keystroke, treat like a
* dismiss Button click
*
* @param e event giving details
*/
public void keyPressed( KeyEvent e )
{
dismiss();
}// end keyPressed
/**
* Handle Dismiss button getting an ordinary keystroke, treat like a
* dismiss Button click
*
* @param e event giving details
*/
public void keyTyped( KeyEvent e )
{
dismiss();
}// end keyTyped
}// end anonymous class
);// end addKeyListener
this.validate();
this.setVisible( true );
}// end constructor
// --------------------------- main() method ---------------------------
/**
* sample test driver
*
* @param args not used
*/
public static void main( String[] args )
{
if ( DEBUGGING )
{
final Frame frame = new Frame( "About box test" );
frame.setSize( 450, 400 );
MenuBar mb = frame.getMenuBar();
if ( mb == null )
{
mb = new MenuBar();
frame.setMenuBar( mb );
}
Menu help = mb.getHelpMenu();
if ( help == null )
{
help = new Menu( "Help", /* tearoff */false );
mb.setHelpMenu( help );
}
help.add( new MenuItem( "keyboard" ) );
help.add( new MenuItem( "command line" ) );
help.add( new MenuItem( "About" ) );
help.addActionListener( new ActionListener()
{
/**
* Handle Menu Selection Request
*
* @param e event giving details of selection
*/
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if ( command.equals( "About" ) )
{
// Don't need to retain a reference.
// We do nothing more that fire it up.
new CMPAboutBox( frame,
"Sample Amanuensis",
"1.3",
"Teaches you how to interconvert the 16 basic Java types,",
"e.g. String to int, Long to double.",
"freeware",
"2000-01-01"
/* RELEASE_DATE */,
1996
/* copyright */,
"CONVERTER" );
}// end if
}// end ActionListener
}// end anonymous class
);// end addActionListener line
frame.addWindowListener( new WindowAdapter()
{
/**
* Handle request to shutdown.
*
* @param e event giving details of closing.
*/
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}// end WindowClosing
}// end anonymous class
);// end addWindowListener line
frame.validate();
frame.setVisible( true );
}// end if
}// end main
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -