Just put the two JProgressBar
s to a JPanel say centerPanel
with BridLayout(0, 1, 5, 5)
.
And put the 2 JButton
s START and STOP
to another JPanel say buttonPanel
with Layout i.e. FlowLayout(FlowLayout.LEFT, 5, 5)
(This will align the JButton
START with the left side of the JProgressBar
s, though if you want the JButton
s to come somewhere in the middle of the same, then simply don't use setLayout(FlowLayout.LEFT, 5, 5)
. The default Layout for the JPanel
will do).
Now add centerPanel
to the JFrame
using
frameReference.add(centerPanel, BorderLayout.CENTER)
and add buttonPanel
using
frameReference.add(buttonPanel, BorderLayout.PAGE_END)
That will do :-)
EDIT 1 :
use a Border
for this thingy. Like
centerPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK))
That will create a Box
around the centerPanel
. Please have a look at this answer, though I am using TitledBorder
in this example.