Ozgun Ozgun - 7 months ago 23
Java Question

add JProgressBar and JLabel vertically in JToolbar

analysisProgressBar = new JProgressBar();
analysisProgressLabel = new JLabel("Analysing...");

add(analysisProgressBar, BorderLayout.NORTH);
add(analysisProgressLabel, BorderLayout.CENTER);


How can I add
JProgressBar
and
JLabel
vertically in
JToolBar
?
I want it to look like this:

[==== ]

Analysing...


How it looks now:

enter image description here

Answer

It's easy

JPanel p = new JPanel(new BorderLayout());
p.add(analysisProgressBar, BorderLayout.NORTH);
p.add(analysisProgressLabel, BorderLayout.CENTER);
toolbar.add(p);