I have done some pretty decent searching and i cant quite fine what im looking for. basically i want a JTable in a JPanel and for that JPanel to re-size itself per the size of the JTable. i know the usual way of implementing a JTable is to use the JScrollpane but in this circumstance it is unnecessary and it makes my program look ... messy.
the reason i cant find the answer i need is everytime someone asks about a JTable in a JPanel someone gives them the answer of putting it in the scrollpane. im aware of the advantages to using the scrollpane but in this circumstance they aren't advantageous.
yes is possible add JTable to the JPanel, notice with a few row that fills real screen resolution
you have to add TableHeader
separatelly to the container too, otherwise isn't added, nor to be visible, for JTable
into JScrollPane
isn't required add or define TableHeader
separatelly
better could be to remove borders from JScrollPane.setBorders(null)
and with to disable VERTICAL
and HORIZONTAL_SCROLLBAR
to NEVER
for shrinking the wider JScrollPane
to fits to the JTables Dimension
is possible to use table.setPreferredScrollableViewportSize(table.getPreferredSize());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With