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

ⅰ亾dé卋堺 提交于 2019-12-10 18:42:37

问题


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:

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.


回答1:


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.




回答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.




回答3:


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));


来源:https://stackoverflow.com/questions/16623429/jprogressbar-capable-of-hiding-the-bar-and-not-the-fluid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!