簡體   English   中英

在JTable1上的鼠標單擊事件上需要更新JTable2以及JEditorPane,所有這些都在同一jframe中

[英]Need to update JTable2 along with the JEditorPane on mouse click event on JTable1, all are in the same jframe

我在JFrame中顯示2個JTables和一個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);  
            }  
        }  
  });  

必須提供更多代碼。 更有意思的是,您將如何精確地進行組件更新。 您是否為更改后的表格模型觸發了表格數據更改,例如tablemodel.fireTableDataChanged()?

希望這會有所幫助,博羅。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM