import javax.swing.*;
import java.io.*;
import java.util.*;
JTextArea area = new JTextArea();
public void actionPerformed(ActionEvent e) {
color = JColorChooser.showDialog(NoteBook.this, "", color);
area.setForeground(color);
}
}
public void actionPerformed(ActionEvent e) {
area.setText("");
}
}
public void actionPerformed(ActionEvent e) {
if (file != null)
filechooser.setSelectedFile(file);
int returnVal = filechooser.showOpenDialog(NoteBook.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
openFile();
}
}
}
public void actionPerformed(ActionEvent e) {
if (file != null)
filechooser.setSelectedFile(file);
int returnVal = filechooser.showSaveDialog(NoteBook.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = filechooser.getSelectedFile();
saveFile();
}
}
}
public void actionPerformed(ActionEvent e) {
int s = JOptionPane.showConfirmDialog(frame, "你真的要结束吗", "结束程序",
JOptionPane.YES_NO_CANCEL_OPTION);
if (s == JOptionPane.YES_OPTION)
System.exit(0);
}
}
public void actionPerformed(ActionEvent e) {
area.copy();
}
}
public void actionPerformed(ActionEvent e) {
area.paste();
}
}
public void actionPerformed(ActionEvent e) {
area.cut();
}
}
public void actionPerformed(ActionEvent e) {
Date d = new Date();
area.append(d.toString());
}
}
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "制作人:沈刚 QQ:289972365",
"关于本软件", JOptionPane.INFORMATION_MESSAGE);
}
}
try {
FileReader fr = new FileReader(file);
int len = (int) file.length();
char[] buffer = new char[len];
fr.read(buffer, 0, len);
fr.close();
area.setText(new String(buffer));
} catch (Exception e) {
e.printStackTrace();
}
try {
FileWriter fw = new FileWriter(file);
fw.write(area.getText());
fw.close();
} catch (Exception e) {
e.printStackTrace();
}
}
area.setLineWrap(true);
JScrollPane jsp = new JScrollPane(area);
JMenuBar jmb = new JMenuBar();
JMenu mFile = new JMenu("文件");
JMenu mEdit = new JMenu("编辑");
JMenu mHelp = new JMenu("关于");
mNew.addActionListener(new xinjian());
mFile.add(mNew);
mOpen.addActionListener(new dakai());
mFile.add(mOpen);
mSave.addActionListener(new baocun());
mFile.add(mSave);
mExit.addActionListener(new close());
mFile.add(mExit);
mFile.setMnemonic(KeyEvent.VK_F);
jmi = new JMenuItem("拷贝");
jmi.addActionListener(new kaobei());
mEdit.add(jmi);
jmi.addActionListener(new jianqie());
mEdit.add(jmi);
jmi.addActionListener(new niantie());
mEdit.add(jmi);
jmi.addActionListener(new color());
mEdit.add(jmi);
jmi.addActionListener(new adddate());
mEdit.add(jmi);
jmi = new JMenuItem("关于本软件");
jmi.addActionListener(new About());
mHelp.add(jmi);
jmb.add(mFile);
jmb.add(mEdit);
jmb.add(mHelp);
Image icon = Toolkit.getDefaultToolkit().getImage(
"icon.gif");
this.setJMenuBar(jmb);
this.setTitle("刚刚记事本1.0");
this.getContentPane().add(jsp);
this.setSize(640, 480);
this.setLocation(200, 150);
this.setIconImage(icon);
this.setVisible(true);
String img = "logo.jpg";
load.getContentPane().add(new JLabel(new ImageIcon(img)));
load.setUndecorated(true);
load.setAlwaysOnTop(true);
load.pack();
load.setLocation((screen.width - load.getWidth()) / 2,
(screen.height - load.getHeight()) / 2);
try {
Thread.sleep(5000);
} catch (Exception e) {
e.printStackTrace();
}
}