public class Display_txt extends JFrame {
JFrame jframe = new JFrame();
JTextArea content;
boolean flag = true;
String str_filePath = null;
public Display_txt(){
//输入框
content = new JTextArea(10,50);
content.setAutoscrolls(true);
JScrollPane contentScroll = new JScrollPane(content);
content.setBorder(BorderFactory.createBevelBorder(1));
JPanel upper = new JPanel(new BorderLayout());
upper.add(contentScroll);
//按钮
JButton filePath = new JButton("打开文件");
filePath.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
JFileChooser jfc = new JFileChooser();
if(jfc.showOpenDialog(jframe)==JFileChooser.APPROVE_OPTION ){
str_filePath = jfc.getSelectedFile().getAbsolutePath();
}
BufferedReader bufferedReader = new BufferedReader(new FileReader(str_filePath));
String str_line;
while((str_line=buffer
java实现极简单的 TXT小说阅读器
最新推荐文章于 2024-04-23 17:17:26 发布