📄 helpframe.java
字号:
/**
* 源文件:HelpFrame.java
* 作用:系统帮助文档
*/
package mypro;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
public class HelpFrame extends JFrame implements ActionListener
{
private JList txtHelp;
private JButton btnSure;
private JScrollPane helpPanel;
private JPanel southPanel;
private Vector vv;
public HelpFrame()
{
txtHelp=new JList();
helpPanel=new JScrollPane();
southPanel=new JPanel();
btnSure=new JButton("确定");
btnSure.addActionListener(this);
Container me=this.getContentPane();
me.add(helpPanel,BorderLayout.CENTER);
me.add(southPanel,BorderLayout.SOUTH);
southPanel.add(btnSure);
helpPanel.getViewport().add(txtHelp);
vv=readTxt();
txtHelp.setListData(vv);
this.setTitle("帮助文档");
this.setSize(480,380);
this.setLocationRelativeTo(this);
this.setResizable(false);
this.setVisible(true);
}
public void actionPerformed(ActionEvent bae)
{
this.dispose();
}
/*读入文本文件内容*/
public Vector readTxt()
{
Vector ve= new Vector();
try
{
File file = new File("..\\S1GraduationDevice\\帮助文挡\\help.txt");
if(!file.exists())
{
file.createNewFile();
}
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String str;
while((str=br.readLine())!=null)
{
ve.add(str);
}
br.close();
fr.close();
}
catch(FileNotFoundException fe)
{
JOptionPane.showMessageDialog(null,"无此文件","错误",JOptionPane.ERROR_MESSAGE);
}
catch(IOException ie)
{
JOptionPane.showMessageDialog(null,"文件读取有错","错误",JOptionPane.ERROR_MESSAGE);
}
return(ve);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -