为什么在JInternalframe关闭然后再次打开时更新JTable数据
public void viewTabelMejaBayar(String mejahe){
//mejahe = textNomeja.getText();
try {
konek = Koneksi.getKoneksi();
state = konek.createStatement();
String query =“select * from tbtrans where stdpr ='1'AND stkasir ='0'AND nomeja ='”+ mejahe +“'”;
ResultSet result = state.executeQuery(query);
while(result.next()){
Kasir p = new Kasir();
p.setNokey(result.getString("nokey"));//1
p.setNovisitor(result.getString("novisitor")); //2
p.setNomeja(result.getInt("nomeja")); //3
p.setNoantri(result.getInt("noantri"));//4
p.setAddedpeg(result.getString("addedpeg"));//5
p.setKdmc(result.getInt("kdmc"));//6
p.setMncafe(result.getString("mncafe"));//7
p.setKatmenu(result.getString("katmenu"));//8
p.setQty(result.getDouble("qty"));//9
p.setHrg(result.getDouble("hrg"));//10
p.setSubtotal(result.getDouble("subtotal"));//11
p.setWorder(result.getString("worder"));//12
p.setStord(result.getInt("stord"));//13
p.setWsaji(result.getString("wsaji"));//14
p.setStdpr(result.getInt("stdpr"));//15
p.setStkasir(result.getInt("stkasir"));//16
p.setPegkasir(result.getString("pegkasir"));//17
tableModelkas.add(p);
//tableModelkas.fireTableDataChanged();
//tableModelkas.fireTableChanged(null);
}
}
catch(Exception e){
e.printStackTrace();
}
//Pramusaji p = new Pramusaji();
}
bt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent t) {
String str = t.getActionCommand();
int action = Integer.parseInt(str);
int count = 0;
count = count +1;
switch (action){
case 1:
//if (e ==0){
viewTabelMejaBayar("1"); //<---Data shown in the table
TotalBayare(); bt.setBackground(Color.GREEN);
textNomeja.setText("1");
textBayar.requestFocus();
}
else{
if((count>0)&&(count<2)){
/* }
* if (count >=2){
* bt.setEnabled(false);
* }
* bt.setBackground(Color.CYAN);
}
*/
repaint();
//ResetviewTabelMejaBayar();
break;