我有这个可爱的问题与我的编程(我是这里的菜鸟)我想给我的编程一些动画,我希望拆分面板中的分隔符从gbPanel.getHeight()(MAX高度)移动到Border.getHeight()(最小高度)使用表格行16像素,如果我做一个System.out.println变量程序似乎工作奇迹但是!表格分隔线和EVERYthing等待,直到时间结束,在窗口中显示它自己...我的第一个尝试解决它或至少检查是否原因是添加Thread.sleep但只是让程序等待一个在结束之前很多并且窗口被更新。然后我尝试强制窗口在内部更新,但这也没有工作。有人介意帮助我吗?
/* this display one row of data and makes the splitpanel divider -16 with each row */
public void DespliegaTD() {
DefaultTableModel jModel = new DefaultTableModel();
jTable1.setModel(jModel);
jModel.setColumnIdentifiers(new Object[]{"Num","Tarjeta","Cuenta","Fecha Trx","Monto","Descripción","Tipo POS","Cod Resp", "Moneda","Autorización","MCC","Resultado"});
try {
ResultSet rs = Query(tDebito.getText(),cuenta.getText(),fechaInicio.getText(),fechaFinal.getText());
while (rs.next()){
if ((dbPane.getHeight()-(rs.getRow()*jTable1.getRowHeight())) >= (Border.getHeight()-1))
dbPane.setDividerLocation((dbPane.getHeight()-(rs.getRow()*jTable1.getRowHeight())));
jModel.addRow(new Object[] {rs.getRow(),rs.getString(1),rs.getString(2),dateFormat4.format(dateFormat3.parse(rs.getString(3))),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getString(9),rs.getString(10),rs.getString(11)});
}
} catch (SQLException ex) {
Logger.getLogger(BVtarjetas.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParseException ex) {
Logger.getLogger(BVtarjetas.class.getName()).log(Level.SEVERE, null, ex);
}
}
答案 0 :(得分:3)
您的问题是尝试在Swing事件线程(又称事件调度线程或EDT)上的长时间运行过程中执行动画。解决方案是使用后台线程,例如通过SwingWorker。