how to locate bottom of scrolling panel?

Hi…

I am making simple chatting program.
But output window always shows top position.
How to make it automatically scrolls down to show the added message.

codes are here.

[code]

    	chatWin = new Window ("Message");
    	chatWin.setWidth ("600px");
    	chatWin.setHeight ("250px");
    	chatWin.setPositionX(5);
    	chatWin.setPositionY(500);
   		
    	// Configure the windows layout; by default a VerticalLayout
            VerticalLayout layout = (VerticalLayout) chatWin.getLayout();
            layout.setMargin(true);
            layout.setSpacing(true);
            layout.setSizeFull ();

            final Panel output = new Panel ("");
            output.setHeight ("100%");
            layout.addComponent(output);
            
        	final TextField input = new TextField();
        	input.setImmediate(true);
        	input.setSizeFull ();
        	input.setHeight("20px");
        	input.focus ();

        	layout.addComponent(input);
        	layout.setExpandRatio (output, 1.0f);
            
        	input.addListener(new TextField.ValueChangeListener() {
                public void valueChange(ValueChangeEvent event) {
                   getMainWindow().showNotification(event.toString ());
                   // Add some content; a label and a close-button
                   output.addComponent (new Label(input.getValue().toString()));
                    input.focus();
                }
            });

You can use Panel.setScrollTop for that purpose. Just use a high enough value, like 99999, and it should scroll all the way down.

There has been talk about an enhancement to make Panel.scrollToComponent(Component c) method, but we’re not there yet.

thanks, but it does not work…

        	input.addListener(new TextField.ValueChangeListener() {
                public void valueChange(ValueChangeEvent event) {
                    output.addComponent (new Label(input.getValue().toString()));

                    output.setScrollTop(9999);

                    input.focus();
                }
            });

output panel does’not scroll automatically.
What do you think the problem is?

Hmm, this seems to be trickier than I thought.

You have to specify this as well:

Panel.setScrollable(true); in order to make setScrollTop/Left make any difference. Don’t see why, but that’s how it is currently.

With the above line added, I’m able to scroll the Panel to the bottom. But on Safari4/Mac the actual scrollbar does not change state - it stays in the top, which is confusing. FF3/Mac works like it should, so I believe this is a Safari bug.

You can see a simple code example here: http://sami.virtuallypreinstalled.com/scripter/run/panelscrolling/

Thanks, i found my problem.
I can’t describe my case exactly because of my poor english.
I added the following lines, it works well in IE6.

[code]

/* to scroll bottom end, first create scroll bar and scroll down */
output.setScrollable(false);
for (int i=0; i<20; i++) {
output.addComponent(new Label(""));
}
output.setScrollable(true);
output.setScrollTop(9999);