📄 第九次作业第二题.txt
字号:
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class Jfilechooser extends JFrame implements ActionListener
{
JButton button;
JTextArea text;
JTextPane textpane;
FileInputStream readfile;
JScrollPane scroll;
Container con;
JFileChooser chooser=new JFileChooser();
public Jfilechooser()
{
super("窗口");
button=new JButton("打开文件");
button.addActionListener(this);
textpane=new JTextPane();
scroll=new JScrollPane(textpane);
setSize( new Dimension(400,400));
setVisible(true);
con=getContentPane();
con.add(button,BorderLayout.NORTH);
con.add(scroll,BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();System.exit(0);}});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==button)
{
String s;
int state =chooser.showOpenDialog(null);
Process p1 = Runtime.getRuntime().exec("notepad d:\\1234.txt");
File file=new File("c:\\hello.txt");
BufferedReader br = new BufferedReader(new FileReader(read));
catch(IOException e1)
{
e1.printStackTrace();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -