Skip to content
Advertisement

Tag: jtable

Disable Column Header sorting on a JTable

Is it possible to disable manual sorting on a JTable after adding a sorter? So I have a JTable that has the following sorter attached to it (basically sorts by column 3 when the table is initialised): This works fine, however the user is still able to click on the column headers in the table and sort by any of

Set row height depend on JTextArea height

I have a problem and really don’t know how to solve it. I used some solutions from this forum but they don’t work. This is the piece of code: This is little bit long but rather simple: my table uses custom cell renderer which contains JTextArea. I use JTA because I need Strings wrapping. After put such JTextAreas I expect

JUnit Tests for GUI in Java

I would like to write test cases for a GUI. I want to know how do you simulate a click of JButton, or how do you extract the elements of a JTable. For the purpose of this, I have built a simple GUI that increase the count by 1 if the button is clicked and the JTextfield is empty, but

Remove row being edited from JTable

I have a JTable and a button next to it that calls deleteSelectedRows(), which does exactly what it sounds like: But if a cell was in the act of being edited when it (and/or cells above it) were deleted, the edited cell stayed while the rest left, like this: And then trying to exit out of the editing threw an

JTable -> TableModeListener

I have this JTable having a DefaultTableModel as its model. On the table I have several swing component, JComboBox and JCheckBox, set on a particular column via DefaultCellEditor and DefaultCellRenderer. The TableModelListener was added to the table to capture changes on editable columns. The rest of the columns will display details of the selected component, i.e. item code -> item

Invert the Selection in JTable

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 it? Answer JTable doesn’t seems to have a built-in way of doing this. So I implemented it with the following code. (Hope this is helpful for someone who

Adding Buttons inside cell of JTable along with data?

Is it possible to add buttons inside the JTable cell along with data? What I am trying to do is to create a table with columns which display data(number) from the database, and two buttons to increase/decrease the number inside the same cell. |ID | Quantity| |06| 2 [+][-] | it would be something like above with [+][-] being buttons.

Advertisement