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
  • 166,747
  • 40
  • 210
  • 420
Asqiir
  • 557
  • 1
  • 6
  • 21
  • 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
  • 316,400
  • 19
  • 155
  • 279