📄 claaddframe.java
字号:
package com.hb.studentmanager.ui;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import com.hb.studentmanager.action.ClaAction;
import com.hb.studentmanager.action.TeaAction;
/**
* 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 ClaAddFrame extends javax.swing.JDialog {
public JPanel mainPanel1;
private JLabel ts1Label1;
private JLabel ts2Label1;
public JButton koButton1;
public JComboBox speidComboBox1;
public JLabel speLabel1;
public JComboBox teaidComboBox1;
public JLabel teaidLabel1;
public JTextField claidTextField1;
public JLabel claidLabel1;
ClaMainFrame cmf = new ClaMainFrame();
ClaAction ca = new ClaAction();
/**
* Auto-generated main method to display this JFrame
*/
/*
* public static void main(String[] args) { //ClaAddFrame inst = new
* ClaAddFrame(); //inst.setVisible(true); }
*/
public ClaAddFrame(ClaMainFrame cmf) {
super();
this.cmf = cmf;
initGUI();
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width - 400) / 2, (height - 300) / 2);
this.setResizable(false);
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(null);
this.setTitle("\u6dfb\u52a0\u73ed\u7ea7\u4fe1\u606f");
pack();
{
mainPanel1 = new JPanel();
getContentPane().add(mainPanel1);
mainPanel1.setBounds(0, 0, 392, 273);
mainPanel1.setLayout(null);
{
claidLabel1 = new JLabel();
mainPanel1.add(claidLabel1);
claidLabel1.setText("\u73ed\u7ea7\u53f7:");
claidLabel1.setBounds(21, 84, 56, 28);
}
{
claidTextField1 = new JTextField();
mainPanel1.add(claidTextField1);
claidTextField1.setBounds(98, 91, 224, 28);
}
{
teaidLabel1 = new JLabel();
mainPanel1.add(teaidLabel1);
teaidLabel1.setText("\u73ed\u4e3b\u4efb\u7f16\u53f7:");
teaidLabel1.setBounds(21, 168, 70, 28);
}
{
DefaultComboBoxModel teaidComboBox1Model = new DefaultComboBoxModel();
ClaAction ta = new ClaAction();
ta.getTeaid(teaidComboBox1Model);
teaidComboBox1 = new JComboBox();
mainPanel1.add(teaidComboBox1);
teaidComboBox1.setModel(teaidComboBox1Model);
teaidComboBox1.setBounds(98, 168, 224, 28);
teaidComboBox1.insertItemAt(null, 0);
}
{
speLabel1 = new JLabel();
mainPanel1.add(speLabel1);
speLabel1.setText("\u4e13\u4e1a\u540d\u79f0\uff1a");
speLabel1.setBounds(21, 14, 70, 28);
}
{
DefaultComboBoxModel speidComboBox1Model = new DefaultComboBoxModel();
ClaAction ca = new ClaAction();
ca.getspename(speidComboBox1Model);
speidComboBox1 = new JComboBox();
mainPanel1.add(speidComboBox1);
speidComboBox1.setModel(speidComboBox1Model);
speidComboBox1.setBounds(98, 14, 224, 28);
speidComboBox1.insertItemAt(null, 0);
}
{
koButton1 = new JButton();
mainPanel1.add(koButton1);
koButton1.setText("\u63d0\u4ea4");
koButton1.setBounds(273, 217, 77, 28);
koButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
koButton1ActionPerformed(evt);
}
});
}
{
ts1Label1 = new JLabel();
mainPanel1.add(ts1Label1);
ts1Label1
.setText("*\u8bf7\u5148\u9009\u62e9\u60a8\u8981\u521b\u5efa\u73ed\u7ea7\u7684\u4e13\u4e1a*");
ts1Label1.setBounds(100, 49, 210, 28);
}
{
ts2Label1 = new JLabel();
mainPanel1.add(ts2Label1);
ts2Label1
.setText("*\u73ed\u7ea7\u53f7\u662f\u7531\u4e13\u4e1a\u540d\u79f0\u52a0\u4e09\u4f4d\u6570\u7ec4\u6210(\u5982:\u7f51\u7edc051)*");
ts2Label1.setBounds(98, 126, 280, 28);
}
}
setSize(400, 300);
} catch (Exception e) {
e.printStackTrace();
}
}
private void koButton1ActionPerformed(ActionEvent evt) {
if (this.claidTextField1.getText().equals("")||this.speidComboBox1.getSelectedItem()==null) {
JOptionPane.showMessageDialog(this, "班级号及专业名称不能为空!!");
} else {
String s = this.claidTextField1.getText().trim();
if(s.length()>3)
{
String s1 = s.substring(0, s.length() - 3);
String s2 = s.substring(s.length() - 3, s.length());
if (s2.matches("\\d{3}")) {
if (s1.equals(this.speidComboBox1.getSelectedItem().toString())) {
if(ca.compare1(s))
{
JOptionPane.showMessageDialog(this, "此班级号已存在,请重新输入!");
}
else
{
ko();
}
}
else
{
JOptionPane.showMessageDialog(this, "用户名不符合规范!");
}
} else {
JOptionPane.showMessageDialog(this, "用户名不符合规范!");
}
}
else
{
JOptionPane.showMessageDialog(this, "用户名不符合规范!");
}
}
}
public void ko() {
try {
int i = JOptionPane.showConfirmDialog(this, "是否确定添加", "警告!",
JOptionPane.OK_OPTION);
if (i == 1) {
return;
}
ca.addclass(this);
this.setVisible(false);
cmf.s1="";
cmf.s2="";
cmf.s3="";
cmf.s4="";
cmf.gettable(cmf.s1,cmf.s2,cmf.s3,cmf.s4);
} catch (Exception e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -