0

My container JPanel has a boxlayout. In the first row, another JPanel, two elements should be placed: a JLabel in the left and a JButton in the right.

How to place them there?

I can't use BorderLayout (so west and east) for the inner JPanel, because it would make the first row blow up taking the whole height which is really ugly.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Asqiir
  • 607
  • 1
  • 8
  • 23
  • Possible duplicate of [Creating two buttons at bottom left/right corner](https://stackoverflow.com/questions/46690476/creating-two-buttons-at-bottom-left-right-corner) – Frakcool Mar 23 '18 at 21:56

1 Answers1

0

In the first row, another JPanel, two elements should be placed: a JLabel in the left and a JButton in the right.

You can use a horizontal BoxLayout for that and add "glue" between the two components.

Read the section from the Swing tutorial on Using Invisible Components as Filler for more information.

camickr
  • 321,443
  • 19
  • 166
  • 288