JScrollPane and JList auto scroll

后端 未结 7 1613
无人共我
无人共我 2020-12-16 14:33

I\'ve got the next code:

    listModel = new DefaultListModel();
    listModel.addElement(dateFormat.format(new Date()) + \": Msg1\");
    messageList = new          


        
7条回答
  •  自闭症患者
    2020-12-16 15:16

    this.list = blah blah... 
    this.list.setSelectedValue(whatever);   
    final JScrollPane sp = new JScrollPane(this.list); // needs to be after the parent is the sp 
    this.list.ensureIndexIsVisible(this.list.getSelectedIndex());
    

提交回复
热议问题