📄 writenote.java
字号:
package soft1;
import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Font;
import com.borland.dbswing.JdbTextField;
import com.borland.dbswing.JdbComboBox;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import java.awt.Color;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import com.borland.dx.sql.dataset.ConnectionDescriptor;
import com.borland.dx.sql.dataset.Load;
import com.borland.dx.sql.dataset.QueryDescriptor;
import com.borland.dx.dataset.Column;
import com.borland.dx.dataset.MetaDataUpdate;
import com.borland.dbswing.JdbTextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import soft1Method.DateChooserJButton;
import soft1Method.GetValue;
import com.borland.dbswing.JdbLabel;
import java.text.SimpleDateFormat;
import soft1Method.*;
import java.sql.SQLException;
import java.sql.Date;
public class WriteNote extends JPanel {
JLabel jLabel1 = new JLabel();
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
TitledBorder titledBorder1 = new TitledBorder("");
JLabel jLabel5 = new JLabel();
JButton jButton2 = new JButton();
Column column1 = new Column();
DateChooserJButton datachooser=new DateChooserJButton();
GetValue gv=new GetValue();
//SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd" + " " + "hh:mm:ss");
SimpleDateFormat tempDate1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
// SimpleDateFormat tempDate2 = new SimpleDateFormat("");
JLabel jLabel6 = new JLabel();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JComboBox jComboBox1 = new JComboBox();
JComboBox jComboBox2 = new JComboBox();
JTextArea jTextArea1 = new JTextArea();
Dataset2 dt=new Dataset2();
GetValue gvl=new GetValue();
String datetime1 = tempDate1.format(new java.util.Date());
//String datetime2 = tempDate2.format(new java.util.Date());
public WriteNote() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(xYLayout1);
setSize(new Dimension(562, 370));
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
jLabel1.setText("标题");
jLabel2.setText("天气");
jLabel3.setText("心情");
jLabel4.setText("正文:");
jLabel5.setText("特别提醒:");
jComboBox1.addItem("");
jComboBox1.addItem("很热");
jComboBox1.addItem("晴朗");
jComboBox1.addItem("阴");
jComboBox1.addItem("小雨");
jComboBox1.addItem("中雨");
jComboBox1.addItem("大雨");
jComboBox1.addItem("随便");
jComboBox2.addItem("");
jComboBox2.addItem("好");
jComboBox2.addItem("很好");
jComboBox2.addItem("一般");
jComboBox2.addItem("不好");
jComboBox2.addItem("很不好");
jComboBox2.addItem("随便");
jButton2.setText("保存");
jButton2.addActionListener(new WriteNote_jButton2_actionAdapter(this));
column1.setColumnName("ID");
column1.setDataType(com.borland.dx.dataset.Variant.INT);
column1.setRowId(true);
column1.setTableName("NotePad");
column1.setVisible(com.borland.jb.util.TriStateProperty.FALSE);
column1.setServerColumnName("ID");
column1.setSqlType(4);
jLabel6.setText("jLabel6");
jTextArea1.setBorder(titledBorder1);
jTextArea1.setLineWrap(true);
this.add(jLabel1, new XYConstraints(6, 6, 33, 28));
this.add(jLabel4, new XYConstraints(6, 43, 40, 28));
this.add(jLabel5, new XYConstraints(84, 43, -1, 28));
this.add(jLabel2, new XYConstraints(300, 43, 33, 28));
this.add(jLabel3, new XYConstraints(422, 43, 37, 28));
this.add(jButton2, new XYConstraints(231, 325, 107, 32));
this.add(jTextField1, new XYConstraints(46, 6, 320, 28));
this.add(jTextField2, new XYConstraints(146, 43, 147, 28));
this.add(jComboBox1, new XYConstraints(337, 43, 72, 28));
this.add(jLabel6, new XYConstraints(383, 6, 171, 28));
this.add(jTextArea1, new XYConstraints(6, 72, 545, 253));
this.add(jComboBox2, new XYConstraints(461, 43, 90, 28));
jLabel6.setText(datetime1);
}
public void jButton2_actionPerformed(ActionEvent e) throws
ClassNotFoundException, SQLException {
System.out.println(datetime1+" 0:00:00");
//String ss="Select * from NotePad where UserName='"+gv.Getvalue()+"' and Caption='"+jTextField1.getText()+"' and Mydate ='"+jLabel6.getText()+"'";
//dt.Rs(ss);
if(jTextField1.getText().equals("")){
JOptionPane.showMessageDialog(this,"您还未写标题!","提示",JOptionPane.PLAIN_MESSAGE);
}
/*else if(dt.Rs(ss).next()){
JOptionPane.showMessageDialog(this,"您还未写标题!","提示",JOptionPane.PLAIN_MESSAGE);
}*/
else{
String s="insert into NotePad(Mydate,Caption,Detail,UserName,Weather,Motion,Special)values('"+jLabel6.getText()+"','"+jTextField1.getText()+"','"+jTextArea1.getText()+"',"+
"'"+gvl.Getvalue()+"','"+jComboBox1.getSelectedItem()+"','"+jComboBox2.getSelectedItem()+"','"+jTextField2.getText()+"')";
System.out.println(s);
dt.Update(s);
JOptionPane.showMessageDialog(this,"上传成功!","提示",JOptionPane.PLAIN_MESSAGE);
}}
}
class WriteNote_jButton2_actionAdapter implements ActionListener {
private WriteNote adaptee;
WriteNote_jButton2_actionAdapter(WriteNote adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
try {
adaptee.jButton2_actionPerformed(e);
} catch (SQLException ex) {
} catch (ClassNotFoundException ex) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -