1
I have a JTable
in my form, I wanted the size(number of rows and columns) of the table to be according to the number the user enters, how to do in java?
1
I have a JTable
in my form, I wanted the size(number of rows and columns) of the table to be according to the number the user enters, how to do in java?
2
It is possible to create an empty table, as one of the constructors of JTable
allows passing the number of rows and columns, and the table is internally created using the DefaultTableModel
.
int numLinhas = 5;
int numColunas = 3;
JTable table = new JTable(numLinhas, numColunas);
The above example displays something like this:
Just remember to pass the JTable
for a JScrollPane
, otherwise the table header will not be displayed and possibly not the Scrolls when needed.
Browser other questions tagged java swing jtable
You are not signed in. Login or sign up in order to post.
What you’ve tried to do?
– user28595
Still nothing, I found no hint!
– Guilherme Bueno
Ai complicates, the answer would be too broad, it would be good for you to post some attempt, or what you have done so far, to have a basis of response.
– user28595
Only the command to set the number of rows and columns of a jtable would already serve
– Guilherme Bueno
The answer below helped you? You can accept it by clicking on
v
next to the post :)– user28595