📄 xinjyh.java
字号:
package soft1;
import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.BorderFactory;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import Soft1.*;
import com.borland.dx.sql.dataset.Load;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import soft1Method.*;
import com.borland.dbswing.JdbTextField;
import com.borland.dx.dataset.Column;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.awt.event.FocusEvent;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Xinjyh extends JDialog {
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JTextField jTextField3 = new JTextField();
private QueryDataSet queryDataSet1 = new QueryDataSet();
JdbTextField jdbTextField1 = new JdbTextField();
JdbTextField jdbTextField2 = new JdbTextField();
Icon img1= new ImageIcon("src/Pic/Login.png");
Dataset2 dataset2=new Dataset2();
XYLayout xYLayout1 = new XYLayout();
XYLayout xYLayout2 = new XYLayout();
public Xinjyh(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public Xinjyh() {
this(new Frame(), "Xinjyh", true);
}
private void jbInit() throws Exception {
this.getContentPane().setBackground(Color.white);
this.setModal(true);
this.setTitle("新建用户");
//this.setUndecorated(true);
setResizable(false);
this.getContentPane().setLayout(xYLayout2);
jButton1.setBorder(BorderFactory.createEtchedBorder());
jButton1.setOpaque(false);
jButton1.setBorderPainted(false);
jButton1.setContentAreaFilled(false);
jButton1.setIcon(img1);
jButton2.addActionListener(new Xinjyh_jButton2_actionAdapter(this));
jButton3.addActionListener(new Xinjyh_jButton3_actionAdapter(this));
jdbTextField1.setColumnName("Name");
jdbTextField1.setDataSet(queryDataSet1);
jdbTextField2.setColumnName("Password");
jdbTextField2.setDataSet(queryDataSet1);
jLabel1.setText("请输入用户名:");
jLabel2.setText("请输入密码:");
jLabel3.setText("再次输入密码:");
jButton2.setText("重置");
jButton3.setText("确定");
jPanel1.setLayout(xYLayout1);
xYLayout2.setWidth(343);
xYLayout2.setHeight(248);
jPanel1.setBackground(new Color(212, 219, 234));
jPanel1.add(jLabel1, new XYConstraints(45, 59, -1, 31));
jPanel1.add(jdbTextField1, new XYConstraints(164, 59, 155, 31));
jPanel1.add(jLabel3, new XYConstraints(45, 153, -1, 31));
jPanel1.add(jTextField3, new XYConstraints(164, 149, 155, 31));
jPanel1.add(jdbTextField2, new XYConstraints(164, 104, 155, 31));
jPanel1.add(jLabel2, new XYConstraints(45, 104, 91, 31));
jPanel1.add(jButton2, new XYConstraints(203, 199, 64, 27));
jPanel1.add(jButton3, new XYConstraints(74, 199, 64, 27));
jPanel1.add(jButton1, new XYConstraints(0, 0, 341, 45));
this.getContentPane().add(jPanel1, new XYConstraints(1, 0, 341, 249));
}
public void jButton2_actionPerformed(ActionEvent e) {
jdbTextField1.setText("");
jdbTextField2.setText("");
jTextField3.setText("");
}
public void jButton3_actionPerformed(ActionEvent e) throws SQLException,
ClassNotFoundException {
if(jdbTextField1.getText().equals("")){ JOptionPane.showMessageDialog(this,"请输入用户名!","提示",JOptionPane.ERROR_MESSAGE);}
else if(jdbTextField2.getText().equals("")){ JOptionPane.showMessageDialog(this,"请输入密码!","提示",JOptionPane.ERROR_MESSAGE);}
else if(!jdbTextField2.getText().equals(jTextField3.getText())){
JOptionPane.showMessageDialog(this,"两次密码输入不一致","提示",JOptionPane.ERROR_MESSAGE);
}
else{
String s= "select * from User where Name='" +jdbTextField1.getText() + "'";
if(dataset2.Rs(s).next()){
JOptionPane.showMessageDialog(this,"该用户名已被使用,请选择其他的!","提示",JOptionPane.PLAIN_MESSAGE);
}
else{
String s2="insert into User(Name,Password) values ('"+jdbTextField1.getText()+"','"+jdbTextField2.getText()+"')";
dataset2.Update(s2);
JOptionPane.showMessageDialog(this,"新建成功!","提示",JOptionPane.PLAIN_MESSAGE);
this.setVisible(false);
}
}
}
public void jButton4_actionPerformed(ActionEvent e) {
this.setVisible(false);
}
}
class Xinjyh_jButton3_actionAdapter implements ActionListener{
private Xinjyh adaptee;
Xinjyh_jButton3_actionAdapter(Xinjyh adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
try {
adaptee.jButton3_actionPerformed(e);
} catch (ClassNotFoundException ex) {
} catch (SQLException ex) {
}
}
}
class Xinjyh_jButton2_actionAdapter implements ActionListener {
private Xinjyh adaptee;
Xinjyh_jButton2_actionAdapter(Xinjyh adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -