Questions tagged [jtable]

JTable is a Java Swing component used to display and edit regular two-dimensional tables of cells.

JTable is a Java Swing component used to display and edit regular two-dimensional tables of cells.

JTable is used to display and edit regular two-dimensional tables of cells. See The Java Tutorial: How to Use Tables for task-oriented documentation and examples of using JTable.

Reference: Class JTable

8514 questions
27
votes
3 answers

How to add button in a row of JTable in Swing java

I have made one swing GUI which have JTable with some rows and Columns.How should I add a button to row in a JTable ?
om.
  • 4,159
  • 11
  • 37
  • 36
26
votes
4 answers

jTable right-click popup menu

I have a SQL database and I am working on a program that will allow me to add/delete/modify records. I already managed to add records I am working on editing/deleting them. I want to display the existing records in a table so I am using jTable. I…
26
votes
3 answers

Can a Jtable save data whenever a cell loses focus?

The high level: I have a JTable that the user can use to edit data. Whenever the user presses Enter or Tab to finish editing, the data is saved (I'm asusming that "saved" really means "the TableModel's setValueAt() method is called".) If the user…
Electrons_Ahoy
  • 36,743
  • 36
  • 104
  • 127
25
votes
7 answers

Align the values of the cells in JTable?

I'm not aware of how to align the values of cells in JTable. For Ex,The Jtable shows, Name Salary Mr.X 100000.50 XXXX 234.34 YYYy 1205.50 I want to align the "Salaries" in the following format. Name…
Venkat
  • 20,802
  • 26
  • 75
  • 84
25
votes
3 answers

ActionListener on JLabel or JTable cell

I have a JTable with JLabel[][] as data. Now I want to detect a double click on either the JLabel or a table cell (but only in one of the columns). How can I add an Action/MouseListener on JLabel respectively table cell?
stefita
  • 1,785
  • 2
  • 20
  • 35
24
votes
5 answers

Change the background color of a row in a JTable

I have a JTable with 3 columns. I've set the TableCellRenderer for all the 3 columns like this (maybe not very effective?). for (int i = 0; i < 3; i++) { myJTable.getColumnModel().getColumn(i).setCellRenderer(renderer); } The…
user
  • 6,567
  • 18
  • 58
  • 85
23
votes
3 answers

JTable: Detect cell data change

In Netbeans, I used the GUI Builder to insert a JTable into my application. I have just one class (CustomerDB) so far which is: package CustomerDB; import [...]; public class CustomerDB extends javax.swing.JFrame { CellEditorListener…
caw
  • 30,999
  • 61
  • 181
  • 291
22
votes
5 answers

Determine Which JTable Cell is Clicked

When a user clicks a cell on a JTable, how do I figure out the row and column of the clicked cell? How would I show this information in a JLabel?
Cristian
  • 221
  • 1
  • 2
  • 3
22
votes
4 answers

Set Right Alignment in JTable Column

I am creating an application for a billing facility. I want the amount column to display with right alignment. How do I set the right alignment for a JTable column?
Arivu2020
  • 2,485
  • 7
  • 25
  • 24
22
votes
2 answers

remove cells border in a jtable

I have my on custom cell renderer and want to remove the border of the cell. How can i do it? I tried setBorder but it doesn't work. Here is my renderer code: public class MyTableCellRenderer extends DefaultTableCellRenderer { private static…
harshit
  • 7,925
  • 23
  • 70
  • 97
22
votes
2 answers

How to reliably get row index in JTable from MouseEvent?

How can I find out which row in a JTable the user just clicked?
Łukasz Bownik
  • 6,149
  • 12
  • 42
  • 60
21
votes
5 answers

Java JTable getting the data of the selected row

Are there any methods that are used to get the data of the selected row? I just want to simply click a specific row with data on it and click a button that will print the data in the Console.
ZeroCool
  • 437
  • 1
  • 7
  • 23
20
votes
4 answers

Setting the height of a row in a JTable in java

I have been searching for a solution to be able to increase the height of a row in a JTable. I have been using the setRowHeight(int int) method which compiles and runs OK, but no row[s] have been increased. When I use the getRowHeight(int) method of…
Douglas Grealis
  • 599
  • 2
  • 11
  • 25
20
votes
2 answers

JTable Clickable Column Sorting: Sorting sorts content of cells, but doesn't update cell formatting?

I have a sortable JTable set up to use a custom extension of the AbstractTableModel. However, some behavior of this table is what I expected, and I would love some advice on how to figure this out. I have the JTable set up to be sortable…
Panky
  • 563
  • 1
  • 3
  • 18
19
votes
5 answers

Shrink JScroll Pane to same Height as JTable

I currently have JTables nested in JScrollPanes like so: My problem is that the number of rows in each table is variable when the table is created. What I want to do is make the JScrollpane smaller if the table is too short, but I want to keep it…
Alex Bliskovsky
  • 5,973
  • 7
  • 32
  • 41