Swing做的简单超市收银系统

前几天学了小锋老师Swing视频,为了巩固知识,动手做了个简单的超市收银系统,开发中遇到很多问题,通过不断调试最后终于昨晚。

现在写一些新得和开发过程中遇到的问题

1.登录密码获取问题

String password = new String(txtPwd.getPassword());

2.登录成功界面消失

  

this.dispose();

 

  打开新窗体

   

new MainFra().setVisible(true);

 

3.设置窗体最大化

  

this.setExtendedState(JFrame.MAXIMIZED_BOTH);

 

4.点击菜单添加面板

 

GoodsInterFra goodsInterFra = new GoodsInterFra();

goodsInterFra.setVisible(true);

this.jDesktopPane1.add(goodsInterFra);

5.table的鼠标pressed时间

 

int row = tabBookType.getSelectedRow();
this.txtId.setText((String) tabBookType.getValueAt(row, 0));
this.txtBookT.setText((String) tabBookType.getValueAt(row, 1));
this.txtBookTypeDesc.setText((String) tabBookType.getValueAt(row, 2));

6.下拉框

 

Connection conn = null;
GoodsType goodsType = null;
try {
    conn = dbutil.getCon();
    ResultSet rs = goodsTypeDao.goodsTypeList(conn, new GoodsType());
    while(rs.next()){
        goodsType = new GoodsType();
        goodsType.setId(rs.getInt("id"));
        goodsType.setGoodsType(rs.getString("goodsType"));
        this.jcbGoodsType.addItem(goodsType);
    }

解决下拉框中内容不显示问题,重写toString方法

public String toString() {
    return this.getGoodsType();
}

7.java.util.Date转java.sql.Date

 

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.sql.Date productTimeDate = null,baozhiDate = null;
try {
    java.util.Date date = sdf.parse(productDate);
    java.util.Date date2 =sdf.parse(baozhiqi);
    productTimeDate = new java.sql.Date(date.getTime());
    baozhiDate = new java.sql.Date(date2.getTime());
} catch (ParseException e) {
e.printStackTrace();
}

8.String转换int

String goodCount = this.txtCountNum.getText();
int count = Integer.parseInt(goodCount.trim());

9.float转换String

float tatalPrice = count*price;
this.txtTotalPrice.setText(String.valueOf(tatalPrice));

通过这次练习我对数据库操作这一块又有更深层次的理解,遇到问题debug更熟练了。

恩,就这么多,我要再接再厉!

 

  

 

 

  

 

posted on 2013-05-27 20:00  New_曙光  阅读(737)  评论(1)    收藏  举报