简体   繁体   English

这个Swing组件的名称是什么?

[英]What is the name of this Swing component?

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? 谁能告诉我如何做到这一点?

eg; 例如; like in windows 7 in my computer there is one toolbar called "Hard Disk Drives". 就像在我的计算机的Windows 7中一样,有一个工具栏叫做“硬盘驱动器”。 When we press on it it shows all the drives and when we again press it it hides it. 当我们按下它时,它显示了所有驱动器,当再次按下它时,它隐藏了它。

SwingX has a collapsible panel control that I think should do what you want. SwingX有一个可折叠的面板控件,我认为它应该做您想要的。 Also take a look at How to have Collapsable/Expandable JPanel in Java Swing . 还可以看看如何在Java Swing中具有可折叠/可扩展JPanel

Some alternatives: 一些替代方案:

  • You can add a JButon to a JToolBar . 您可以将JButon添加到JToolBar In your button's ActionListener , open a JOptionPane containing your components. 在按钮的ActionListener ,打开一个包含组件的JOptionPane This example illustrates some possibilities. 这个例子说明了一些可能性。

  • For a more advanced view, consider Outline , illustrated here . 要获得更高级的视图,请考虑此处所示的Outline

图片

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM