??JComboBox实现类似于HTML的select一般是怎么做的,就是有一个显示值有一个实际值 JComboBox实现类似于HTML的select一般是怎么做的,就是有一个显示值有一个实际值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是类似于<select><option value='test'>测试</option><select>option 不是有一个value么 fontComBox.addItem("A");fontComBox.addItem("B");fontComBox.addItem("C");fontComBox.addItem("D");if(fontComBox.getSelectedItem()=="B") System.out.println("B"); public class ComboBoxItem { private Object value = null; private String text = null; public ComboBoxItem(Object value, String text) { this.value = value; this.text = text; } public Object getValue() { return value; } public String toString() { return text == null ? "" : text; }}...combobox.add(new ComboBoxItem("test", "测试"));...ComboBoxItem item = (ComboBoxItem))combobox.getSelectedItem();String value = (String)item.getValue(); 算法问题 JAVA一个程序中为什么规定只能有一个公共类? 一个简单的程序,放声的 关于JFram的重大问题? 接口继承问题 HttpURLConnection取回数据的问题!!!急!!!急!!! 汉诺塔问题分析过程。 怎样初始化 i、j、k ? 同步问题:高手请进!研究过Think in Java第14章多线程的请进 一个让我觉得都不好意思问的问题 要CS1.5过任何平台的作弊器的朋友请加我MSN JTable如何使用?有没有最简单的例子。
option 不是有一个value么
fontComBox.addItem("B");
fontComBox.addItem("C");
fontComBox.addItem("D");if(fontComBox.getSelectedItem()=="B")
System.out.println("B");
private Object value = null;
private String text = null;
public ComboBoxItem(Object value, String text)
{
this.value = value;
this.text = text;
} public Object getValue()
{
return value;
} public String toString()
{
return text == null ? "" : text;
}
}...
combobox.add(new ComboBoxItem("test", "测试"));
...
ComboBoxItem item = (ComboBoxItem))combobox.getSelectedItem();
String value = (String)item.getValue();