# type: (int, int) -> object """Returns the value at the specified row and column.""" if row < self. # type: () -> int """Returns the number of rows in the table model.""" return len( self. # type: () -> int """Returns the number of columns in the table model.""" return len( self. We need to pass the row from the table ( table.getSelectedRow()) to Need to convert using convertRowIndexToView or convertRowIndexToModel. Selection is always in terms of JTable so that when using RowSorter you will Necessarily the same as that of the underlying TableModel. We can read about this behavior in the JTable Documentation:Īll of JTables row based methods are in terms of the RowSorter, which is not The 3rd item (now issue3), the panel will be updated with issue2. AfterĬlicking on it, the panel information does not change to issue2. Index ( #) column, it will be the second item (which was issue1 before). If we sort the table, the view changes and if weĬlick on any row, it will update it to the data that was there before sorting.įor example, in the gif, issue2 is the 3rd item. After clicking each item, it's updated in the rest of the # import mainPanel to modify it from MainPanel import mainPanel # let's see if we can modify the panel print rowData clicked index:", self.getClickedIndex(event) rowData = self. At the end of the file, there is an instance of MainPanel. The panel class has been renamed to MainPanel and resides in MainPanel.py Instead, I choose the simple way of passing a "global" I guess with some trickery we could traverse the hierarchy and get it, but it The table through event.getSource(), we do not have access to the main panel. Updating the panel should be done inside mouseClicked. Probably have noticed that somewhere in between I changed the severity combobox Name, host, and path with the data from the selected row in the table. In this step, we want to update the read-only items in the panel such as the Row data printed after mouseclicks Updating the Panel with The Selected Row The data is printed to console after clicking on each row. jTable1 = IssueTable(tableData, tableHeadings) # setting up the table # initial data in the table tableData = [ Index is the first column so it detects which row is selected and then getClickedIndex returns the index number of the Our custom mouse listener is in the IssueTableMouseListener class. Implementing the MouseListener interface and adding it to We can detect when the table is clicked and act accordingly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |