3

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.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
user2388169
  • 237
  • 1
  • 3
  • 9

3 Answers3

3

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.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thank you for your detailed input. And thank you for bringing proper names to my attention as well. I am purely self taught w/ communities so every bit of knowledge like this helps. I do know that Java will not use my settings in Windows 8, as mentioned. So I will look into making my own ProgressBarUI with the link you gave me. Thank you for your knowledge. – user2388169 May 19 '13 at 07:19
2

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.

LtWorf
  • 7,286
  • 6
  • 31
  • 45
  • It didn't do anything actually. this image shows the current Progressbar on my app, everything you see here is JUST the JProgressBar, the JFrame is invisible. What Im looking for is the GREY to be invisible, but I still want to be able to see the Green in the progress bar http://prntscr.com/15g2vm – user2388169 May 18 '13 at 11:03
  • Hm I understand, and I guess you aren't using normal java on a desktop too? Check this out http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#setOpaque(boolean) – LtWorf May 18 '13 at 11:08
  • I am using Java on Windows 8. So that might be why the progress bar looks weird. Im not a fan of the new Windows 8 progress bars, haha Hangout here for a second while I try out some of these methods you pointed me to. – user2388169 May 18 '13 at 11:10
  • method JComponent.isOpaque() is not applicable (actual and formal argument lists differ in length) I get this error when I try to complie. – user2388169 May 18 '13 at 11:15
  • setOpaque worked, but had no effect on the ProgressBar itself. – user2388169 May 18 '13 at 11:15
  • as the documentation say, your theme can ignore these values, you need to write a new theme, but that is not going to be easy I guess. – LtWorf May 18 '13 at 11:23
  • 1
    Well, I could always write something that resemble a Progress bar. Thank you for your help! – user2388169 May 18 '13 at 11:26
  • As suggested [here](http://stackoverflow.com/a/16625494/230513), you'll have to change the `ProgressBarUI`. – trashgod May 18 '13 at 14:43
0

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));
nigelg
  • 151
  • 3
  • 12