📄 aboutframe.java
字号:
package com.sam.net.download;
import javax.swing.*;
import java.awt.*;
public class AboutFrame extends JFrame{
public AboutFrame() {
super("关于我们...");
setSize(400,200);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Pane pane = new Pane();
getContentPane().setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(pane,"Center");
show();
}
}
class Pane extends JPanel implements Runnable {
private Image body;
private Thread runner;
private int y;
private String[] msg;
public Pane() {
Toolkit tk = (Toolkit)Toolkit.getDefaultToolkit();
body = (Image)tk.getImage(getClass().getResource("images/google.gif"));
this.msg = new String[] {
"程序设计:sam_chen <ali_sam@163.com>",
"完成日期:2008 年 11 月",
"",
"该软件完全仿照下载工具迅雷5制作",
"软件中,有许多图片和模板的版权属于原作者所有。",
"",
"该软件仅供 Java 程序员学习研究使用,不能",
"用于任何商业应用。"
};
this.y=msg.length*20-80;
if (this.runner==null) {
this.runner=new Thread(this);
this.runner.start();
}
}
public void paintComponent(Graphics g) {
Graphics2D comp = (Graphics2D)g;
comp.setColor(Color.white);
comp.fillRect(0,0,this.getWidth(),this.getHeight());
comp.setFont(new Font("宋体",0,12));
// draw the shadow of message
for (int m=0;m<3;m++) {
int k=255-(m*100)/2;
comp.setColor(new Color(k,k,k));
for (int i=0;i<msg.length;i++) {
comp.drawString(msg[i],135-m,y+5+i*20-m);
}
}
// draw the title image
comp.drawImage(body,0,this.getHeight() - this.body.getHeight(this),this);
// draw the message
comp.setColor(Color.blue);
for (int i=0;i<msg.length;i++) {
comp.drawString(msg[i],130,y+i*20);
}
}
// method: move the message
public void run() {
try {
while(true) {
Thread.sleep(100);
if (--y < - msg.length*20) y=this.getHeight()+20;
repaint();
}
} catch (InterruptedException ignore) {}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -