如何在JavaFX中以编程方式切换选项卡 [英] How to switch through tabs programmatically in JavaFX

查看:161
本文介绍了如何在JavaFX中以编程方式切换选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一次只能看到一个标签。用户使用鼠标/键盘选择一个。
假设,TabPane上有三个选项卡,首先是一个按钮。当用户按下按钮时,我想要打开第二个标签。
然后必须有一些代码切换到绑定到按钮的第二个Tab。



是否可以以编程方式?
若然,怎么办?

解决方案

试试



<$ p 。$ p> tabPane.getSelectionModel()选择(索引);

  tabPane.getSelectionModel()选择(someTab)。 

  tabPane.getSelectionModel()selectNext(); 

或......


Only one tab is visible at a time. The user selects the one using mouse/keyboard. Suppose, there are three tabs on TabPane and there is a button on first. When user press the button, I want the second tab to be opened. Then there must be some code to switch to second Tab that in bound to the button.

Is it possible programmatically? If so, how?

解决方案

Try

tabPane.getSelectionModel().select(index);

or

tabPane.getSelectionModel().select(someTab);

or

tabPane.getSelectionModel().selectNext();

Or...

这篇关于如何在JavaFX中以编程方式切换选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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