I have a problem concerning layouts in Swing. I have got a BorderLayout
and want to add a JProgressBar
with multiple JLabels
below in the NORTH
section of this layout all aligned horizontal next to each other.
It should look something like this:
I already tried various layouts like for example GroupLayout
but I couldn't get it to work.
Consider using a second JPanel
with a GridLayout
...
setLayout(new BorderLayout());
add(new JProgressBar(), BorderLayout.NORTH);
JPanel panel = new GridLayout(1, 6);
panel.add(new JLabel("Step 1"));
panel.add(new JLabel("Step 2"));
panel.add(new JLabel("Step 3"));
panel.add(new JLabel("Step 4"));
panel.add(new JLabel("Step 5"));
panel.add(new JLabel("Step 6"));
add(panel, BorderLayout.CENTER);
As an example.
See How to Use GridLayout for more details