combobox.addKeyListener().....do an input character check, if necessary, append or remove the last hit character.

解决方案 »

  1.   

    这样来做:
    1.写一个实现ComboBoxEditor接口类,里面有个JTextField的对象;
      这个jTextField让它只能输入数字,具体做法参见我在:
      http://expert.csdn.net/Expert/topic/1783/1783604.xml?temp=.2580377
      中的回答。
    2.在实现ComboBoxEditor接口中的 public Component getEditorComponent()方法时,返回jTextField.
    3.调用jComboBox.setEditor(...);,传入你自己写的实现ComboBoxEditor接口的对象即可。