【Java开源代码栏目提醒】:网学会员鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“tuipiaoFrm.java”一文,供大家参考学习
package train_table;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.util.*;
import java.sql.*;
public class tuipiaoFrm extends JFrame {
Calendar curdate=Calendar.getInstance() ;//日历
int year=curdate.get(Calendar.YEAR ) ;
int month =curdate.get(Calendar.MONTH)+1 ;
int day =curdate.get(Calendar.DAY_OF_MONTH) ;
private JPanel jPanel1 = new JPanel();
private XYLayout xYLayout1 = new XYLayout();
private XYLayout xYLayout2 = new XYLayout();
private TitledBorder titledBorder1;
private JPanel jPanel2 = new JPanel();
private TitledBorder titledBorder2;
private JPanel jPanel3 = new JPanel();
private TitledBorder titledBorder3;
private JLabel jLabel1 = new JLabel();
private JLabel jLabel2 = new JLabel();
private XYLayout xYLayout3 = new XYLayout();
private JLabel jLabel3 = new JLabel();
private XYLayout xYLayout4 = new XYLayout();
private JPanel jPanel4 = new JPanel();
private TitledBorder titledBorder4;
private JPanel jPanel5 = new JPanel();
private TitledBorder titledBorder5;
private JLabel jLabel4 = new JLabel();
private XYLayout xYLayout5 = new XYLayout();
private JTextField times_txt = new JTextField();
String[] time=new String[]{"今天","明天","后天"};
private JComboBox jComboBox1 = new JComboBox(time);
private JLabel jLabel5 = new JLabel();
private JRadioButton jRadioButton1 = new JRadioButton();
private JRadioButton jRadioButton2 = new JRadioButton();
private JTextField zhangshu_txt = new JTextField();
private JLabel jLabel6 = new JLabel();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
private JLabel jLabel7 = new JLabel();
private XYLayout xYLayout6 = new XYLayout();
public tuipiaoFrm() {
try {
jbInit();
pack();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
String date=Integer.toString(year)+"-"+Integer.toString(month)+"-"+Integer.toString(day);
titledBorder4 = new TitledBorder("");
titledBorder5 = new TitledBorder("");
jLabel3.setForeground(new Color(144, 0, 0));
jLabel3.setText(date);
titledBorder1 = new TitledBorder("");
titledBorder2 = new TitledBorder("");
titledBorder3 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(151, 145, 140)),"当前日期");
jPanel1.setLayout(xYLayout1);
this.getContentPane().setLayout(xYLayout2);
jPanel1.setBorder(titledBorder1);
jPanel2.setBorder(titledBorder2);
jPanel2.setLayout(xYLayout3);
jPanel3.setBorder(titledBorder3);
jPanel3.setLayout(xYLayout4);
this.setTitle("退票系统");
jLabel1.setText("1.退票时间必须为三天以内的票");
jLabel2.setText("2.本系统只属模拟不涉及票额的计算");
jPanel4.setBorder(titledBorder4);
jPanel4.setLayout(xYLayout6);
jPanel5.setBorder(titledBorder5);
jPanel5.setLayout(xYLayout5);
jLabel4.setText("车 次");
jLabel5.setText("时 间");
jRadioButton1.setSelected(true);
jRadioButton1.setText("硬座");
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jRadioButton1_actionPerformed(e);
}
});
jRadioButton2.setText("卧铺");
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jRadioButton2_actionPerformed(e);
}
});
zhangshu_txt.setText("1");
zhangshu_txt.setHorizontalAlignment(SwingConstants.RIGHT);
jLabel6.setText("张 数");
jButton1.setText("退票");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jButton2.setText("关闭");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
}
});
xYLayout2.setWidth(400);
xYLayout2.setHeight(283);
jLabel7.setForeground(SystemColor.activeCaption);
jLabel7.setHorizontalAlignment(SwingConstants.CENTER);
jLabel7.setHorizontalTextPosition(SwingConstants.CENTER);
this.getContentPane().add(jPanel1, new XYConstraints(4, 7, 390, 251));
jPanel1.add(jPanel2, new XYConstraints(5, 9, -1, 86));
jPanel2.add(jLabel1, new XYConstraints(6, 14, -1, -1));
jPanel2.add(jLabel2, new XYConstraints(6, 44, -1, -1));
jPanel1.add(jPanel3, new XYConstraints(219, 1, 157, 53));
jPanel3.add(jLabel3, new XYConstraints(39, 0, 81, 20));
jPanel1.add(jPanel4, new XYConstraints(221, 56, 153, 39));
jPanel4.add(jLabel7, new XYConstraints(-1, 0, 143, 27));
jPanel1.add(jPanel5, new XYConstraints(5, 102, 369, 98));
jPanel5.add(times_txt, new XYConstraints(99, 9, 69, -1));
jPanel5.add(jLabel4, new XYConstraints(45, 12, -1, -1));
jPanel5.add(jComboBox1, new XYConstraints(100, 44, 70, -1));
jPanel5.add(jLabel5, new XYConstraints(45, 46, -1, -1));
jPanel5.add(jRadioButton1, new XYConstraints(215, 4, -1, -1));
jPanel5.add(jLabel6, new XYConstraints(214, 45, 32, -1));
jPanel5.add(zhangshu_txt, new XYConstraints(265, 43, 54, -1));
jPanel5.add(jRadioButton2, new XYConstraints(275, 5, -1, -1));
jPanel1.add(jButton1, new XYConstraints(130, 205, -1, -1));
jPanel1.add(jButton2, new XYConstraints(187, 205, -1, -1));
}
void jRadioButton1_actionPerformed(ActionEvent e) {
jRadioButton2.setSelected(false);
zhangshu_txt.setText("1");
}
void jButton1_actionPerformed(ActionEvent e) {
String checi=times_txt.getText();
JianSuanShiJian jssj=new JianSuanShiJian();
errormessage em=new errormessage();
int zhangshu=0;
int i=0; //用于控制计算时间中的今天明天后天
String date1=""; //计算出的时间用字符表示
int yingzuonum=0;
int wopunum=0;
boolean error=false;
if(em.isEmpty(checi)){ //输入为空的处理
error=true;
jLabel7.setText("输入不能为空");
}
else{
zhangshu=Integer.parseInt(zhangshu_txt.getText());
}
if(!em.isNum(zhangshu_txt.getText())){ //输入是否为数字
error=true;
jLabel7.setText("张数必须为数字");
}
if(!error){
if(jComboBox1.getSelectedItem().equals("今天")) //退今天的票的处理
{
jssj.getTime(year,month,day,i); //计算时间
date1=String.valueOf(year)+"-"+String.valueOf(month)+"-"+String.valueOf(day);
}
else if(jComboBox1.getSelectedItem().equals("明天")) //退明天的票的处理
{
jssj.getTime(year,month,day,i+1);
date1=String.valueOf(year)+"-"+String.valueOf(month)+"-"+String.valueOf(day);
}
else{ //后天的退票处理
jssj.getTime(year,month,day,i+2);
date1=String.valueOf(year)+"-"+String.valueOf(month)+"-"+String.valueOf(day);
}
dbBean db=new dbBean();
Re
上一篇:
tsyyBean.java
下一篇:
一个人晕着也能去看病打针