Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JTable without a header

Tags:

Can anyone tell me how to create a table without a table header?

I am making Sudoku puzzle and I want to create a table without the table header in Java. Is it possible?

like image 454
saurabh Avatar asked Mar 27 '10 08:03

saurabh


People also ask

How do I make a table without headers?

Click anywhere in the table. Go to the Table tab on the Ribbon. In the Table Style Options group, select the Header Row check box to hide or display the table headers.

How is JTable created?

JTable(): A table is created with empty cells. JTable(int rows, int cols): Creates a table of size rows * cols. JTable(Object[][] data, Object []Column): A table is created with the specified name where []Column defines the column names.


2 Answers

I don't think that you want your Sudoku to scroll, so the easiest way should be not to put your table into a JScrollPane, which is responsible for displaying the header:

alt text


The other way is to call

table.setTableHeader(null); 
like image 60
Peter Lang Avatar answered Sep 27 '22 17:09

Peter Lang


Anyone having problems with the suggested methods, try the following:

jTable.getTableHeader().setUI(null); 

This is tested with Java 8.

like image 21
BudwiseЯ Avatar answered Sep 27 '22 18:09

BudwiseЯ