Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Transparent JMenuBar/JMenu?

843807Jan 8 2010 — edited Jan 9 2010
Hello all,

I am using a JMenuBar with a lot of menus and what bugs me is the bar. I would rather it be slightly transparent. So far I have tried to extend JMenuBar and override the paintComponent and paint methods.
        protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.2f));
            super.setOpaque(false);
            super.paintComponent(g2);            
        }

        public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.2f));
            super.setOpaque(false);
            super.paint(g2);
        }
So far all i've managed to do is make the menu titles transparent I still can't figure out how to actually make the JMenuBar transparent. I have tried setting opaque(false) that doesn't seem to work either. Any help would be great thanks. :)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2010
Added on Jan 8 2010
1 comment
1,237 views