Link to home
Start Free TrialLog in
Avatar of load_o_crap
load_o_crap

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of pyxide
pyxide

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial