import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class GUITest1 extends JFrame implements ActionListener{
JMenuBar jmb = new JMenuBar();
JMenu jm1 = new JMenu("游戏");
JMenu jm2 = new JMenu("查看");
JMenuItem jmi1 = new JMenuItem("开始");
JMenuItem jmi2 = new JMenuItem("暂停");
JMenuItem jmi3 = new JMenuItem("关于");
File f = new File("D:/说明书.txt");
String a = null;
public GUITest1(){
setBounds(200,300,200,300);
this.setJMenuBar(jmb);
jmb.add(jm1);
jm1.add(jmi1);
jm1.add(jmi2);
jmb.add(jm2);
jm2.add(jmi3);
jmi3.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==jmi3){
if(e.getActionCommand().equals("关于")){
try {
InputStreamReader read = new InputStreamReader (new FileInputStream(f),"ISO8859_1");
BufferedReader reader=new BufferedReader(read);
while((a=reader.readLine())!=null){
System.out.println( a);
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
public static void main(String[] args) {
new GUITest1();
}
}
//点击”关于“后显示不出中文,怎么样才能显示出来呢
------解决方案--------------------
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class GUITest1 extends JFrame implements ActionListener
{
JMenuBar jmb = new JMenuBar();
JMenu jm1 = new JMenu("游戏");
JMenu jm2 = new JMenu("查看");
JMenuItem jmi1 = new JMenuItem("开始");
JMenuItem jmi2 = new JMenuItem("暂停");
JMenuItem jmi3 = new JMenuItem("关于");
File f = new File("D:/jworkspace/说明书.txt");
String a = null;
JTextArea ja = null;
boolean help = false;
public GUITest1()
{
setBounds(200, 300, 200, 300);
this.setJMenuBar(jmb);
jmb.add(jm1);
jm1.add(jmi1);
jm1.add(jmi2);
jmb.add(jm2);
jm2.add(jmi3);
jmi3.addActionListener(this);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == jmi3)
{
if (e.getActionCommand().equals("关于"))
{
if (help)
{
this.remove(ja);
help = false;
}
ja = new JTextArea();
ja.setEditable(false);
this.add(ja);
try
{
InputStreamReader read = new InputStreamReader(
new FileInputStream(f), "GBK");
BufferedReader reader = new BufferedReader(read);
while ((a = reader.readLine()) != null)
{
System.out.println(a);