flatronka
flatronka

Reputation: 1081

Java table in table with auto resize

I want to make a table which can contain small tables and supports resize.

enter image description here

My solution use a JScrollpane which contains the table and the gridbaglayout contains the row which is a JPanel and this row JPanel contains JLabels and ETable (flowlayout).

How I can solve the resize problem? When I resize the window the column align automatically with the window.

enter image description here

The columns are not aligned correctly in the big table.

Upvotes: 1

Views: 1456

Answers (2)

jay gohel
jay gohel

Reputation: 39

You can use this

Jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

using this JTable will display horizontal as well as vertical scroll bar when required.

Upvotes: 0

mKorbel
mKorbel

Reputation: 109815

  1. I see there J(X)TreeTable or Outline with Custom Look and Feel (Renderer talking about Nimbus L&F, because isn't there correctly used background for Boolean value)

  2. put JComponents (from top) top the JPanel and there use GridBagLayout

  3. put JScrollPane with J(X)TreeTable or Outline put to the Center area

  4. please which type of TreeTable is there used ??? (for calculating PreferredSize of Columns)

EDIT

In this case replace the table with a black box. It's not relevant.

JFrame has implemented BorderLayout in the API, then

  • all JComponents from the TOP of the JFrame put to the separate JPanel, there you can use GridBagLayout, this JPanel put to the NORTH area e.g. JFrame.add(JPanel, BorderLayout.NORHT)

  • put black box to the CENTER area e.g. JFrame.add(black box, BorderLayout.CENTER)

Upvotes: 1

Related Questions