I need to know if it is possible to retrieve the row number of a JTable to click on a button located on the inside of the table. I need get the numer of row from a specific cell
When you click on a cell in a table the row will become selected.
To determine the selected row you can use:
int row = table.getSelectedRow();
Related
I have a jtable and one of cell in each row contains combobox. When i select a value from combobox then that whole row gets updated with somme values.
Now i need to fill data in sequentially manner only.
E.g
1) If user selects a combobox in first row then that row gets updated
2) Now if user selects a comobox other than second row then it should give some alert and stop editing the value
How can I get row by row data sequentially on "label" by clicking button again and again until all row's data access? This problem is come when I want access row from a database table by click on next button to see first row and again click to see second row and so on.
What i want to do is to get all the tableItems from the selected row. but i have find out that the tableItems are stored in indexes (like in arrary) and not like give row and column and store it on specific cell of table (row, column).
So i have to go through all the next rows upto the end of table and then go through all the rows upto the selected row to get to my required tableItem.
See image for clearance of my question. The coloured row is the selected one. If i want to go from 'a' to 'b' and then 'c' and so on for complete row, i have go through all the next rows.
so now the problem is how can i get the total number of rows present in swt.table
A SWT TableItem IS a row in your Table. You can use it's getText(int index) method to get the contents of the column with index (starting from 0 for the first column) of the selected TableItem.
Therefor the number of TableItems is the total number of rows.
I'm developing a Java Swing application which contains a JTable. By default, while launching the application for the first time, the call to the method jtable.getSelectedRow() or jtable.getSelectedColumn() returns -1, which means that no row selected at that moment. After user clicked any row or column, the call to the method jtable.getSelectedRow() or jtable.getSelectedColumn() returns the appropriate values of selected rows & columns. What I actually need is that I want to set the selected row or column to -1 i.e. "no row or column selected state". How can I do this?
The JTable method clearSelection will do what you want -- clear the selection of all the table's selected rows and columns. The JTable API is the place to look for methods such as these.
I am trying to add a JComboBox to the last column of my JTable. The JComboBox isn't for editing purposes but for traversing the JTable itself. Each row can have 0-many elements that need to go in the JComboBox and when a value is selected from the box I need to scroll to a different row in the JTable.
All the research I have done points me specifically to editors and renderers with the down fall being that data in the JComboBox is set per column so that a user can select a value for the cell in the row. Where as I need values that are specific to the row.
So my question is, has anyone tried to do this before? and Can you point me to some good information on how to do this? or even better could you describe how you did this?
1/ simple example here, your job is only to move (hold) TableCellEditor to the last row in the TableView,
2/ if JComboBox's Item changed then search in TableModel for TableRow (if every TableColumns ends with JComboBox)
3/ then call myTable.changeSelection(row, column, false, false);
4/ possible fauls implemented and used RowSorter, RowFilter, then you have to get int row from TableView and convert that to the TableModel by using
int modelRow = convertRowIndexToModel(row);