我在 JFrame 中显示 2 个 JTable 和一个 JEditorPane。两个表都有不同的数据。双击 table2 我想更新 table1 和编辑器窗格。我可以更新编辑器窗格,但不能更新 table1。我尝试为 table1 添加 e.getClickCount() == 2 ,但它不起作用。
基本上,当我在 Tabel2 中单击一行(这是线程号)时,editorPane 和 table1 应该使用线程详细信息进行更新。看起来像-
| 3105 | BOUNDARY_CORE_FCS | 20101216 105754399 | 输入 XATransaction::getInstance
在 doubleClick 上,我可以在 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);
}
}
});