📄 teaaddframe.java
字号:
package com.hb.studentmanager.ui;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import com.hb.studentmanager.action.TeaAction;
import com.hb.studentmanager.tools.ChooseFile;
import com.hb.studentmanager.tools.DateChooserJButton;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class TeaAddFrame extends javax.swing.JDialog {
public JPanel mainPanel1;
public JScrollPane aspScrollPane1;
private JLabel tsLabel1;
public JButton koButton1;
public JScrollPane remScrollPane1;
public JTextArea remTextArea1;
public JLabel remLabel1;
public JScrollPane addScrollPane1;
public JTextArea addTextArea1;
public JLabel teaaddLabel1;
public JButton teaphoButton1;
public JLabel teaphoLabel1;
public JTextArea teaaspTextArea1;
public JLabel teaLabel1;
public JComboBox tealevComboBox1;
public JLabel tealevLabel1;
public JTextField teatelTextField1;
public JLabel telLabel1;
public JLabel teadateLabel1;
public ButtonGroup buttonGroup1;
public JRadioButton femaleRadioButton1;
public JRadioButton manRadioButton1;
public JLabel teasexLabel1;
public JTextField teanameTextField1;
public JLabel teanameLabel1;
public JTextField idTextField1;
public JLabel teaidLabel1;
public File file;
public DateChooserJButton datejButton;
TeaMainFrame tmf=new TeaMainFrame();
TeaAction ta=new TeaAction();
/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
//TeaAddFrame inst = new TeaAddFrame();
//inst.setVisible(true);
}
public TeaAddFrame(TeaMainFrame tmf) {
super();
this.tmf=tmf;
initGUI();
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width-450)/2, (height-470)/2);
this.setResizable(false);
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setTitle("\u6dfb\u52a0\u6559\u5e08\u4fe1\u606f");
getContentPane().setLayout(null);
{
{
buttonGroup1 = new ButtonGroup();
}
mainPanel1 = new JPanel();
getContentPane().add(mainPanel1);
mainPanel1.setBounds(0, 0, 441, 441);
mainPanel1.setLayout(null);
{
teaidLabel1 = new JLabel();
mainPanel1.add(teaidLabel1);
teaidLabel1.setText("\u6559\u5e08\u7f16\u53f7:");
teaidLabel1.setBounds(7, 7, 63, 28);
}
{
idTextField1 = new JTextField();
mainPanel1.add(idTextField1);
idTextField1.setBounds(77, 7, 154, 28);
}
{
teanameLabel1 = new JLabel();
mainPanel1.add(teanameLabel1);
teanameLabel1.setText("\u6559\u5e08\u59d3\u540d:");
teanameLabel1.setBounds(7, 63, 63, 28);
}
{
teanameTextField1 = new JTextField();
mainPanel1.add(teanameTextField1);
teanameTextField1.setBounds(77, 63, 154, 28);
}
{
teasexLabel1 = new JLabel();
mainPanel1.add(teasexLabel1);
teasexLabel1.setText("\u6027\u522b\uff1a");
teasexLabel1.setBounds(7, 105, 56, 28);
}
{
manRadioButton1 = new JRadioButton();
mainPanel1.add(manRadioButton1);
manRadioButton1.setText("\u7537");
manRadioButton1.setBounds(77, 105, 49, 28);
buttonGroup1.add(manRadioButton1);
manRadioButton1.setSelected(true);
}
{
femaleRadioButton1 = new JRadioButton();
mainPanel1.add(femaleRadioButton1);
femaleRadioButton1.setText("\u5973");
femaleRadioButton1.setBounds(147, 105, 56, 28);
buttonGroup1.add(femaleRadioButton1);
}
{
teadateLabel1 = new JLabel();
mainPanel1.add(teadateLabel1);
teadateLabel1.setText("\u51fa\u751f\u65e5\u671f:");
teadateLabel1.setBounds(7, 147, 63, 28);
}
{
telLabel1 = new JLabel();
mainPanel1.add(telLabel1);
telLabel1.setText("\u8054\u7cfb\u65b9\u5f0f:");
telLabel1.setBounds(7, 196, 56, 28);
}
{
teatelTextField1 = new JTextField();
mainPanel1.add(teatelTextField1);
teatelTextField1.setBounds(77, 196, 154, 28);
}
{
tealevLabel1 = new JLabel();
mainPanel1.add(tealevLabel1);
tealevLabel1.setText("\u6559\u5e08\u7ea7\u522b:");
tealevLabel1.setBounds(7, 245, 63, 28);
}
{
ComboBoxModel tealevComboBox1Model = new DefaultComboBoxModel(
new String[] { "助教","讲师","副教授","教授" });
tealevComboBox1 = new JComboBox();
mainPanel1.add(tealevComboBox1);
tealevComboBox1.setModel(tealevComboBox1Model);
tealevComboBox1.setBounds(77, 245, 112, 28);
}
{
teaLabel1 = new JLabel();
mainPanel1.add(teaLabel1);
teaLabel1.setText("\u4e3b\u653b\u65b9\u5411:");
teaLabel1.setBounds(7, 287, 56, 28);
}
{
aspScrollPane1 = new JScrollPane();
mainPanel1.add(aspScrollPane1);
aspScrollPane1.setBounds(77, 294, 105, 91);
{
teaaspTextArea1 = new JTextArea();
aspScrollPane1.setViewportView(teaaspTextArea1);
teaaspTextArea1.setBounds(184, 331, 118, 91);
teaaspTextArea1.setLineWrap(true);
}
}
{
teaphoLabel1 = new JLabel();
mainPanel1.add(teaphoLabel1);
teaphoLabel1.setText("\u7c98\u8d34\u7167\u7247\u5904");
teaphoLabel1.setBounds(315, 7, 105, 98);
}
{
teaphoButton1 = new JButton();
mainPanel1.add(teaphoButton1);
teaphoButton1.setText("\u6dfb\u52a0\u7167\u7247");
teaphoButton1.setBounds(301, 112, 91, 28);
teaphoButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
teaphoButton1ActionPerformed(evt);
}
});
}
{
teaaddLabel1 = new JLabel();
mainPanel1.add(teaaddLabel1);
teaaddLabel1.setText("\u5bb6\u5ead\u4f4f\u5740:");
teaaddLabel1.setBounds(280, 147, 70, 28);
}
{
addScrollPane1 = new JScrollPane();
mainPanel1.add(addScrollPane1);
addScrollPane1.setBounds(287, 182, 126, 84);
{
addTextArea1 = new JTextArea();
addScrollPane1.setViewportView(addTextArea1);
addTextArea1.setBounds(161, 175, 147, 84);
addTextArea1.setLineWrap(true);
}
}
{
remLabel1 = new JLabel();
mainPanel1.add(remLabel1);
remLabel1.setText("\u5907\u6ce8\uff1a");
remLabel1.setBounds(224, 287, 49, 28);
}
{
remScrollPane1 = new JScrollPane();
mainPanel1.add(remScrollPane1);
remScrollPane1.setBounds(287, 294, 126, 91);
{
remTextArea1 = new JTextArea();
remScrollPane1.setViewportView(remTextArea1);
remTextArea1.setBounds(154, 329, 133, 91);
remTextArea1.setLineWrap(true);
}
}
{
koButton1 = new JButton();
mainPanel1.add(koButton1);
koButton1.setText("\u63d0\u4ea4");
koButton1.setBounds(315, 406, 77, 28);
koButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
koButton1ActionPerformed(evt);
}
});
}
{
datejButton = new DateChooserJButton();
mainPanel1.add(datejButton);
datejButton.setBounds(77, 147, 154, 28);
}
{
tsLabel1 = new JLabel();
mainPanel1.add(tsLabel1);
tsLabel1.setText("*\u6559\u5e08\u7f16\u53f7\u662f\u7531'wh'+4\u4f4d\u6570\u7ec4\u6210(\u5982:wh0001)*");
tsLabel1.setBounds(7, 35, 252, 21);
}
}
pack();
setSize(450, 470);
} catch (Exception e) {
e.printStackTrace();
}
}
private void teaphoButton1ActionPerformed(ActionEvent evt) {
ChooseFile cF=new ChooseFile();
file=cF.chooseFile();
if(file!=null){
ImageIcon icon = new ImageIcon(file.getAbsolutePath());
this.teaphoLabel1.setText("");
this.teaphoLabel1.setIcon(icon);
}
}
private void koButton1ActionPerformed(ActionEvent evt) {
if(idTextField1.getText().equals(""))
{
JOptionPane.showMessageDialog(this, "用户名不能为空");
}
else
{
if(this.idTextField1.getText().getBytes().length>20||this.teanameTextField1.getText().getBytes().length>20||this.teatelTextField1.getText().getBytes().length>20||this.addTextArea1.getText().getBytes().length>100||this.remTextArea1.getText().getBytes().length>100||this.teaaspTextArea1.getText().getBytes().length>50)
{
if(this.idTextField1.getText().getBytes().length>20)
{
JOptionPane.showMessageDialog(this, "教师编号输入的字数长度超过了20个!!");
}
if(this.teanameTextField1.getText().getBytes().length>20)
{
JOptionPane.showMessageDialog(this, "教师姓名输入的字数长度超过了20!!");
}
if(this.teatelTextField1.getText().getBytes().length>20)
{
JOptionPane.showMessageDialog(this, "教师电话输入的字数长度超过了20!!");
}
if(this.teaaspTextArea1.getText().getBytes().length>50)
{
JOptionPane.showMessageDialog(this, "教师的主攻方向输入的字数长度超过了50!!");
}
if(this.addTextArea1.getText().getBytes().length>100)
{
JOptionPane.showMessageDialog(this, "教师地址输入的字数长度超过了100!!");
}
if(this.remTextArea1.getText().getBytes().length>100)
{
JOptionPane.showMessageDialog(this, "备注输入的字数长度超过了100!!");
}
}
else
{
String s=this.idTextField1.getText().trim();
if(s.length()==6)
{
String s1=s.substring(0, 2);
String s2=s.substring(2, 6);
if(s1.equals("wh")&&s2.matches("\\d{4}"))
{
if(ta.compare(s))
{
JOptionPane.showMessageDialog(this,"此教师编号已存在,请重新输入!");
}
else
{
ko();
}
}
else
{
JOptionPane.showMessageDialog(this, "教师编号命名不符合规范,请重新输入!");
}
}
else
{
JOptionPane.showMessageDialog(this, "教师编号命名不符合规范,请重新输入!");
}
}
}
}
public void ko()
{
try{
int i=JOptionPane.showConfirmDialog(this, "是否确定添加","警告!",JOptionPane.OK_OPTION);
if(i==1)
{
return;
}
ta.addteacher(this);
tmf.s0="";
tmf.s1="";
tmf.s2="";
tmf.s3="";
tmf.s4="";
tmf.s5="";
tmf.gettable(tmf.s0,tmf.s1,tmf.s2,tmf.s3,tmf.s4,tmf.s5);
this.setVisible(false);
}catch(Exception e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -