Search code examples
javaswinggraphicsjbuttonjtabbedpane

JButton visual glitch


I have a JFrame containing a JSplitPane with a JTabbedPane and another JSplitPane. The Second JSplitPane contains a JScrollPane and a JPanel. On the JPanel, there are two buttons that transfer back and forth between visuals for my program. The issue I am having is that there are visual artifacts being left on the JButtons when they are enabled and disabled, and sometimes when I scroll over them.

They should appear like this:

http://puu.sh/9z64Q/49aa838e63.png

But they appears like this: http://puu.sh/9z5VR/fe3eb124a7.png


Solution

  • On the JPanel, there are two buttons that transfer back and forth between visuals for my program.

    Don't use a tabbed pane for this because you can't control the painting of the tabs.

    Instead you should probably use a CardLayout to control the swapping of panels.

    You may want to consider looking at Card Layout Actions which extends the CardLayout to provide some support for next/previous functions