I ran into that problem, and the following seems to work:

Point viewPos = scrollPane.getViewport().getViewPosition();
scrollPane.remove(myBox);
// update myBox 
scrollPane.getViewport().setView(myBox);
scrollPane.getViewport().setViewPosition(viewPos);
myBox.revalidate();

Evan

> James Brundege wrote:
> 
> Hi there,
> 
> I'm got a complex layout with a Box inside a Jscrollpane.  I want to
> let the user type into a textArea and then add what they typed to the
> top of the view, above where the cursor is.  However, when I call
> revalidate() to update the display, it repositions the scrollpane to
> the top, so the cursor is off-screen.
> 
> I can reposition the scrollpane by calling setViewPosition() on it's
> viewport.  However, it tends to redraw the screen AFTER I do this,
> putting it into position for a split second and then redrawing down
> from the top.
> 
> What I need is a way to add components to the Box and then tell the
> Layout Manager to re-layout the components, and recalculate the
> viewport position without repainting them.  Then paint them ONCE in
> the correct location.  Does anyone know how this can be done?
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to