如何从JavaFX的ComboBox中获取所选项目? [英] How to get the selected item from a ComboBox in JavaFX?

查看:619
本文介绍了如何从JavaFX的ComboBox中获取所选项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ComboBox cbx 和一个TabPane包含选项卡(选项卡: t )和一个按钮 b1 。因此,单击此按钮 b1 时,它将在TabPane中添加一个新标签 t ,并在其中添加一个新项目。 ComboBox cbx 包含选项卡的相同名称。问题是我不知道如何从 cbx 获取项目,并且该项目的名称与标签的名称相同,然后又是做点事,这样我就可以用javafx做到这一点,非常感谢:)

i have ComboBox cbx and a TabPane Contains Tabs (tab: t) and a button b1. So on click on this button b1, it adds a new tab t in the TabPane and it adds a new item in the ComboBox cbx contains the same name of the tab. The problem is i don't know how to get the item from cbx and much the name of the item with the same name of the tab and then Do something so how i can do this with javafx and thanks very much :)

推荐答案

查看API:
http: //docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ComboBox.html

有一个 comboBox.getValue()方法,为您提供选定的项目。

There's a comboBox.getValue() method which gives you the selected item.

这篇关于如何从JavaFX的ComboBox中获取所选项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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