📄 dutyaddframe.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.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import com.hb.studentmanager.action.DutyAction;
import com.hb.studentmanager.date.DutyDAO;
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 DutyAddFrame extends javax.swing.JDialog {
public JLabel stuidjLabel;
public JLabel datejLabel;
public JButton submjButton;
public JTextArea baezjTextArea;
public JScrollPane beizjScrollPane;
public JComboBox weekjComboBox;
private JLabel jLabel4;
private JLabel jLabel5;
public JLabel jLabel3;
public JComboBox dayjComboBox;
public JLabel jLabel2;
public JButton jButton;
public JComboBox stuidjComboBox;
public JComboBox chuqjComboBox;
public JComboBox yearjComboBox;
public JLabel jLabel1;
public JLabel chuqjLabel;
public JLabel beizhujLabel;
DutyMainFrame df=new DutyMainFrame();
DutyAction da=new DutyAction();//得到DutyAction的对象 /**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
}
public DutyAddFrame(DutyMainFrame dmf) {
super();
initGUI(dmf);
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width-450)/2, (height-470)/2);
this.setResizable(false);
this.setTitle("\u6dfb\u52a0\u5b66\u751f\u51fa\u52e4");
}
private void initGUI(final DutyMainFrame dmf) {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(null);
{
stuidjLabel = new JLabel();
getContentPane().add(stuidjLabel);
stuidjLabel.setText("\u5b66\u53f7\uff1a");
stuidjLabel.setBounds(84, 28, 63, 28);
}
{
datejLabel = new JLabel();
getContentPane().add(datejLabel);
datejLabel.setText("\u51fa\u52e4\u65f6\u95f4\uff1a");
datejLabel.setBounds(84, 182, 70, 28);
}
{
chuqjLabel = new JLabel();
getContentPane().add(chuqjLabel);
chuqjLabel.setText("\u51fa\u52e4\u60c5\u51b5\uff1a");
chuqjLabel.setBounds(84, 112, 70, 28);
}
{
beizhujLabel = new JLabel();
getContentPane().add(beizhujLabel);
beizhujLabel.setText("\u5907\u6ce8\uff1a");
beizhujLabel.setBounds(91, 322, 63, 28);
}
{
ComboBoxModel chuqjComboBoxModel = new DefaultComboBoxModel(
new String[] { null, "正常", "迟到","早退","旷课"});
chuqjComboBox = new JComboBox();
getContentPane().add(chuqjComboBox);
chuqjComboBox.setModel(chuqjComboBoxModel);
chuqjComboBox.setBounds(182, 112, 119, 28);
}
{
beizjScrollPane = new JScrollPane();
getContentPane().add(beizjScrollPane);
beizjScrollPane.setBounds(182, 329, 119, 91);
{
baezjTextArea = new JTextArea();
beizjScrollPane.setViewportView(baezjTextArea);
baezjTextArea.setBounds(105, 392, 63, 28);
baezjTextArea.setLineWrap(true);
}
}
{
submjButton = new JButton();
getContentPane().add(submjButton);
submjButton.setText("\u63d0\u4ea4");
submjButton.setBounds(336, 385, 77, 28);
submjButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
submjButtonActionPerformed(evt,dmf);
}
});
dmf.gettable(dmf.s1,dmf.s2,dmf.s3,dmf.s4,dmf.s5);
}
{
DefaultComboBoxModel stuidjComboBoxModel = new DefaultComboBoxModel();
da.getStudentId(stuidjComboBoxModel);//得到学号 stuidjComboBox = new JComboBox();
getContentPane().add(stuidjComboBox);
stuidjComboBox.setModel(stuidjComboBoxModel);
stuidjComboBox.setBounds(182, 28, 119, 28);
stuidjComboBox.insertItemAt("", 0);
}
{
ComboBoxModel yearjComboBoxModel = new DefaultComboBoxModel(
new String[] { "", "第一学期", "第二学期" , "第三学期" , "第四学期"
, "第五学期" , "第六学期" , "第七学期" , "第八学期" });
yearjComboBox = new JComboBox();
getContentPane().add(yearjComboBox);
yearjComboBox.setModel(yearjComboBoxModel);
yearjComboBox.setBounds(210, 182, 91, 28);
}
{
jLabel1 = new JLabel();
getContentPane().add(jLabel1);
jLabel1.setText("\u5b66\u671f");
jLabel1.setBounds(182, 182, 28, 28);
}
{
ComboBoxModel weekjComboBoxModel = new DefaultComboBoxModel(
new String[] { "","第一周","第二周","第三周","第四周","第五周"
,"第六周","第七周","第八周","第九周","第十周"
,"第十一周","第十二周","第十三周","第十四周","第十五周","第十六周"
,"第十七周","第十八周"});
weekjComboBox = new JComboBox();
getContentPane().add(weekjComboBox);
weekjComboBox.setModel(weekjComboBoxModel);
weekjComboBox.setBounds(210, 217, 91, 28);
}
{
jLabel2 = new JLabel();
getContentPane().add(jLabel2);
jLabel2.setText("\u5468");
jLabel2.setBounds(182, 217, 21, 28);
}
{
ComboBoxModel dayjComboBoxModel = new DefaultComboBoxModel(
new String[] { "","星期一", "星期二","星期三","星期四","星期五" });
dayjComboBox = new JComboBox();
getContentPane().add(dayjComboBox);
dayjComboBox.setModel(dayjComboBoxModel);
dayjComboBox.setBounds(210, 252, 91, 28);
}
{
jLabel3 = new JLabel();
getContentPane().add(jLabel3);
jLabel3.setText("\u661f\u671f");
jLabel3.setBounds(182, 252, 28, 28);
}
{
jLabel4 = new JLabel();
getContentPane().add(jLabel4);
jLabel4.setText("(*\u5b66\u53f7\u5fc5\u987b\u9009\u62e9)");
jLabel4.setBounds(182, 56, 119, 28);
}
{
jLabel5 = new JLabel();
getContentPane().add(jLabel5);
jLabel5.setText("(*\u65f6\u95f4\u5fc5\u987b\u9009\u62e9)");
jLabel5.setBounds(182, 280, 119, 28);
}
pack();
setSize(450, 470);
} catch (Exception e) {
e.printStackTrace();
}
}
private void submjButtonActionPerformed(ActionEvent evt,DutyMainFrame dmf) {
DutyAction da=new DutyAction();
String s1=yearjComboBox.getSelectedItem().toString();
String s2=weekjComboBox.getSelectedItem().toString();
String s3=dayjComboBox.getSelectedItem().toString();
if(stuidjComboBox.getSelectedItem()==null||s2.equals("")||s3.equals("")){
JOptionPane.showMessageDialog(this,"学号和时间必须添加");
}
else{
if(baezjTextArea.getText().getBytes().length>100){
JOptionPane.showMessageDialog(this, "输入字数太长");
}
else{
try {
JOptionPane.showConfirmDialog(this, "是否确定添加","警告!",JOptionPane.OK_OPTION);
boolean b;
b=da.AddDuty(this);
if(b==true){
this.setVisible(false);
dmf.s1="";dmf.s2="";dmf.s3="";dmf.s4="";dmf.s5="";
dmf.gettable(dmf.s1,dmf.s2,dmf.s3,dmf.s4,dmf.s5);
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -