如何使用 TabbedPane 选项卡更改在 NetBeans IDE 内置的 Applet 中显示不同的面板?
我正在 NetBeans 中构建一个 Java Applet,该 Applet 的底部有一个 TabbedPane,顶部有一个常规面板。我希望顶部面板根据底部选择的选项卡进行切换。 (我会附上一个屏幕截图来澄清,但这里是新的,这是不允许的。)
按钮有 ActionPerformed,但 TabbedPane 似乎没有每个单独选项卡的 StateChange(至少在 NetBeans 中不容易看到) 。
有什么想法吗?
I'm building a Java Applet in NetBeans that has a TabbedPane on the bottom of the applet and a regular Panel on the top. I would like the top Panel to switch depending on which tab is selected on the bottom. (I would attach a screenshot to clarify, but being new here it isn't allowed.)
A Button has ActionPerformed, but a TabbedPane doesn't seem to have StateChange for each of the seperate tabs (at least not readily visible in NetBeans).
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这里,你可以这样做:
然后,使用一些switch 语句来指导程序的流程。
续:上次我在 Netbeans 中使用 JTabbedPane 时,我所要做的就是添加一个新选项卡并为其构建 GUI。如果您遇到此问题,您可能需要查看 卡片布局。
如果您浏览开发屏幕右侧的选项卡,您应该会看到事件列表。您需要做的就是从该列表中选择适当的事件,Netbeans 将为您做这件事。另一方面,您可以使用文本编辑器(WordPad、NotePad++ 等)打开 .java 文件(虽然不在 netbeans 中打开),修改您想要的代码并保存它。当您通过 netbeans 打开文件时,您应该看到您的更改也已加载。
According to here, you can do something like this:
Then, use some switch statement to direct the flow of the program.
Continuation: Last time I used a JTabbedPane in Netbeans, all that I had to do was to add a new tab and simply build the gui for it. If you are having trouble with this, you might want to take a look at the Card Layout.
If you go through the tabs on the right hand side of your development screen, you should come accross a list of events. What you need to do is to select the appropriate event from that list and Netbeans will do it for you. On the other hand, you can open the .java file (while not open in netbeans) with a text editor (WordPad, NotePad++, etc) modofiy the code you want and save it. When you will open the file back through netbeans, you should see that your changes have been loaded as well.