import javax.swing.*; import javax.swing.filechooser.FileFilter; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import java.text.SimpleDateFormat; import java.util.Date; /** * Created by asus on 2017/3/21. */ public class NotePad extends JFrame implements ActionListener, ThreadProc { private JTextArea text = null; // 定义文本区域 private JScrollPane jScrollPane = null; // 定义滚动条面板 private JMenuBar menuBar = null; // 定义JMenuBar private JMenu menuFile, menuSet = null; // 定义菜单对象 private JMenuItem newItem, openItem, saveItem, exitItem = null; // 定义文件菜单各个菜单项组件 private JMenuItem fontItem, colorItem = null; // 定义设置菜单的菜单项组件 private JLabel timeLabel, numberLabel = null; //状态栏显示系统时间 private JButton openButton, saveButton; private JFileChooser jFileChooser; public NotePad() { initNotepade(); init(); setTitle("我的记事本"); setSize(800, 600); setVisible(true); setLocationRelativeTo(null); setJMenuBar(menuBar); // 在窗体中加入JMenuBar组件 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); openButton = new JButton("打开"); saveButton = new JButton("保存"); add(openButton, BorderLayout.NORTH); add(saveButton, BorderLayout.SOUTH)<
如何用 java swing打开或者保存文件
最新推荐文章于 2022-04-06 23:42:45 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)