第九次作业第二题.txt
来自「编写一个有两个文本框和一个按钮的应用程序,在一个文本框输入一个字符串按回车键或者」· 文本 代码 · 共 53 行
TXT
53 行
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 + =
减小字号Ctrl + -
显示快捷键?