⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogabout.java

📁 Java画板
💻 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 + -