⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 new_memoire.java~604~

📁 提醒簿采用java语言和xml数据库结合开发.通过读写xml文件动态写入读取备忘录.,通过线程机制及时提醒您.提供多种提醒方式.操作方便,使用简单.是个很不错的提醒簿. 运行平台: Windows
💻 JAVA~604~
字号:
package new_memoire;

import java.awt.*;

import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import java.text.*;
import dboperate.*;
import javax.swing.JOptionPane;
import javax.xml.parsers.*;
import main_frame.mainFrame;

/**
 * <p>Title:勿忘软件,lzquan </p>
 *
 * <p>Description:勿忘软件 </p>
 *
 * <p>Copyright: 泉水依然 Copyright (c) 2007-03-20</p>
 *
 * <p>Company: 泉水依然</p>
 *
 * @author :李政权,湖南农业大学科学技术师范学院04计算机教育班.
 *
 * QQ:25241418
 */
public class New_Memoire extends JFrame {

    XYLayout xYLayout1 = new XYLayout();
    JTextArea jTextArea1 = new JTextArea();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    XYLayout xYLayout2 = new XYLayout();
    TitledBorder titledBorder1 = new TitledBorder("");
    JLabel jLabel1 = new JLabel();
    XYLayout xYLayout3 = new XYLayout();
    JLabel jLabel2 = new JLabel();
    JScrollPane jScrollPane1 = new JScrollPane();
    JTextArea jTextArea2 = new JTextArea();
    JTextField jTextField1 = new JTextField();
    TitledBorder titledBorder2 = new TitledBorder("");
    JPanel jPanel3 = new JPanel();
    XYLayout xYLayout4 = new XYLayout();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JComboBox jComboBox_Class = new JComboBox();
    JComboBox jComboBox_mode = new JComboBox();
    /**
     * 动态读取提醒类别.
     */
    xmlConn classXmlConn = new xmlConn("Class_Name", 2);
    Object[][] data = classXmlConn.getData(); //获得类别的所有值

    xmlConn memoireXmlConn = new xmlConn("Not_Forget", 9);
    Object[][] memoireData = memoireXmlConn.getData(); //获得提醒记录所有值
    /**
     * 设置时间模式.
     */
    SpinnerModel model2 = new SpinnerDateModel();
    JSpinner jSpinner_Time = new JSpinner(model2);

    JCheckBox jCheckBox_use = new JCheckBox();
    JCheckBox jCheckBox_confirm = new JCheckBox();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    mainFrame main_Frame = null;
    /**
     * 获取主窗体对象.
     * @param mainFrame Object
     */
    public void setMainFrame(Object mainFrame){
        this.main_Frame =(mainFrame) mainFrame;
    }

    public New_Memoire() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.getContentPane().setBackground(new Color(236, 233, 234));
        this.setTitle("勿忘软件 -- 新建备忘录 -- ^_^");
        getContentPane().setLayout(xYLayout1);
        jTextArea1.setText("      新建提示:\n      1)按要求填写内容.\n      2)选择提醒方式,是否需要确认.");
        jTextArea1.setFocusable(false);//不能获取焦点.
        xYLayout1.setWidth(490);
        xYLayout1.setHeight(259);
        jPanel1.setBackground(new Color(236, 233, 255));
        jPanel1.setBorder(BorderFactory.createEtchedBorder());
        jPanel1.setLayout(xYLayout3);
        jPanel2.setLayout(xYLayout2);
        jPanel2.setBackground(new Color(236, 233, 255));
        jPanel2.setBorder(titledBorder1);
        jLabel1.setText("提醒名称:");
        jLabel2.setText("提醒内容:");
        jPanel3.setLayout(xYLayout4);
        jPanel3.setBackground(new Color(236, 233, 255));
        jPanel3.setBorder(BorderFactory.createEtchedBorder());
        jLabel3.setText("提醒类别:");
        jLabel4.setText("提醒方式:");
        jLabel6.setText("指定时间:");
        jCheckBox_use.setBackground(new Color(236, 233, 255));
        jCheckBox_use.setSelected(true);
        jCheckBox_use.setText("提醒有效");
        jCheckBox_confirm.setBackground(new Color(236, 233, 255));
        jCheckBox_confirm.setText("提醒需要确认");
        jButton1.setText("确定");
        jButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jButton1_actionPerformed(e);
            }
        });
        jButton2.setText("取消");
        jButton2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jButton2_actionPerformed(e);
            }
        });
        jSpinner_Time.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
        this.getContentPane().add(jTextArea1, new XYConstraints(0, 0, 500, -1));
        this.getContentPane().add(jPanel2, new XYConstraints( -2, 217, 494, 36));
        jPanel1.add(jLabel1, new XYConstraints(23, 7, 58, -1));
        jPanel1.add(jScrollPane1, new XYConstraints(22, 53, 254, 88));
        jPanel1.add(jTextField1, new XYConstraints(86, 4, 190, -1));
        jPanel1.add(jLabel2, new XYConstraints(23, 33, 58, -1));
        this.getContentPane().add(jPanel3, new XYConstraints(288, 54, 204, 164));
        jScrollPane1.getViewport().add(jTextArea2);
        jPanel3.add(jComboBox_Class, new XYConstraints(70, 6, 109, 20));
        jPanel3.add(jLabel3, new XYConstraints(7, 8, 59, -1));
        jPanel2.add(jButton1, new XYConstraints(295, 2, 70, 22));
        jPanel2.add(jButton2, new XYConstraints(384, 2, 70, 22));
        jPanel2.add(jCheckBox_confirm, new XYConstraints(118, 2, 108, -1));
        jPanel2.add(jCheckBox_use, new XYConstraints(19, 2, 77, -1));
        jPanel3.add(jComboBox_mode, new XYConstraints(70, 44, 108, 20));
        jPanel3.add(jLabel4, new XYConstraints(7, 44, 59, -1));
        jPanel3.add(jLabel6, new XYConstraints(7, 82, -1, -1));
        jPanel3.add(jSpinner_Time, new XYConstraints(18, 108, 159, 23));
        this.getContentPane().add(jPanel1, new XYConstraints(0, 54, 285, 163));
        this.setDefaultCloseOperation(this.DISPOSE_ON_CLOSE);
        jComboBox_mode.addItem("默认提醒");
        jComboBox_mode.addItem("弹出窗口");
        jComboBox_mode.addItem("闪烁提醒");
        jComboBox_mode.addItem("播放声音");
        /**
         * 将提醒类别动态加载进来.
         */
        for(int i=0;i<this.data.length;i++){
               this.jComboBox_Class.addItem(data[i][1]);
            }



    }

    public void jButton2_actionPerformed(ActionEvent e) {
        this.dispose();
    }

    /**
     * 提交信息.
     * @param e ActionEvent
     */
    public void jButton1_actionPerformed(ActionEvent e) {
        if(this.checkFrame()){
            try {
                writexml insertXml = new writexml();
                insertXml.toWrite(this.getAllMemoire());
                insertXml.toSave();
                this.dispose();
                this.main_Frame.setisNewMemoire();//告知主窗体已经新建.需要重新读取数据.
            } catch (ParserConfigurationException ex) {
                JOptionPane.showMessageDialog(null,"抱歉,操作失败!");
                this.dispose();
            }
        }
    }

    /**
     * 取得新建的所有信息.
     * @return Object[]
     */
    public Object[] getInsertValue(){
        Object insert[] = new Object[9];
        try {
            insert[0] = this.memoireXmlConn.getMaxID()+1;
            insert[1] = this.jTextField1.getText();
            insert[2] = this.jTextArea2.getText();
            insert[3] = this.jComboBox_Class.getSelectedItem();
            insert[4] = this.jSpinner_Time.getValue();
            insert[5] = this.jComboBox_mode.getSelectedItem();
            if (this.jCheckBox_confirm.isSelected()) {
                insert[6] = 1;
            } else {
                insert[6] = 0;
            }
            if (this.jCheckBox_use.isSelected()) {
                insert[7] = 1;
            } else {
                insert[7] = 0;
            }
            insert[8] = 1;
        } catch (Exception ex) {
            System.out.println("getvalue catch"+ex.getMessage());
            return null;
        }
        return insert;
    }

    /**
     * 取得所有信息.包括插入的信息.
     * @param args String[]
     */
    public Object[][] getAllMemoire() {
        Object[] arry = this.getInsertValue();
        int newRow = this.memoireData.length + 1;
        //定义新的数组存放所有的数据.包括要插入的.
        Object newMemoireData[][] = new Object[newRow][9];
       //把新的数据存放到新的数组里面.
        for (int k = 0; k < newMemoireData[0].length; k++) {
            newMemoireData[0][k] = arry[k];
        }
        //将剩余的其它数据一同放入新的数组.
        for (int m = 0, n = 1; m < this.memoireData.length; m++, n++)
            for (int x = 0; x < 9; x++) {
                newMemoireData[n][x] = this.memoireData[m][x];
            }
        return newMemoireData;
    }


    public void setEditValue(Object[] frameValue) {
        this.jTextField1.setText(frameValue[1].toString());
        this.jTextArea2.setText(frameValue[2].toString());
        this.jComboBox_Class.setSelectedItem(frameValue[3].toString());
        this.jSpinner_Time.setValue(frameValue[4].toString());
        this.jComboBox_mode.setSelectedItem(frameValue[5].toString());
        if (frameValue[6].toString().equals("1")) {
            this.jCheckBox_confirm.setSelected(true);
        } else {
            this.jCheckBox_confirm.setSelected(false);
        }
        if (frameValue[7].toString().equals("1")) {
            this.jCheckBox_use.setSelected(true);
        } else {
            this.jCheckBox_use.setSelected(false);
        }
        frameValue[8] = 0;
    }




    /**
     * 检查输入时候正确.
     * @param args String[]
     */
    public boolean checkFrame(){
        if (this.jTextArea2.getText().equals("") ||
            this.jTextField1.getText().equals("")) {
            JOptionPane.showMessageDialog(null,"抱歉,标题和内容不能为空!");
            return false;
        }else{
            return true;
        }
    }


    /**
     * 设置提示信息.
     * @return String
     */
    public void setEditMessage(String Message){
        this.jTextArea1.setText(Message);
    }

    public static void main(String[] args) {
        New_Memoire new_memoire = new New_Memoire();
        new_memoire.setSize(500, 300);
        new_memoire.setLocationRelativeTo(null);
        new_memoire.setVisible(true);
    }


}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -