Home > database >  Jatble length Size
Jatble length Size

Time:07-05

I'm insert the jtable database and getting the print. But in some cases it can fill up to 5 lines and in some cases 100 lines. when there are many lines, print does not appear. My goal is to increase the length of the table based on the number of rows. view without needing JScrollPane

CodePudding user response:

My goal is to increase the length of the table based on the number of rows. view without needing JScrollPane

Easy way is to use the scroll pane:

JTable table = new JTable(model);
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane scrollPane = new JScrollPane( table );

Now the table will be the same size as the scroll pane so no scrollbars will appear and the table header will be displayed. If you add the scroll pane to a panel that respects the preferred size of the scroll pane then you will see all the rows.

Or, another option is to build your own panel using a BorderLayout. Then you do:

panel.add(table.getHeader(), BorderLayout.PAGE_START);
panel.add(table, BorderLayout.CENTER);

CodePudding user response:

enter image description here

Enlarging the size of the table that looks like this so that all of them can be seen

enter image description here

  • Related