Jdbener
Jdbener

Reputation: 5

Scrolling a scrollbar to the bottom when its at the bottom

I am trying to make a chatbox application, im trying to code the side bar so that it will stay at the bottom but can also scroll up to view history. Is there any way i can do this?

pane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {  
        public void adjustmentValueChanged(AdjustmentEvent e) {  
            e.getAdjustable().setValue(e.getAdjustable().getMaximum());  
        }   
    });

Upvotes: 0

Views: 54

Answers (1)

camickr
camickr

Reputation: 324118

, im trying to code the side bar so that it will stay at the bottom but can also scroll up to view history

Check out the Smart Scrolling. When the scrollbar is at the bottom it will stay there as next text is added. If you scroll somewhere else, it will stay there (even when new text is added) until you move the scrollbar back to the bottom.

Upvotes: 1

Related Questions