请问如何取得JComboBox选中的值,谢谢 请问如何取得JComboBox选中的项的值,是要取得选中项的名字,一个String值,用 jComboBox.getSelectedItem()好像不行呀 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要一个转换(String) getSelectedIterm() jComboBox.getSelectedItem() 得到的应该是对象,可以重写toString()方法来获取,不知道回答是否对 combo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(((SteppedComboBox) e.getSource()) .getSelectedItem()); String comboxValue = (String) ((SteppedComboBox) e.getSource()) .getSelectedItem(); } }); private String[] str={"xiao","dap","zhong"}; String s1= (String)jc.getSelectedItem();//jc.getSelectedItem 方法放回的是Object 类型的 JComboBox jc=new JComboBox (str); jComboBox.getSelectedItem().toString();就可以 JDialog显示问题 双向循环链表的重新排序 canvas可以嵌入JPanel中么? 如何使用数组作为参数 javax.speech dwr参数问题 请教:applet播放声音...异常 一段内部类代码,不解. eclipse调试问题 有人用java开发过Agent吗? java Object读取的问题! 关于排序的问题
combo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
System.out.println(((SteppedComboBox) e.getSource())
.getSelectedItem());
String comboxValue = (String) ((SteppedComboBox) e.getSource())
.getSelectedItem();
}
});
String s1= (String)jc.getSelectedItem();//jc.getSelectedItem 方法放回的是Object 类型的
JComboBox jc=new JComboBox (str);
就可以