I don't know how to properly explain this, so here's a picture:
You can see quite a bit of the background around the green line, especially at the start and below the line. How can I fix this?
I don't know how to properly explain this, so here's a picture:
You can see quite a bit of the background around the green line, especially at the start and below the line. How can I fix this?
Your probably need to setBorderPainted to false. Refer http://docs.oracle.com/javase/8/docs/api/javax/swing/JProgressBar.html#setBorderPainted-boolean-
The spaces / border visible on your screenshot is just the spacing of the parent panel, it is not the border of the JProgressBar
.
For example you will see no borders around the progress bar in this example:
final JFrame f = new JFrame("Test");
final JProgressBar pb = new JProgressBar();
pb.setValue(50);
f.getContentPane().add(pb);
f.pack();
f.setVisible(true);
But if you use a JPanel
as content pane with FlowLayout
which has default 5 pixel horizontal and veritcal gap, you will see something like in your screenshot.
f.setContentPane(new JPanel(new FlowLayout()));
The spaces disappear if you use 0 spacing between components like this:
f.setContentPane(new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)));