需要更新 JTable2 以及 JTable1 上鼠标单击事件的 JEditorPane,所有这些都在同一个 jframe 中
我在 JFrame 中显示 2 个 JTable 和一个 JEditorPane。两个表都有不同的数据。双击 table2 时,我想更新 table1 和编辑器窗格。我可以更新编辑器窗格,但不能更新 table1。我尝试为 table1 添加 e.getClickCount() == 2 ,但它不起作用。
基本上,当我单击 Table2 中的一行(即线程号)时,editorPane 和 table1 应该使用线程详细信息进行更新。看起来像
- | 3105 | 3105边界_核心_FCS | 20101216 105754399 | 在 doubleClick 上输入 XATransaction::getInstance
我能够在 editorPane 中显示它,但无法在表中更新它。任何帮助将不胜感激。谢谢。
下面的代码是 table2- 的 addMouseListener
JTable clsNewJTable = new JTable(new RCGUITableModel(arroData, arroHeaders));//... table2
JTable m_clsJTable = RCGUI.m_clsJTable2;// ... table 1
clsNewJTable.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
if (e.getClickCount() == 2){
JTable clsNewJTable1 = (JTable)e.getSource(); // gets table 2
int rowIndex = clsNewJTable1.getSelectedRow();
int colIndex = clsNewJTable1.getSelectedColumn();
clsNewJTable1.getSelectedRows();
Object strCellValue = clsNewJTable1.getValueAt(rowIndex, colIndex);
doUpdateThreadsInTextArea(strCellValue); // this displays in the jeditorPane
//Should i create the new table1 here?and then update it or adding a new mouselistener to table1 is better?
clsNewJTable1.setVisible(true);
}
}
});
I am displaying 2 JTables and a JEditorPane in a JFrame. Both the Tables have different data. On double clicking the table2 i want to update table1 and the editor pane. I am able update the editor pane but not the table1. I tried the add e.getClickCount() == 2 for table1 , but its not working.
Basically when i click a row(which is the thread number) in Tabel2, the editorPane and table1 should update with the thread details. which looks like-
| 3105 | BOUNDARY_CORE_FCS | 20101216 105754399 | Entering XATransaction::getInstance
on doubleClick I am able to display that in the editorPane but not able to update it in the table. Any help would be greatly appreciated. Thanks.
The Code below is addMouseListener for table2-
JTable clsNewJTable = new JTable(new RCGUITableModel(arroData, arroHeaders));//... table2
JTable m_clsJTable = RCGUI.m_clsJTable2;// ... table 1
clsNewJTable.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
if (e.getClickCount() == 2){
JTable clsNewJTable1 = (JTable)e.getSource(); // gets table 2
int rowIndex = clsNewJTable1.getSelectedRow();
int colIndex = clsNewJTable1.getSelectedColumn();
clsNewJTable1.getSelectedRows();
Object strCellValue = clsNewJTable1.getValueAt(rowIndex, colIndex);
doUpdateThreadsInTextArea(strCellValue); // this displays in the jeditorPane
//Should i create the new table1 here?and then update it or adding a new mouselistener to table1 is better?
clsNewJTable1.setVisible(true);
}
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更多代码是必须的。更有趣的是看看你到底是如何更新组件的。您是否为已更改的表模型触发表数据更改,例如 tablemodel.fireTableDataChanged()?
希望这有帮助,博罗。
More code is a must. More interesting would be to see how exactly you are making the update of the components. Do you fire table data change for the changed table'd model, e.g. tablemodel.fireTableDataChanged()?
Hope this helps, Boro.