0

I want to put one toolbar type component in which there will be one button which when pressed the toolbar should expand, size of the form increases and it contains some components like text area and label that user can see and once again when the button is pressed the toolbar is minimized and the size of the form decreases.

Can anybody tell me how to accomplish this?

e.g; like in windows 7 in my computer there is one toolbar called "Hard Disk Drives". When we press on it it shows all the drives and when we again press it it hides it.

Matt Taylor
  • 3,360
  • 1
  • 20
  • 34
  • 1
    please dont use uppercase titles... – nano_nano Apr 09 '13 at 09:33
  • "Home made" - there is no component in Swing that can do that. You could use a JButton when clicked, displays a JPopupMenu that would hold your extra controls, but you're going to have to make it yourself – MadProgrammer Apr 09 '13 at 09:55
  • search for java & ribbon or accordion – mKorbel Apr 09 '13 at 10:35
  • See also this duplicate question: [Explorer bar in java or any other component](http://stackoverflow.com/questions/15895561/explorer-bar-in-java-or-any-other-component). – trashgod Apr 09 '13 at 16:10

2 Answers2

2

SwingX has a collapsible panel control that I think should do what you want. Also take a look at How to have Collapsable/Expandable JPanel in Java Swing.

Community
  • 1
  • 1
Vindicare
  • 213
  • 1
  • 12
2

Some alternatives:

  • You can add a JButon to a JToolBar. In your button's ActionListener, open a JOptionPane containing your components. This example illustrates some possibilities.

  • For a more advanced view, consider Outline, illustrated here.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045