如何在 Swing 中对 JDialog 进行重绘?
如何在 Swing 中对 JDialog 进行重绘? 如果我单击 JDialog 中的转换按钮,我需要更改 JDialog 的 GUI 设计,但它没有发生?他们有什么解决办法吗?
_convertAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
String para = new String();
_task.setBookTypeId(13);
initComponents();
// validate();
// repaint();
setVisible(true);
}
};
我设置的预订类型 id 是 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 方法中更改组件。
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);
}
};
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);
}
Using Id I'm changing componenents in initcomponents method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您重新创建 JTable,而不是
添加
,但新的 JTable 未添加到布局中
Instead of
add
You recreate JTable but the new one isn't added to layout
您可以获取当前组件或任何组件的窗口,然后调用
repaint()
。You can get the Window of the current Component or any Component and than call
repaint()
.