📄 about.java
字号:
package system;
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class About extends JDialog{
private static final int WIDTH = 300;
private static final int HEIGHT = 300;
public About(JFrame owner,String fileName){
super(owner,true);
JTextArea content = new JTextArea();
content.setOpaque(false);
content.setEditable(false);
content.setLineWrap(true);
JScrollPane s = new JScrollPane(content);
s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.getContentPane().add(s);
//====================加载文件内容=======================================
try{
BufferedReader b =
new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
String data;
while((data = b.readLine()) != null){
content.append(data);
content.append("\n");
}
}
catch(FileNotFoundException e){
e.printStackTrace();
System.out.println("About.java---没有找到相应的文件!");
}
catch(IOException e){
e.printStackTrace();
}
}
public static void showAboutDialog(JFrame owner,String fileName){
new About(owner,fileName).show();
}
public void show(){
this.setTitle("关于");
this.setSize(this.WIDTH,this.HEIGHT);
this.setResizable(false);
Dimension s = Toolkit.getDefaultToolkit().getScreenSize();
int width = s.width;
int height = s.height;
this.setLocation((width - this.WIDTH)/2,(height - this.HEIGHT)/2);
super.show();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -