• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Scroll to most recent item in List box

public class udpClient extends Applet {
      Label lblCommon =  new Label("Text Here");
      Panel pTop = new Panel();
      Button bEnter = new Button("Enter");
      TextField txtChat      = new TextField(20);
      List lst = new List(4, false);
      
      public void init() {
          
            class BL implements ActionListener {
                  public void actionPerformed(ActionEvent e){
                        lst.add(txtChat.getText());
                        lst.add(Integer.toString(lst.getItemCount()));
                        lst.select(lst.getItemCount());
                        lst.makeVisible(lst.getItemCount());
                         
                  }
            }
            
            BL a = new BL();
            bEnter.addActionListener(a);
            
            resize(320,400);
            
          setLayout(new BorderLayout());
          add(pTop,BorderLayout.NORTH) ;
                
                pTop.add(lblCommon);
                pTop.add(txtChat);
                pTop.add(bEnter);
          
          add(lst,  BorderLayout.CENTER);
                  
    }
}

how do i make the list box scroll to the most recent added item

thanks.. the code above didnt release any errors.. but items were added.. just that the select and makeVisible method doesnt seem to work

thanks
0
load_o_crap
Asked:
load_o_crap
1 Solution
 
pyxideCommented:
what about "lst.getItemCount()-1" instead of "lst.getItemCount()" ?
(last index = count - 1 )

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now