有没有类似于TextField中的.setText就好了;如果我想在jComBox中显示指定项的值,而不是显示的默认的第一项,用什么方法啊?

解决方案 »

  1.   

    void setSelectedIndex(int anIndex) Selects the item at index anIndex.
      

  2.   

    fontComBox=new JComboBox(); fontComBox.addItem("a");
    fontComBox.addItem("b");
    fontComBox.addItem("c");
    fontComBox.addItem("d");
    fontComBox.addItem("e");
    //设计e为默认项
                      fontComBox.setSelectedItem("e");
      

  3.   

    void setSelectedIndex(int anIndex) 
              Selects the item at index anIndex. 
     void setSelectedItem(Object anObject) 
              Sets the selected item in the combo box display area to the object in the argument. 
      

  4.   

    JComboBox test = JComboBox();test.addItem("another");
    test.addItem("this");test.setSelectedItem("this");