?? insertuserinfogui.java
字號:
{
if(!(Tools.checkMsg(passwordField.getText(), 6, 10, false)))
{
JOptionPane.showMessageDialog(frame,"輸入的密碼不符合長度!","警告",JOptionPane.WARNING_MESSAGE,null);
passwordField.setText("");
return;
}
}
if(passwordTwo.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"重復密碼不能為空!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
else
{
if(!(Tools.checkMsg(passwordTwo.getText(), 6, 10, false)))
{
JOptionPane.showMessageDialog(frame,"輸入的重復密碼不符合長度!","警告",JOptionPane.WARNING_MESSAGE,null);
passwordTwo.setText("");
return;
}
}
if(!passwordField.getText().equals(passwordTwo.getText()))
{
JOptionPane.showMessageDialog(frame,"重復密碼和新密碼不同!","警告",JOptionPane.WARNING_MESSAGE,null);
passwordField.setText("");
passwordTwo.setText("");
return;
}
if(sex.equals(""))
{
JOptionPane.showMessageDialog(frame,"請選擇性別!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
if(positionField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"職務不能為空","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}else
{
if(!(positionField.getText().length()<=5))
{
JOptionPane.showMessageDialog(frame,"職務超過5個字符!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
}
if((!(Tools.checkMsg(delField.getText(), 7, 12, true)))||delField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"電話輸入的不對,請確認是在7-12的數字!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
if((!(Tools.includeChar(emailField.getText(),'@')))||emailField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"E_mail輸入的格式不正確!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
if(!(Tools.checkMsg(textArea.getText(), 0, 30, false)))
{
JOptionPane.showMessageDialog(frame,"備注超過長度!","警告",JOptionPane.WARNING_MESSAGE,null);
return;
}
String [] userinfo=UserBO.userhead(idField.getText());
if(userinfo[0]!="F"){
JOptionPane.showMessageDialog(frame, "該ID號已存在", "提示", JOptionPane.WARNING_MESSAGE);
idField.setText("");
idField.requestFocus();
return;
}else{
JOptionPane.showMessageDialog(frame, "可以使用", "提示", JOptionPane.WARNING_MESSAGE);
idField.setEditable(false);
}
String year=(String)yearComboBox.getSelectedItem();
String month=(String)monthComboBox.getSelectedItem();
if(month.length()==1){
month="0"+month;
}
String day=(String)dayComboBox.getSelectedItem();
if(day.length()==1){
day="0"+day;
}
String dept=(String)deptComboBox.getSelectedItem();
String birth=year+month+day;
String name=nameField.getText();
String position=positionField.getText();
String remark=textArea.getText();
int i=UserBO.insertInfo(idField.getText(), name, passwordField.getText(), position, dept, sex, birth, delField.getText(), emailField.getText(), headpic, remark);
if(i==1){
JOptionPane.showMessageDialog(frame, "添加成功", "提示", JOptionPane.INFORMATION_MESSAGE);
}else
{
JOptionPane.showMessageDialog(frame, "添加失敗", "提示", JOptionPane.WARNING_MESSAGE);
}
}
});
commit.setText("提交");
commit.setBounds(71, 421, 78, 27);
frame.getContentPane().add(commit);
final JButton butRe = new JButton();
butRe.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
idField.setEditable(true);
textArea.setText("");
emailField.setText("");
delField.setText("");
passwordTwo.setText("");
passwordField.setText("");
nameField.setText("");
idField.setText("");
}
});
butRe.setText("重置");
butRe.setBounds(171, 421, 77, 27);
frame.getContentPane().add(butRe);
head = new JButton();
head.setBounds(336, 6, 49, 48);
frame.getContentPane().add(head);
final JButton button_2 = new JButton();
button_2.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
panel.setVisible(true);
}
});
button_2.addMouseListener(new MouseAdapter() {
public void mouseEntered(final MouseEvent e) {
button_2.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/0.gif"));
}
public void mouseExited(final MouseEvent e) {
button_2.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/h7.gif"));
}
});
button_2.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/h7.gif"));
button_2.setBounds(384, 27, 15, 27);
frame.getContentPane().add(button_2);
panel = new JPanel();
panel.setLayout(new GridLayout(0, 1));
panel.setBounds(336, 52, 45, 318);
panel.setVisible(false);
frame.getContentPane().add(panel);
final JButton button_9 = new JButton();
button_9.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_9.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t2.png";
}
});
button_9.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t2.png"));
panel.add(button_9);
final JButton button_5 = new JButton();
button_5.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_5.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t1.png";
}
});
button_5.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t1.png"));
panel.add(button_5);
final JButton button_3 = new JButton();
button_3.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_3.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t3.png";
}
});
button_3.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t3.png"));
panel.add(button_3);
final JButton button_4 = new JButton();
button_4.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t7.png"));
button_4.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_4.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t7.png";
}
});
panel.add(button_4);
final JButton button_6 = new JButton();
button_6.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t4.png"));
button_6.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_6.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t4.png";
}
});
panel.add(button_6);
final JButton button_7 = new JButton();
button_7.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t5.png"));
button_7.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_7.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t5.png";
}
});
panel.add(button_7);
final JButton button_8 = new JButton();
button_8.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t6.png"));
button_8.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_8.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t6.png";
}
});
panel.add(button_8);
final JButton button_10 = new JButton();
button_10.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t8.png"));
button_10.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
head.setIcon(button_10.getIcon());
panel.setVisible(false);
headpic="/edu/sccp/chat/image/t8.png";
}
});
panel.add(button_10);
final JButton button = new JButton();
button.setText("檢測ID");
button.addActionListener(new ActionListener(){
public void actionPerformed(final ActionEvent e){
if(idField.getText().length()==0)
{
JOptionPane.showMessageDialog(frame,"用戶名不能為空!","警告",JOptionPane.WARNING_MESSAGE,null);
idField.setText("");
return;
}
else
{
if(!(Tools.checkMsg(idField.getText(),8,10,true)))
{
JOptionPane.showMessageDialog(frame,"用戶名輸入格式不對,請確認輸入的是數字并保持在8-10之內!","警告",JOptionPane.WARNING_MESSAGE,null);
idField.setText("");
return;
}
}
String [] userinfo=UserBO.userhead(idField.getText());
if(userinfo[0]!="F"){
JOptionPane.showMessageDialog(frame, "該ID號已存在", "提示", JOptionPane.WARNING_MESSAGE);
idField.setText("");
idField.requestFocus();
}else{
JOptionPane.showMessageDialog(frame, "可以使用", "提示", JOptionPane.WARNING_MESSAGE);
idField.setEditable(false);
}
}
});
button.setBounds(226, 7, 75, 25);
frame.getContentPane().add(button);
label_11 = new JLabel();
label_11.setForeground(new Color(255, 0, 0));
label_11.setBounds(226, 67, 82, 15);
frame.getContentPane().add(label_11);
label_12 = new JLabel();
label_12.setForeground(new Color(255, 0, 0));
label_12.setBounds(227, 96, 81, 15);
frame.getContentPane().add(label_12);
label_13 = new JLabel();
label_13.setForeground(new Color(255, 0, 0));
label_13.setBounds(226, 245, 87, 15);
frame.getContentPane().add(label_13);
label_14 = new JLabel();
label_14.setForeground(new Color(255, 0, 0));
label_14.setBounds(226, 271, 82, 15);
frame.getContentPane().add(label_14);
Tools.setFormat(label_11);
Tools.setFormat(label_12);
Tools.setFormat(label_13);
Tools.setFormat(label_14);
final JLabel label_15 = new JLabel();
label_15.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_15.setText("職務:");
label_15.setBounds(0, 293, 64, 25);
frame.getContentPane().add(label_15);
positionField = new JTextField();
positionField.setBounds(81, 293, 141, 26);
frame.getContentPane().add(positionField);
label_16 = new JLabel();
label_16.setForeground(new Color(255, 0, 0));
label_16.setBounds(226, 37, 82, 16);
frame.getContentPane().add(label_16);
final JButton button_1 = new JButton();
button_1.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
frame.dispose();
}
});
button_1.setText("關閉");
button_1.setBounds(263, 422, 77, 25);
frame.getContentPane().add(button_1);
}
public void showGUI()
{
frame.setResizable(false);
frame.setSize(410,482);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
//new InsertUserInfoGUI().showGUI();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -