Java JTabbedPane问题 [英] Java JTabbedPane questions

查看:105
本文介绍了Java JTabbedPane问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JTabbedPane来保存我正在构建的向导中的每个步骤.步骤之间的导航是使用上一个/下一个"按钮或选择一个选项卡进行的.这些按钮可减少/增加JTabbedPane的SelectedIndex.

I'm using a JTabbedPane to hold each step in the wizard that I am building. Navigation between steps is doing using the Previous/Next buttons or by selecting a tab. The buttons decrement/increment the JTabbedPane's SelectedIndex.

在进行下一步之前,我需要验证每个步骤.本质上,我很难确定要使用哪个事件. StateChange事件发生得太晚了.我需要观察哪个事件?

I need to validate each step before proceeding to the next step. Essentially, I'm having difficulty determining which event to use. The StateChange event occurs too late. Which event do I need to observe?

另一个烦恼:向导运行时,似乎保存了JTabbedPane的SelectedIndex的状态(通常是最后一步的值),然后使用该值设置下次运行向导时的SelectedIndex.设计器中的selectedIndex属性未更改.而且,在JPanel的构造函数中调用setSelectedIndex()似乎对此没有影响.我想念什么?

Another irritation: when the wizard runs, it seems to save the state of the JTabbedPane's SelectedIndex (usually the last step's value), this value is then used to set the SelectedIndex the next time the wizard is run. The selectedIndex property in the designer hasn't change. Moreover, calling the setSelectedIndex() in the JPanel's contructor doesn't seem to have an effect on this. What am I missing?

推荐答案

而不是 JTabbedPane ,请考虑使用 CardLayout .后者使您可以更严格地控​​制导航.

Instead of JTabbedPane, consider using CardLayout. The latter lets you control navigation more rigidly.

这篇关于Java JTabbedPane问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆