简体   繁体   English

Eclipse Windows Builder动态更改面板内容

[英]Eclipse Windows Builder dynamically change content of panel

I'm using WindowsBuilder (Eclipse) to generate a simple GUI. 我正在使用WindowsBuilder(Eclipse)生成一个简单的GUI。 Basically, I have a series of buttons ("Add Book", "Add DVD", "Add Magazine", etc..) add the top of the gui, and a JPanel underneath them. 基本上,我有一系列按钮(“添加书”,“添加DVD”,“添加杂志”等。)将gui的顶部添加到其下面,并添加一个JPanel。 I would need to display a different series of elements (textfields, radio buttons etc) depending on which button the user presses. 我将需要显示一系列不同的元素(文本字段,单选按钮等),具体取决于用户按下的按钮。 I have understood the basics of adding elements, but how can I define these multiple panel structures? 我已经了解了添加元素的基础,但是如何定义这些多个面板结构呢?

Thanks :) 谢谢 :)

I would need to display a different series of elements (textfields, radio buttons etc) depending on which button the user presses. 我将需要显示一系列不同的元素(文本字段,单选按钮等),具体取决于用户按下的按钮。

You should be using a CardLayout which will allow you to swap panels depending on the button pressed. 您应该使用CardLayout,它允许您根据按下的按钮交换面板。 Read the section from the Swing tutorial on How to Use Card Layout work a working example. 阅读Swing教程中有关如何使用卡布局的部分的工作示例。

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

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