I want a JPanel that can be Collapsed or Expanded when user clicks on a text/icon on its border. I need this type of panel due to space crunch in my application.
I read about CollapsiblePanel class but not sure how to use it.. I think SwingX is needed to be downloaded but did not find that anywhere.
Moreover, it would be better if I get the solution to this in basic Java Swing.
As we mentioned before, Swing provides three generally useful top-level container classes: JFrame , JDialog , and JApplet .
You can simply create your jPanel using drag and drop, as you always do and then for changing the panel's color and making it transparent or semi-transparent you can use this code: panel. setBackground(new Color(0.0f, 0.0f, 0.0f, 0.5f));
You can set a panel's layout manager using the JPanel constructor. For example: JPanel panel = new JPanel(new BorderLayout()); After a container has been created, you can set its layout manager using the setLayout method.
not sure where you looked, but it's not that difficult to find - even given the infrastructure mess we are in ;-)
Go to the project home of SwingX, then follow the link in the first paragraph to the (barebone) download section, down to releases\1.6.2. Nothing special to the collapsibles themselves, just containers to put components into.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With