Home » Category » Java Core GUI APIs

Java Core GUI APIs: ZScrollableDesktop revisited

300| Sun, 23 Sep 2007 16:37:00 GMT| ashayka| Comments (0)

Hi,

Looking through the archives, I came upon ZScrollableDesktop and have been trying to adapt it to my needs. Specifically, I need to have the scrollpane automatically scroll, as in scrollToVisibleRect(), not merely resize the desktop so as to create appropriate scrollbars.

I'm no stranger to writing desktop layout managers, and I know the solution is somewhere in the dragFrame() method of ZDesktopManager, but I just can't get scrolling to work correctly.

My dragframe() looks something like this:

public void dragFrame( JComponent f, int newX, int newY ) {

Rectangle dBounds = f.getParent().getBounds();

if( newX < 0 ) {

newX = 0;

}

if( newY < 0 ) {

newY = 0;

}

super.dragFrame( f, newX, newY);

// I pass a reference to ZDesktopPane to ZDesktopManager

desktop.scrollRectToVisible(new java.awt.Rectangle(newX, newY,1,1));

desktop.repaint();

}

Unfortunately, this doesn't work properly. As the internal frame is dragged beyond the viewport window bounds, the scrollpane does indeed begin to scroll, but the cursor position relative to the internal frame begins to grow in the direction of the scrolling. In essence, the cursor 'runs away' from the internal frame. There is some interaction between scrolling and internal frame position that I'm not taking into account, so that's where I was hoping for some help.

I'd especially appreciate a tested solution.

Thanks in advance,

Alex

Keywords & Tags: zscrollabledesktop, revisited, java, core, gui, apis

URL: http://java.itags.org/java-core-gui-apis/66610/
 
«« Prev - Next »» 0 helpful answers below.

Java Core GUI APIs Hot Answers

Java Core GUI APIs New questions

Java Core GUI APIs Related Categories