现在写一些新得和开发过程中遇到的问题
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));