How to get the selected item from a ComboBox in JavaFX?

只谈情不闲聊 提交于 2020-01-03 20:02:07

问题


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 :)


回答1:


Take a look at the API: http://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ComboBox.html

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



来源:https://stackoverflow.com/questions/30572918/how-to-get-the-selected-item-from-a-combobox-in-javafx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!