I have a JFrame with a few JTables. On one certain JTable, I need the position of the cell in the JFrame that is selected (selection done via code), as soon as it is selected. I would like to draw something here on a Glass Pane. How can I accomplish this?
Point p = gui.rerouteTable.getLocation();
SwingUtilities.convertPointToScreen(p,gui.rerouteTable);
I thought this could get me the upper left hand corner of the table. And via Cell Height and the SelectionListener I could claculate the position i need. But i ca´t even get the uppper left hand corner of the table. Why not? The gui.rerouteTable.getLocation() return (0,0) so obviously the convertPointToScreen is not working correctly.
ListSelectionModel newmodel = mytable.
So you can call table. getSelectionModel(). isSelectionEmpty() to find out if any row is selected.
The TableModel interface specifies the methods the JTable will use to interrogate a tabular data model. The JTable can be set up to display any data model which implements the TableModel interface with a couple of lines of code: TableModel myData = new MyTableModel(); JTable table = new JTable(myData);
Use JTable's method
public Rectangle getCellRect(int row, int column, boolean includeSpacing)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With