0

I'm using swing and want to implement such construction as this:

|- - - -|
| table |
| with  |
| images|
|       |
|- - - -|
| text  |
|-------|

I implement table with images using GridLayout and it looks okay for me.

JPanel mainPanel = new JPanel(); //which layout should I use?
InterfaceBuilder builder = new InterfaceBuilder();
panel.add(builder.getTable()); //this function returns JPanel with grid layout. It is okay
panel.add(builder.getLabel());

Which JComponent and mainPanel's layout should I use to implement text field with custom height and size?

Sergei Podlipaev
  • 1,331
  • 1
  • 14
  • 34

1 Answers1

1

Use a BorderLayout.

Add the panel with images to the BorderLayout.CENTER.

Add the text to the BorderLayout.PAGE_END.

Read the section from the Swing tutorial on Layout Managers for information and working examples on all the layout managers.

Learn how each layout manager works and remember you can nest panels with different layout managers to get your desired layout.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • Thanks! I used http://stackoverflow.com/questions/22920046/how-to-set-fix-size-of-jlabel answer to make jlabel with fixed size and it worked as I wished! – Sergei Podlipaev Nov 09 '16 at 20:03
  • @SergeiPodlipaev, there is no need to use a fixed size and that is the wrong solution. All Swing components are designed to determine there own size and you should not try to do that manually. – camickr Nov 09 '16 at 20:22