user2388169
user2388169

Reputation: 237

JProgressBar Capable of hiding the 'bar' and not the 'fluid'

I understand that 'fluid' isn't the best description, but that's how I imagine the green that lays inside a progress bar.

I was just wondering if it was possible to just see the green 'fluid' from the progress bar, and not the container that hold the 'fluid'.

The purpose of this is to make artwork under the progress bar that would hold the green 'fluid', rather then the system's default UI holding this fluid.

EDIT:

This is a photo of the current progress bar in question:

image

The JFrame this is on is INVISIBLE, so all you can see is this bar. I would like to know if it is possible to remove the GREY from around the JProgressBar and just display the green.

Upvotes: 3

Views: 865

Answers (3)

nigelg
nigelg

Reputation: 161

I know this is an old question, but found it using google and I'm trying to do exactly the same thing. I found setting the background to transparent works perfectly, at least with the Nimbus L&F, haven't tested this with others.

progress.setBackground (new Color (0, 0, 0, 0));

Upvotes: 0

trashgod
trashgod

Reputation: 205885

By fluid, you may mean the paint used by a BasicProgressBarUI in its implementation of paintDeterminate(). The UI delegate fills all of boxRect with ProgressBar.background and some fraction of boxRect with ProgressBar.foreground. You can

  • Change the color via the UIManager, as discussed here, but the delegate is not obligated to use your setting.

  • Implementnt your own ProgressBarUI, as suggested here.

Upvotes: 3

LtWorf
LtWorf

Reputation: 7608

http://docs.oracle.com/javase/6/docs/api/javax/swing/JProgressBar.html#paintBorder

you should use setBorderPainted to remove the border, I guess that's what you want.

Upvotes: 2

Related Questions