Pretty JPanels in Swing
-
22-09-2019 - |
Question
I'm currently working on making my Swing application look better. I want to achieve something along these lines:
The idea is for each box to have a pretty header with a background similar to the above image. The closest I can get to anything like this using basic Swing components is adding a TitledBorder but this is nothing close to what I want.
I have experiment with JXTaskPane from SwingX, which is close:
http://img411.imageshack.us/img411/6866/image431.png
And near perfect, except for the fact that it's collapsible and it doesn't appear possible to make it not collapsible.
Are there any obvious solutions I'm missing here? Otherwise I figure extending JPanel and creating a special header for it using a image for the background of the header.
Any pointers greatly appreciated. Thanks.
Solution
Since you already looking into SwingX components, why don't you use JXTitledPanel? I think it is very close to what you want to achieve. You can set your own colors there.
OTHER TIPS
Yes, why not write your own custom border or JPanel for that? You customize the painting by overriding the paintComponent-method.