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
19
votes
5 answers

How can I change the font of a JTable's header?

I want to set the JTable header's font. Do you know how?
Stefanos Kargas
  • 10,547
  • 22
  • 76
  • 101
19
votes
2 answers

How to sort JTable in shortest way?

I was searching for Sorting in JTable and I referred many articles, but couldn't get the easiest way to sort the table. I also know that TableRowSorter could be somehow helpful but don't know how. Being new to JTable, I am creating a new question…
Pratik
  • 367
  • 2
  • 4
  • 11
19
votes
7 answers

How to fill data in a JTable with database?

I want to display a JTable that display the data from a DataBase table as it is. Up till now, I have used JTable that displays data from Object [ ][ ]. I know one way to display the data is to first convert the database table into Object [ ][ ] but…
Amit
  • 33,847
  • 91
  • 226
  • 299
19
votes
6 answers

Removing all the rows of DefaultTableModel

I want to delete all the rows of DefaultTable. I found two common ways to delete them on internet, but none of them works in my case because those methods does not exist in my DefaultTableModel. I wonder why. My code for using DefaultTableModel…
Xara
  • 8,748
  • 16
  • 52
  • 82
18
votes
7 answers

How to clear contents of a jTable ?

I have a jTable and it's got a table model defined like this: javax.swing.table.TableModel dataModel = new javax.swing.table.DefaultTableModel(data, columns); tblCompounds.setModel(dataModel); Does anyone know how I can clear its contents ?…
tom
  • 4,911
  • 11
  • 37
  • 39
18
votes
1 answer

TableModel vs ColumnModel: who owns the column value?

What's the difference between JTable.getModel().getColumnName() and JTable.getColumnModel().getColumn(index).getHeaderValue()? The two don't seem to share any data. My guess is that TableModel.getColumnName() indicates the textual representation of…
Gili
  • 86,244
  • 97
  • 390
  • 689
18
votes
1 answer

JTable in JScrollPane, how to set background?

I am using a JScrollPane to wrap a JTable. Depending on the configuration, there is some space that is not occupied by the table. It is drawn gray (it looks like it is transparent and you can just see the component in the back). How can I set this…
brimborium
  • 9,362
  • 9
  • 48
  • 76
18
votes
6 answers

How to remove a row from JTable?

I want to remove some rows from a JTable. How can I do it?
somya agrawal
17
votes
6 answers

Java JTable - Make only one column editable

I was wondering how to make one column of a JTable editable, the other columns have to be non editable. I have overwritten isCellEditable() but this changes every cell to non editable. Thnx in advance.
Th3Ndr1X
  • 340
  • 1
  • 4
  • 8
17
votes
18 answers

How do you remove selected rows from a JTable?

I've tried this: public void removeSelectedFromTable(JTable from) { int[] rows = from.getSelectedRows(); TableModel tm= from.getModel(); while(rows.length>0) { …
Penchant
  • 1,165
  • 7
  • 19
  • 28
17
votes
3 answers

How to make a JButton in a JTable cell click-able?

I have a JTable with a custom cell renderer. The cell is a JPanel that contains a JTextField and a JButton. The JTextField contains an integer, and when the user clicks on the JButton the integer should be increased. The problem is that the JButton…
Jonas
  • 121,568
  • 97
  • 310
  • 388
17
votes
4 answers

How to Insert Image into JTable Cell

Can someone point me in the right direction on how to add an image into Java Table cell.
dwayne
  • 1,587
  • 3
  • 11
  • 5
17
votes
4 answers

How to add row dynamically in JTable

I want to add the row dynamically in JTable and I have writen the following code for that: tblTaskList = new JTable(); tblTaskList.setShowVerticalLines(false); tblTaskList.setCellSelectionEnabled(true); …
Uday A. Navapara
  • 1,237
  • 5
  • 20
  • 40
17
votes
6 answers

How to change JTable header height?

Title explains the question. How can I easily do that?
Anubis
  • 6,995
  • 14
  • 56
  • 87
16
votes
1 answer

How to add checkboxes to JTABLE swing

Does anyone know how to put a JCheckBox in a JTable column? Something like this: I took this from How To use Tables Thanks in advance.
java2world
  • 219
  • 1
  • 2
  • 4