Select 1 « JTable « Java Swing Q&A





1. Preserve JTable selection across TableModel change    stackoverflow.com

We're seeing JTable selection get cleared when we do a fireTableDataChanged() or fireTableRowsUpdated() from the TableModel. Is this expected, or are we doing something wrong? I didn't see any property on ...

2. Getting real row indices of selected rows in JTable when columns are alphabetized    stackoverflow.com

If the columns of my JTable are unalphabetized, I can use getSelectedRows() and get values of their rows without any trouble. But, if the user clicks on the column name and ...

3. JTable no update when selection    stackoverflow.com

When I select a row in a JTable, my JTable doesn't get updated anymore. When I don't select a row, the code beneath works as expected. A row is added to the ...

4. How do you remove selected rows from a JTable?    stackoverflow.com

I've tried this:

public void removeSelectedFromTable(JTable from)
{
 int[] rows = from.getSelectedRows();
 TableModel tm= from.getModel();

 while(rows.length>0)
 {
  ((DefaultTableModel)tm).removeRow(from.convertRowIndexToModel(rows[0]));

  rows = from.getSelectedRows();
 }
 from.clearSelection();
}
But, it sometimes leaves one still there. What can ...

5. JTable or some other Java table class with advanced cell selection?    stackoverflow.com

Right now I'm using a JTable for what I'm doing. After looking through the Java API and various web resources, I don't think a JTable is going to cut it anymore. ...

6. getting selected row through AbstractTableModel    stackoverflow.com

Is it possible to get the selected row index from my table model? My object already knows about the table model. Instead of passing a reference to the table it self can ...

7. How to programatically deselect the currently selected row in a JTable (swing)?    stackoverflow.com

I want to programatically deselect the currently selected row (or rows) in a JTable. Basically I want the oposite of this:

JTable table = ...;
table.setRowSelectionInterval(x,x);
I tried (with little hope) using:
table.setRowSelectionInterval(-1,-1)
or
table.setRowSelectionInterval(1,0)
but it doesn't work. Any ...

8. JTable not returning selected row correctly    stackoverflow.com

I am working with an extension of the DefaultTableModel as follows: This is the NEW AchievementTableModel after updating it to reflect input from some answers.

public AchievementTableModel(Object[][] c, Object[] co) {
 super(c,co);
}
public ...





10. jTable grid lines for selected rows    stackoverflow.com

I have a jTable set so that it is read only, and selection is done by single row only. However, when the user selects a row and the row is painted, the ...

11. Strange blinking of cell on selection with custom Cell Editor    stackoverflow.com

I am new to working with JTables and having trouble with getting my custom JTable editor to work properly. I have a number of custom panels with lists and buttons. To ...

12. Select next cell JTable    stackoverflow.com

I would like to make a JTable that users when selecting an uneditable cell the it changes the focus to the next editable cell automatically. Important: the user could select a ...

13. In Groovy SwingBuilder, how do I attatch a closure to a JTable that fires when a cell is selected?    stackoverflow.com

I have a JTable being constructed via Groovy's SwingBuilder. I'd like to attach a closure to the table that fires when a cell is selected, but I can't seem to ...

14. Preventing the selection of next cell in JTable while using AutoComplete    stackoverflow.com

I am using GlazedList's autoComplete support in a JTable using the below code

itemColumn.setCellEditor(AutoCompleteSupport.createTableCellEditor(itemList));
How do I prevent the selection or editing the next cell, if the user hasn't selected any value in ...

15. How to get correct selection in a JTreeTable?    stackoverflow.com

I am working with a JTreeTable as described in an old article at: Sun Developer Network Here are the same files but slightly adjusted for java 6: http://edtaylor80.angelfire.com If you ...

16. Invert the Selection in JTable    stackoverflow.com

On clicking a button, I want the selected rows to be inverted (non-selected rows should be selected and selected rows should be non-selected). Is there a build-in method in JTable to do ...





17. Selecting multiple rows of JTable    stackoverflow.com

I'm currently using JTable to show the contents in database. I want to provide the facility for user so that he can select the number of rows he wants using shift+arrow ...

18. Selection mode in JTable?    stackoverflow.com

I couldn't understand the Difference between multiple_selection_interval and single_interval_selection in JTable.. table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); next, is table.setSelectionMode(ListSelectionModel.MULTIPLE_SELECTION_INTERVAL); what's the difference these?

19. how select all cell while selected JTable value?    stackoverflow.com

First i gave all values of row in JTAble. While inserting table values into database, I selected all values of row in JTable, using the following model.getValueAt(rowIndex,colIndex); But this method gets all the ...

20. I have to select the checkbox two times to check/uncheck in jTable    stackoverflow.com

I have a jTable code i intend to use, but the problem with it is that when i click on the checkbox once it doesn't select/deselect it, instead i have to ...

21. Java: Selected rows's index does not changes when I sort them!    stackoverflow.com

I have a Jtable on which I called the method table1.setAutoCreateRowSorter(true);. So this works on well. But I also have a methos in my JFrame class which is fired when i push ...

22. Is there any scrollbar component in java swing ,there by which we can select first and last rows in a JTable?    stackoverflow.com

Is there any scrollbar component in java swing ,there by which we can select first and last rows in a JTable?

23. Creating a table with an initial element selected    stackoverflow.com

I want to create a table which displays in each row a set of data, in addition to a radio button for possible selection. This can be achieved easily by using ...

24. JTable .. colour of selected row    stackoverflow.com

I have a JTable in Java that has a custom dataMOdel and custom renderer. Now when i select some cell it has a dark blue border around it. I want the ...

25. Intercept jTable selection change events    stackoverflow.com

I found this forum thread which suggests overriding ListSelectionModel to prevent rows from being selected. I would like to prevent selection changes when there are unsaved changes (external to the ...

26. How to change values of panel on selecting a row in a table : jgoodies    stackoverflow.com

I am using Jgoodies binding to bind the table with my data. What listener i should implement so that when a cell is selected the values in a panel are changed. ...

27. After JTable cell setDefaultRenderer to jTextArea how to highlight the selected row in jTextArea    stackoverflow.com

This is my renderer

class tblCalendarRenderer extends JTextArea implements TableCellRenderer {

    JTextArea textField;

    public tblCalendarRenderer() {
        textField = ...

28. JTable: how to select columns at runtime    stackoverflow.com

I have too many columns in a table to display them all at once, and would like to let the user change which columns are visible. How can I do this? note: ...

29. How to make the jList selectable inside a jTable    stackoverflow.com

How to make the jList selectable and jScrollPane scrollable inside a jTable. This is my table code :

private JTable getCalendarTable() {
    if (calendarTable == null) {
    ...

30. Java Swing JTable; Right Click Menu (How do I get it to "select" aka highlight the row)    stackoverflow.com

Short: I need a "right-click event" to highlight the cell row. I am using a JTable inside a ScrollPane in Java Swing (Netbeans Matisse). I have a MouseClicked event ...

31. Item always selected in JTable    stackoverflow.com

I have created a JTable where the included items are provided with radio buttons in order to enable users to select any of these once at a time. In order to ...

32. printing selection of JTable    stackoverflow.com

I want to print only selected rows in a JTable. My approach is to make a new TableModel, copy the selected rows there, add the tableModel to a new JTable and then ...

33. How to change a table content based on the selection of a row from another table    stackoverflow.com

I have created a JDialog which displays two different tables. When the user selects a row from the first table, the content of the second table should update accordingly and display ...

34. problem when implementing a selection listener in a JTable    stackoverflow.com

I am developing a JTable with different rows. I would like to associate an event to the selection of a row in this table. I have used the following selection class ...

35. JTable cell loses focus after run an action on selected cells if use keyboard shortcut and temporaily disable the JTable    stackoverflow.com

In my JTable I have a number of actions that can accessed via popup menu or by selecting the configured shortcut. Selecting the action from the popup using mouse or keyboard ...

36. Java PreparedStatement ResultSet TableModel MySQL Select Error    stackoverflow.com

I'm trying to adapt a ResultSetTableModel I got from a deitel book, in it was an implementation of a ResultSetTableModel using regular java.sql.Statement. I'm trying to modify the code so ...

37. Row selection function disabled after using a cell renderer    stackoverflow.com

I'm cleary doing something wrong. My guess would be the component, but here's the problem. This is my cell renderer:

public class WildcardCellRenderer implements TableCellRenderer {

    @Override
    ...

38. JTable - color selection of a line    stackoverflow.com

Bonjour, J'ai un jtable, où je dispose dans la première colonne d'un JPanel. Le problème c'est que lorsque je sélectionne une ligne, toutes les cellules de la ligne changent la couleur de background ...

39. JTable : No selected row    stackoverflow.com

I want to disable a button whenever there aren't any rows selected in a jTable. Is there any possible way to do this?

40. Multiple row selection in JTable    stackoverflow.com


I have a JTable, that has one column that is text which is not editable and the second column is a check box that displays boolean values.... Now what i want ...

41. Action listener JList and create Jtable based on Jlist selection    stackoverflow.com

I have Jlist that have list of tables . I want the user to select table from the JList and this should change the values in the JTable that being ...

42. using a JLabel+icon with JTable cellrenderer + selection highlight    stackoverflow.com

I have a JTable with one column that has a custom cell renderer that shows one of several icons. It works well except the selection highlight does not automatically appear, and I ...

43. Java Table: how to make it "selection impervious"    stackoverflow.com

I have a table in a Java program which is read only: and I don't need any user-selection of cells. But, when I click on the table, an entire ...

44. how to get the focused cell in JTable during multiple selection    stackoverflow.com

I have a JTABLE with 10 rows. If I do multiple selection on the JTABLE, how do A I get the cell that is currently focused? I have tried to used JTable's ...

45. How can I check which JTable cell has been clicked/selected?    stackoverflow.com

When my user clicks a cell of my JTable, I want to know the row and column of the selected cell and show the info in a JLabel. How can I ...

46. Can't navigate a JTable by the arrow keys after using setRowSelectionInterval(int, int)    stackoverflow.com

I'm extending JTable and I have a populateData() method that I'm using to load data into the table model. In this method I'm using:

setRowSelectionInterval(tableRow, tableRow);
And it is working as I want ...

47. JXTable + GlazedLists + update during drag selection = problem    stackoverflow.com

I'm having a table row selection problem with JXTable. If I run the following program, I get two frames that are viewing the same EventList<Item>. One has a JTable and one ...

48. JTable row selection    stackoverflow.com

I need to select a row when I click on the row on the JTable. The default behavior is when the mouse is pressed, the row gets selected. How can I ...

49. How can I determine which cell in a JTable was selected?    stackoverflow.com

I have a JTable in a GUI and I want to return a number based on the value of the cell that a user clicks on. This is the code:

ListSelectionModel newmodel ...

50. TableCellRenderer selected cell problem    stackoverflow.com

I want to implement a tablecellrenderer of a JTable component, which should show a different color depending on the cell data. I got this, but I can't change the color of ...

51. JTable row selection without changing the data    stackoverflow.com

Hi Im doing a project for college and have a JTable in my GUI. I want the user to be able to select rows without being able to change the data ...

52. How to enable using arrows keys to move row selection in JTable?    stackoverflow.com

I noticed that I can you arrows to move row selection of my JTable object only when I press tab key. Is it possible to use arrows after row selection by ...

53. Detecting Selection Changes in a JTable    stackoverflow.com

I'm trying to find a way to detect changes in which column the user selected in a JTable. I did some poking around and it appears that you need to ...

54. jtable multiple cell selection    stackoverflow.com

Is it possible to select multiple non adjacent cells in java using jtable ? if not, is there an alternative to this ? thanks !

55. Why does my Java custom cell renderer not show highlighting when the row/cell is selected?    stackoverflow.com

I have a custom cell renderer for a cell to do a word wrap so more content can be read. Here is the code:

import java.awt.Color;
import java.awt.Component;
import java.awt.Insets;

import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.table.TableCellRenderer;

public class ...

56. JEditorPane rectangle (column) selection mode    stackoverflow.com

I would like to know how can I extend JEditorPane (or any other swing text editing component) to handle rectangle (column) selection mode. It is a well known feature in current ...

57. JTable Selection with the help of a combobox?    stackoverflow.com

I have a combobox with values of 1 to 5 and a JTable of 5X5... Whenever a select a value from combobox corresponding entire column of the JTable has to get ...

58. How to make JTable click on unselected do a drag instead of a select    stackoverflow.com

If you have JTable set with table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) and then you click drag on a row that is not already selected, it starts selecting multiple rows. We don't want that behavior. We ...

59. Change value in column on select JComboBox    stackoverflow.com

I have table with two columns and lot of rows, each column contain JComboBox. I wrap JComboBox into DefaultCellEditor and added to model. How to implement that when I choose in ...

60. get the selected row    stackoverflow.com

Hello i want to select a row and after i click the button i want to display this line!

public class TableDemo extends JPanel {

    static List<String[]> rosterList = ...

61. How to auto select the last inserted row in JTable?    stackoverflow.com

Since JTable could be sorted. How do I set it auto select the last inserted row whenever a row is inserted? Thanks

63. Where is setSelectedRow() for JTable?    stackoverflow.com

Java Swing JTable has a getSelectedRow() method, but does not have a setSelectedRow() method. I need to highlight/select a row in a JTable. How should I proceed?

64. Retrieving JTable line content after user sorted content by clicking on column    stackoverflow.com

I have a pane with two tables A and B. When a row is selected in A, the content of B should be upated. My code detects row selections in A ...

65. java: how to select only one cell in a jtable and not the whole row    stackoverflow.com

in a jTable, I want when a user clicks on a cell, this sentence to be printed on the screen :

I am cell in row X and column Y
where x and ...

66. how to enable/disable selection of rows on a JTable?    stackoverflow.com

Which method can I call to enable/disable the possibility of select rows in a JTable?

67. Swing JTable - Highlight selected cell in a different color from rest of the selected row?    stackoverflow.com

I have a basic swing JTable and the requirement is that when clicked on any cell, the entire row should be highlighted, and also that the cell which was clicked should ...

68. JTable Row selection background problem.    stackoverflow.com

I have a JTable and to set a picture as background in JTable and other properties i used this code.

tblMainView= new JTable(dtModel){
        public Component ...

69. how to get values of other cell if checkbox is selected of the correcponding checkbox in jtable    stackoverflow.com

how to get values of other cell if checkbox is selected of the correcponding JCheckBox in JTable. I add JCheckbox in JTable

JCheckBox checkBox = new javax.swing.JCheckBox();
jTable1 = new javax.swing.JTable();

jTable1.setModel(new javax.swing.table.DefaultTableModel(
  ...

70. Render TableCell with JComboBox and selection background    stackoverflow.com

I have a requirement to render selected/focused cells in JTable with a JComboBox if the column in question uses combo as editor. The intent of this is to give hint to ...

71. Display a row of Strings on a JComponent so that the single Strings are selectable/their location getLocation()-able?    stackoverflow.com

In order to be able to display a sentence on a, say, JPanel with a GridLayout(1,0) [i.e., only one line/row] and then be able to draw a syntax tree (or similar) ...

72. JTable row selection after TableModel update    stackoverflow.com

How to preserve table row selecetion after table mode update (fireTableDataChanes)? I know that I should save selection before fire and restore it after (from there). But when I try ...

73. Java: update details table which bound to the List property of master collection selected item    stackoverflow.com

I try to implement UI with Netbeans GUI builder using property bindings. Source for master table is collection of elements List<Pride>, and details table source is selectedPride.cats collection. (The code below is ...

74. JTable data is invisible unless cell is selected    stackoverflow.com

I'm creating a JTable with data contained in 2 Vector, rowData and columnNames. I'm using a renderer to give the colour I want to the JTable. But data is invisible unless ...

75. How to keep previously selected cells selected when mouse click other cell in jtable    stackoverflow.com

The default behavior of jtable selection is, when you click on a cell, all previously selected cells change to unselected. How to keep previously selected cells selected when mouse click other ...

76. How to make a JTable row to an "unselected" state after selected any row in that table?    stackoverflow.com

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 ...

77. Individual and not continuous JTable's cell selection    stackoverflow.com

Is there any clean way to allow a user to select multiple non continuos cells of a JTable? Or I'm forced to implement my own ListSelectionModel? I played around with setCellSelectionEnabled() and setSelectionModel() ...

78. JTable Row Selection - No event fired and no blue color shown    stackoverflow.com

I have a JTable which only allows row selection using a ListSelectionListener as shown in the below code snippet. There are two problems in the JTable: Q1) Although I set the ...

79. Multi-cell selection in a Swing JTable    stackoverflow.com

I want to provide multi-cell editing functionality to a JTable: double click will still edit the value in the selected cell (the standard behavior), while right-click should open up a popup ...

80. before cell select jtable event    stackoverflow.com

Are there any event that is fired when cell is about to be selected? There is ListSelectionListener, but it has event that is fired only after selection has happened. I need ...

81. How to change the background for whole column and whole row of a selected cell    stackoverflow.com

i have a jtable and i want when selecting a cell to change the background for the whole row and the whole column of this cell (not to change the background ...

82. Automatically selecting every other row in a JTable    stackoverflow.com

I'm trying to create a table where every other row is selected (for looks, mainly). I'm also wondering if there's a way to change the selection color to black, instead of the ...

83. How to change the look & feel of UITableViewCell when "selected" the cell?    stackoverflow.com

I got a customized UITableViewCell in UITableView using subclass (e.g. "LayoutATableCell"). What I want to achieve is that when the table cell is clicked, it changes to another layout, with different ...

84. Check whether the jcheckbox is selected in a table cells in Java SE    stackoverflow.com

I want to the check the selected check boxes in a table cell after pressing a button and the that selected rows. (The table date will be filled by a DB ...

85. JTreeTable selection listener indexes    stackoverflow.com

I'm using a JTreeTable taken from the java sun example.. I have the following structure:

+1
+4
+7
which represents the 3 node collapsed..
-1
--2
---3
-4
--5
---6
-7
--8
---9
And this is the structure expanded. I've added a ListSelectionListener to my ListSelectionModel. Suppose ...

86. How to disable specific column selection in JTable?    bytes.com

You can't select individual cells; you can either select rows and/or columns. When both are selected the intersection of the rows and columns makes up the selection and you can't have ...

87. How can i make a jTable based on jComboBox selection    forums.netbeans.org

Hello everybody, i use netbeans ide 6.7.1 and i have a problem in reloading my jTable while the jComboBox selected item changes. I have already made an entity class of the ...

88. Related to JTable( Switching between Row Selection)    coderanch.com

I have JTable with 5 columns, the first column is noneditable others are editable. If I am in the first column, I want RowsSelection to be ON for deletion,addition of rows at selected row, Otherwise if i am in other Columns it should work as cell selection true(both row and column selection to be Off) I tried ListSelectionListener method but don't ...

90. jtable selecting only one column    coderanch.com

hi! i have a table with 2 columns... at the moment both columns are editable. lets describe my problem: i only want to edit the second column. the first column should be static... i tried the method: -> setEditingColumn( 2 ); but nothing special happened? can anybody outthere help me? greetings Steffen

91. Disabling JTable Cell selections    coderanch.com

I came across the same problem and struggled with it for a couple of days, but finally got it figured out. You need to implement isCellEditable(row,col) in your data model to return the appropriate boolean flag for the cells. Then add a key listener to the table and implement the keyReleased method to check for VK_TAB key code, if it is ...

92. JTable selections    coderanch.com

I'd like to have single selections in my table and to have it highlight both the row and the column for the selected cell, so it looks like a plus sign ( + ). I've tried lots of things but all I can do is get the cell, the row, or the column separately. Does anyone know how I can do ...

93. copy selected data from JTable's cell to clipboard    coderanch.com

This is an old post, but I've been dealing with the same thing and thought I'd show what I've done thusfar. This solution works most of the time, but gets a little flaky when a custom renderer is used. Does anyone know a foolproof way to harness data from a particular cell, as formatted by the appropriate renderer? Some of my ...

94. JTable selection problem    coderanch.com

I have a problem regarding the selection of table rows. Let's say there is a table displaying 10 rows. For instance the 2nd and 3rd row are selected. When I then change the sorting order of the displayed elements (e.g. after the user clicks on a table header) the selected rows stay the same, that means the 2nd and 3rd row ...

95. JTable selection problem    coderanch.com

I have a problem regarding the selection of table rows. Let's say a table is displaying 10 rows. The table also has a sorting algorithm that gets triggered when the user clicks on a table's column header. For instance the 2nd and 3rd row are selected. When then the sorting order gets changed (by clicking on a table's column header) the ...

96. JTable selection problem    coderanch.com

Because I have posted this message again without any response I post it again... I have a problem regarding the selection of table rows. Let's say a table is displaying 10 rows. The table also has a sorting algorithm that gets triggered when the user clicks on a table's column header. For instance the 2nd and 3rd row are selected. Then ...

97. Selective ui cell selection swing jtable    coderanch.com

Hi all, I am having a table of 4 columns. While tabbing through, i want the columns 3,4 are to be selected and not the 1,2. How to do that? Right now, i put the code in isCellEditable() method but 1,2 column gets focus then transfer happens. Any solution for avoiding the 1,2 column tab movement. thanx in advance.

99. MultipleCell Selection in JTable    coderanch.com