I'm trying to create a scrollable menu with item in them
I want to be able to draw a custom background to the scroll and have it be fixed when I scroll among the items
to do the draw of the background I use
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if(background != null){
background.paintIcon(this,g);
}
}
my problem when I try to set the JScrollBar container opacity to false I get a white background
开发者_Python百科as you can I see I want the background to be the same "surface" as the other parts.
any idea what is causing this problem?
Jason
A common problem. You don't actually 'see' the JScrollPane, but the Viewport of the JScrollPane. You need to do all your GUI actions on the JScrollPane.getViewport() (or something like that)
So to make a JScrollPane transparent you would use JScrollPane.getViewport().setOpaque(false)
精彩评论