?? dialogabout.java
字號:
package test.paint;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
/**
* DialogAbout類
* 作者:曾燕秋
* 初始時間:2007 5-17
* 最后一次修改時間:2007 6-17
*/
public class DialogAbout extends JDialog {
//變量Image用來存放對話框的圖片
private Image img=null;
//String 用來顯示對話框的內容
private String str=null;
JTextArea taText = new JTextArea();
JButton btnOK = new JButton();
public DialogAbout( Frame parent, Image img, String str ) throws HeadlessException {
super(parent,true);
this.img = img;
this.str = str;
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**
* 初始化對話框AboutDialog的界面
* @throws Exception
*/
private void jbInit() throws Exception {
taText.setBackground( SystemColor.control );
taText.setBounds( new Rectangle( 124, 15, 137, 137 ) );
this.getContentPane().setLayout( null );
this.setSize( new Dimension( 300, 169 ) );
this.setLocation( 300,300 );
btnOK.setBounds(new Rectangle( 104, 110, 72, 20 ) );
btnOK.setText( "確定" );
btnOK.addActionListener(
new DialogAbout_btnOK_actionAdapter( this )
);
this.getContentPane().add( btnOK, null );
this.getContentPane().add( taText, null );
taText.append( str );
taText.setEditable( false );
taText.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
this.setTitle( "關于" );
}
public void paint( Graphics g )
{
super.paint( g );
g.drawImage( img, 30, 50, 64, 64, this );
}
/**
* 監聽OK按鈕引發的事件
* @param e
*/
void btnOK_actionPerformed( ActionEvent e ) {
this.setVisible( false );
this.dispose();
}
}
/**
* 用于OK按鈕的觸發
* @author 曾燕秋
*
*/
class DialogAbout_btnOK_actionAdapter implements java.awt.event.ActionListener {
DialogAbout adaptee;
DialogAbout_btnOK_actionAdapter( DialogAbout adaptee ) {
this.adaptee = adaptee;
}
public void actionPerformed( ActionEvent e ) {
adaptee.btnOK_actionPerformed( e );
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -