import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.*;
public class diary extends JFrame{
static String file="a.ou";
JFrame f=new JFrame("日记本");
Container p=f.getContentPane();
Calendar c1=Calendar.getInstance();
File iconDir = new File("心情表情");
JOptionPane jop=new JOptionPane();
File file1=null;
final File[] iconFiles = iconDir.listFiles(new FileFilter() {
public boolean accept(File file)
{
return file.getName().toLowerCase().endsWith(".gif");
}
});
JLabel jlabel1=new JLabel("标 题"), //建立标签
jlabel2= new JLabel("日 期"),
jlabel3=new JLabel("天 气"),
jlabel4=new JLabel("心 情");
JTextArea
t4=new JTextArea(1,8),
t3=new JTextArea(1,8),
t2=new JTextArea(1,20),
t1=new JTextArea(40,80);
String[] description={
"阴天","晴天","下雨了","起风了", //天气组合框
"下雪了","有点热","有点冷"};
JComboBox c=new JComboBox();
final JComboBox comboBox = new JComboBox(iconFiles);
JPanel
pp=new JPanel(),
pa=new JPanel(),
ppanel=new JPanel();
FileDialog fd;
JButton //建立按钮
save=new JButton("保存日记"),
open=new JButton("查看日记"),
newFile =new JButton("新建日记"),
about=new JButton("关于"),
search=new JButton("检索日记");
JScrollPane jscrollpane=new JScrollPane(t1);//建立滚动条
public diary(){ //把组件加入到面板中
ppanel.add(newFile);
ppanel.add(save);
ppanel.add(open);
ppanel.add(search);
ppanel.add(about);
pa.add(jlabel1);
pa.add(t2);
pa.add(jlabel3);
pa.add(c);
pa.add(jlabel4);
pa.add(comboBox);
pa.add(jlabel2);
pa.add(t3);
pp.add(t4);
t3.append(c1.get(Calendar.YEAR)+
" 年 "+(c1.get(Calendar.MONTH)+1)+
" 月 " + c1.get(Calendar.DATE)+"日");
t4.append(c1.get(Calendar.YEAR)+
"."+(c1.get(Calendar.MONTH)+1)+
"." + c1.get(Calendar.DATE));
newFile.addActionListener(new ActionListener(){ //新建日记
public void actionPerformed(ActionEvent e){
save.setEnabled(true);
t1.setText(" ");
t2.setText(" ");
&nb