can anyone give me example codes on how to create transparent JProgress Bar or customize JProgress Bar
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
can anyone give me example codes on how to create transparent JProgress Bar or customize JProgress Bar
Here is a way to make a transparent popup menu. You can modify this code to work with other Swing components such as the JProgress bar.
The transparency level is set here:import javax.swing.*; import java.awt.*; class TransparentPopupMenu extends JPopupMenu { public TransparentPopupMenu() { super(); setOpaque(false); } } class TransparentMenuItem extends JMenuItem{ public TransparentMenuItem(String text) { super(text); setOpaque(false); } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); super.paint(g2); g2.dispose(); } }
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, [B]0.5f[/B]));
0.0f means 100% transparent (you will not see it)
0.5f means 50% transparent
1.0f means 0% transparent (Not transparent at all)
Also look here:
Hacking Swing: Translucent Windows | O'Reilly Media
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.