📄 about.java
字号:
package notepad.popGUI;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JTextArea;
/**
* 类名About 关于记事本的对话框的类,用于显示记事本的一些信息。<BR>
*
* @author 黎明你好
* @version 2.0 2009-4-27
*/
public class About extends JDialog implements ActionListener
{
/**序列化时为了保持版本的兼容性*/
private static final long serialVersionUID = 1L;
/**确定按钮*/
private JButton approve_button;
/**显示文字的文本区*/
private JTextArea textArea;
/**用来添加图片用的*/
private MyCanvas canvas;
/**图片文件*/
private Image image;
/**
* 类的构造方法
*
* @param parent -
* JFrame 用来确定这个对话框是基于谁显示的
*/
public About(JFrame parent)
{
super(parent, true);
setTitle("关于 Java版记事本");
initGUI();
approve_button.addActionListener(this);
approve_button.requestFocus();/* 设置初始化焦点位置 */
this.setSize(400, 450);
this.setLocationRelativeTo(parent);
this.setResizable(false);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
});
}
/**
* 用于初始化对话框界面的方法
*/
public void initGUI()
{
approve_button = new JButton("确定");
textArea = new JTextArea();
Toolkit tool = getToolkit();
image = tool.getImage("image/about.jpg");
canvas = new MyCanvas(image);
textArea
.setText(" Java记事本\n\n 版本2.0(内部版本号 2009-4-27-12-58-20)\n 版权所有 "
+ " (C) 2009-2029 Andison Corp.\n\n 本产品符合最终用户许可协议,授权给\n\n 黎明你好\n Andison");
textArea.setEditable(false);
textArea.setFont(new Font("宋体", Font.PLAIN, 15));
textArea.setBackground(new Color(244, 244, 244));
this.setLayout(null);
this.add(canvas);
this.add(textArea);
this.add(approve_button);
canvas.setBounds(5, 5, 380, 90);
textArea.setBounds(20, 110, 355, 230);
approve_button.setBounds(310, 370, 70, 25);
}
/**
* 监听器方法,发生操作调用时该对话框设置成不显示,释放内存
*/
public void actionPerformed(ActionEvent e)
{
setVisible(false);
this.dispose();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -