java swing 收银系统,Swing做的简单超市收银系统

这篇博客详细介绍了Java开发过程中的关键步骤,包括密码获取、界面管理、窗口最大化、组件添加、表格操作、下拉框填充、日期转换、字符串与整数及浮点数之间的转换。这些基本操作对于构建一个完整的Java应用程序至关重要。
摘要由CSDN通过智能技术生成

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

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));

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值