Skip to main content

Setting the color of a Titlebar in a JXTitledPanel

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
miguelm
Offline
Joined: 2005-03-17

Okay, I'm new to SwingX, and it all looks very cool, but I often feel like I need a secret decoder ring to figure out how to use it. The demo JXTitledPanel has a nice blue background color, but when I use one in my own application, the title comes out gray. I don't see anything in the demo code that could possibly change the color, and I certainly don't see an API to specify a color. Furthermore, the PainterUIResource I extracted does a fine job of concealing the actual painter that's doing the work.
Can anybody tell me how to specify the color of a titlebar in a JXTitledPanel?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kschaefe
Offline
Joined: 2006-06-08

The gray painter is the default painter. The color you get depends on the look and feel. Metal returns an appropriately themed title painter, while windows uses colors from the JInternalFrame.
If you would like to see the colors being used, review TitledPaneAddon.java. You can always choose to create a custom painter with any painting code you like. See the demos Painters section for ideas on how to use painters.
Karl

miguelm
Offline
Joined: 2005-03-17

Thanks.