I'd like to customize the look of JPopupMenu
so i made a custom class extending the JPopupMenu class on i overrode the paintComponent
method as i would do for any component i need to customize.
public class CustomPopupMenu extends JPopupMenu {
@Override
public paintComponent(Graphics g) {
//custom draw
}
}
The only problem i have right know is that i'm not able to make the JPopupMenu
transparent. I though setOpaque(false)
would be enough, i was wrong.
How can i make a JPopupMenu
transparent?
The problem with a popup menu is that it may be realized as a top-level container (Window), and a window is opaque, no matter what value you set with setOpaque(), its opaque. But windows can be made translucent, too.
You can hack it by forcing the use of a heavyweight popup and brutally altering its opacity. Try this as a starting base for experiments (Java7):
Note that it will not make submenus translucent!