本文原创,禁止转载!
因为事情比较多,就想把代待办事项记录下来,可是网上找了一圈都不太好用,用java自己写了一个软件,运行后会直接贴在屏幕右上角,然后设置开机自启动,每次都会加载,要修改时点击三下“更改”(防止错误更改)就好了,方便简单。资料保存在硬盘,断电关机资料都不会消失。
代码,就一个类
package EasyNotes; import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JRootPane; import javax.swing.border.EmptyBorder; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JTextArea; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Toolkit; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.io.File; import java.io.IOException; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class mainFrame extends JFrame { private JPanel contentPane; int lock=0; String filePrefix="D://EasyNotes//data//"; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { mainFrame frame = new mainFrame(); frame.setUndecorated(true); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. * @throws Exception */ public mainFrame() throws Exception { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //setBounds(100, 100, 305, 417); Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screensize = kit.getScreenSize(); int width = screensize.width; int height = screensize.height; if(width-260>0&&height-417>0) { setBounds(width-260, 0, 260, 380); }else { setBounds(600, 0, 260, 380); } contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JButton b1 = new JButton("\u66F4\u6539"); b1.setOpaque(true); b1.setForeground(Color.WHITE); b1.setBackground(Color.BLACK); b1.setFont(new Font("宋体", Font.BOLD, 26)); b1.setBounds(0, 350, 163, 30); contentPane.add(b1); JTextArea t1 = new JTextArea(); t1.setForeground(Color.WHITE); t1.setBackground(Color.BLACK); t1.setBounds(0, 0, 260, 150); t1.setFont(new Font("宋体", Font.BOLD, 26)); contentPane.add(t1); JTextArea t2 = new JTextArea(); t2.setForeground(Color.WHITE); t2.setBackground(Color.GRAY); t2.setBounds(0, 150, 260, 200); t2.setFont(new Font("宋体", Font.BOLD, 26)); contentPane.add(t2); t1.setLineWrap(true); t2.setLineWrap(true); File p=new File(filePrefix); if(!p.exists()) {p.mkdirs();} File f1=new File(filePrefix+"notes1.txt"); File f2=new File(filePrefix+"notes2.txt"); if(!f1.exists()) {f1.createNewFile();} if(!f2.exists()) {f2.createNewFile();} txtOpration t=new txtOpration(); t1.setText(t.readTxt(filePrefix+"notes1.txt")); t2.setText(t.readTxt(filePrefix+"notes2.txt")); JButton b2 = new JButton("\u95DC\u9589"); b2.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { System.exit(0); } }); b2.setForeground(Color.WHITE); b2.setFont(new Font("宋体", Font.BOLD, 26)); b2.setOpaque(true); b2.setBackground(Color.BLACK); b2.setBounds(163, 350, 97, 30); contentPane.add(b2); b1.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if(lock>=3) { txtOpration t=new txtOpration(); try { t.writeTxt(t1.getText(), filePrefix+"notes1.txt"); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { t.writeTxt(t2.getText(), filePrefix+"notes2.txt"); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { t1.setText(t.readTxt(filePrefix+"notes1.txt")); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { t2.setText(t.readTxt(filePrefix+"notes2.txt")); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } lock=0; b1.setText("更改"); } else { b1.setText("再按"+(3-lock)+"下解锁。"); lock++; } } }); } }