Java Core GUI APIs: ZScrollableDesktop revisited

  • ashayka / 300 / Mon, 04 May 2009 03:43:00 GMT / 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:

    zscrollabledesktop, revisited, java, core, gui, apis

  • http://java.itags.org/java-core-gui-apis/66610/«« Last Thread - Next Thread »»
  • Java Core GUI APIs Questions

    • image and outlook

      I'm having a problem when I copy an image to the Windows SystemClipboard. When I copy an image ...

      By jonathanm_usa

    • JOptionPane and HotKeys

      Hi, I was wondering if it was at all possible to include a hotkey on a simple JOptionPane. E.g. If a...

      By ibeandya

    • Trouble in Jformattedtextfield

      Hey!I'm having problem with entering numbers after decimal point. I 've settwo numbers aft...

      By kishanthany_gmail

    • netbeans debug problem

      Hi Guys,Any help appreciated on this one:I was happily building projects using netbeans 3.6, and was...

      By jez_naisbitt