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
245
votes
11 answers

How to add JTable in JPanel with null layout?

I want to add JTable into JPanel whose layout is null. JPanel contains other components. I have to add JTable at proper position.
Sagar
  • 2,475
  • 2
  • 15
  • 3
113
votes
5 answers

How to add row in JTable?

Do you know how I can add a new row to a jTable?
oneat
  • 10,778
  • 16
  • 52
  • 70
111
votes
7 answers

How to make a JTable non-editable

How to make a JTable non-editable? I don't want my users to be able to edit the values in cells by double-clicking them.
Siddharth Raina
  • 1,255
  • 2
  • 8
  • 6
108
votes
9 answers

Java JTable setting Column Width

I have a JTable in which I set the column size as…
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
95
votes
6 answers

JTable How to refresh table model after insert delete or update the data.

This is my jTable private JTable getJTable() { String[] colName = { "Name", "Email", "Contact No. 1", "Contact No. 2", "Group", "" }; if (jTable == null) { jTable = new JTable() { public boolean…
user236501
  • 8,538
  • 24
  • 85
  • 119
85
votes
4 answers

JTable won't show column headers

I have the following code to instantiate a JTable: the table comes up with the right number of rows and columns, but there is no sign of the titles atop the columns. public Panel1() { int nmbrRows; setLayout(null); …
John R Doner
  • 2,242
  • 8
  • 30
  • 36
76
votes
2 answers

JTable, disable user column dragging

I have declared my JTable as: data_table = new JTable(info, header) { @Override public boolean isCellEditable(int row, int column) { return false; } }; But I've seen that at runtime it's possible to drag the columns with…
giozh
  • 9,868
  • 30
  • 102
  • 183
57
votes
3 answers

Programmatically select a row in JTable

When the application is started, none of the rows is selected. But I would like to show that the first row is already selected. How to do this? Do I need to set the color of a row in JTable? Update: I tried table.setRowSelectionInterval(0,0). I…
Klausos Klausos
  • 15,308
  • 51
  • 135
  • 217
52
votes
5 answers

JTable Scrolling to a Specified Row Index

I have a JTable that is within a JScrollPane. Rows are added to the table at runtime based on events that happen in my application. I want to have the scoll pane scroll to the bottom of the table when a new row is added to the table. For JLists…
Chris Dail
  • 25,715
  • 9
  • 65
  • 74
49
votes
8 answers

How to make a columns in JTable Invisible for Swing Java

I have designed one GUI in which I have used one JTable from which I have to make 2 columns invisible . How should I do that ?
om.
  • 4,159
  • 11
  • 37
  • 36
45
votes
5 answers

JTable with horizontal scrollbar

Is there any way to enable horizontal scroll-bar whenever necessary? The situation was as such: I've a JTable, one of the cells, stored a long length of data. Hence, I need to have horizontal scroll-bar. Anyone has idea on this?
Mr CooL
  • 1,529
  • 8
  • 23
  • 27
40
votes
6 answers

How to get rid of the border with a JTable / JScrollPane

If you run the small sample below you'll see a border around the center region. I'm not sure why this border is showing. It happens when a JTable is in a JScrollPane. I tried various things to remove it but so far no luck. A JTable without the…
sproketboy
  • 8,967
  • 18
  • 65
  • 95
39
votes
3 answers

Double click listener on JTable in Java

I am curious as to how to call valueChanged overridden method only if a row in JTable has been double clicked. For now the below code snippet achieves one click action or event arrow key to navigate through a list of people and would adjust JLabel…
MooHa
  • 819
  • 3
  • 11
  • 23
39
votes
10 answers

How to populate JTable from ResultSet?

I call getnPrintAllData() method after pressing OK button: public class DatabaseSQLiteConnection { Connection conn = null; PreparedStatement statement = null; ResultSet res = null; public DatabaseSQLiteConnection(){ …
A. K. M. Tariqul Islam
  • 2,824
  • 6
  • 31
  • 48
36
votes
8 answers

Disable user edit in JTable

When a JTable component is created, cell editing is enabled by default. How can I prevent the user from editing the content of a JTable?
Parag
  • 7,746
  • 9
  • 24
  • 29
1
2 3
99 100