[英]how to check whether a particular items is selected from combo-box in java (determining with the number of element selected)
I added a combo box to my JFrame and those items are added from an array. 我向我的JFrame添加了一个组合框,并且这些项是从数组中添加的。 What i want to know is that how to check whether and items is selected so that i can do some function with that like;
我想知道的是如何检查是否选择了项目,以便我可以执行类似的功能;
String[] osCM = {"--Select--", "Windows", "Mac", "Unix", "Linux" };
JComboBox cmbOS = new JComboBox(osCM);
cmbOS.setBounds(116, 69, 149, 20);
add(cmbOS);
if(//code to check a particular item is selected){
//do some function
}else if(//code to check a particular item is selected){
//do some function
}else{
//do some function
}
Please help. 请帮忙。 Thanks is advance.
感谢是前进。
if(cmbOS.getSelectedIndex()== 0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.