简体   繁体   中英

JavaFX TabPane cancel tab change

Using JavaFX 2.2 I have a window which consists mainly of a TabPane with 4 Tabs. The user may make changes to data presented in any of the tabs, and if they do, I want to make sure they don't loeave that tab until they've saved/cancelled/updated the data. In particular I want to make sure they don't select a different tab. I can catch if they're trying to quit or execute some menu item, but I can't seem to find a way to interrupt a tab change. I can catch when they've clicked on a new tab (onSelectionChanged), and ask if they really want to discard their edits, but then the tab change happens anyway. Help greatly appreciated.

获取选项卡窗格的选择模型,监视其选定的索引属性以进行更改,并在检测到更改时询问您的选项卡是否可以立即更改 - 如果没有,请将所选索引设置回当前选定的选项卡,覆盖选择更改为新选项卡。

您可以停用其他标签,直到用户点击“保存”或“取消”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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