如何在Swing中为JDialog进行重绘? [英] How to make repaint for JDialog in Swing?
本文介绍了如何在Swing中为JDialog进行重绘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Swing中为JDialog进行重绘? 如果我在JDialog中单击转换按钮,则需要更改JDialog的GUI设计,但是没有发生吗?他们有什么解决办法吗?
How to make repaint for JDialog in Swing? If I click on convert button in JDialog I need to change GUI design of JDialog but it's not happening? Is their any solution?
_convertAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
String para = new String();
_task.setBookTypeId(13);
initComponents();
// validate();
// repaint();
setVisible(true);
}
};
我将预订类型ID设置为13.
I'm setting booking type id is 13 .
if(_task.getBookTypeId()== 1){
String colnames[] = {"Leg","Departure", "Date","Time", "Arrival","Date", "Time","How","Aircraft","PIC","Copilot"};
MyTableModel mytablemodel = new MyTableModel(colnames);
legdetailsTable = new JTable(mytablemodel);
legdetailsTable.setRowSelectionAllowed(true);
}else {
System.out.println("Brokered booking table");
String colnames[] = {"Leg","Departure", "Date","Time", "Arrival","Date", "Time","How"};
MyTableModel mytablemodel = new MyTableModel(colnames);
legdetailsTable = new JTable(mytablemodel);
legdetailsTable.setRowSelectionAllowed(true);
}
使用ID,我正在initcomponents方法中更改组件.
Using Id I'm changing componenents in initcomponents method.
推荐答案
您可以获取当前组件或任何组件的窗口,然后调用repaint()
.
You can get the Window of the current Component or any Component and than call repaint()
.
SwingUtilities.getWindowAncestor( this ).repaint();
这篇关于如何在Swing中为JDialog进行重绘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文