JList加在JScrollPane中。比如我在JList中有顺序排好的一万项,在JComboBox中输入后要JList能根据输入将该项显示在JList的第一行,该怎么做呢?  
小弟不知说明白没有呵,先谢谢大虾们关照

解决方案 »

  1.   

    在JComboBox里输入后直接插入到JList,它才不管你有没有排过序的。直接显示在第一行。
      

  2.   

    setSelectedValue
    public void setSelectedValue(Object anObject,
                                 boolean shouldScroll)
    Selects the specified object from the list. Parameters:
    anObject - the object to select
    shouldScroll - true if the list should scroll to display the selected object, if one exists; otherwise false
    选择的对象会滚动到能见 位置,被选中,但是应该不一定是第一行,不知道是否满足你的要求