๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #2740

Re: ScrollBox

#2740
From: Johan Forsberg
Date: Fri, 12 May 2000 00:00
41 lines
1788 bytes
David Br๏ฟฝnnvall <david@strangnas.mail.telia.com> skrev i
diskussionsgruppsmeddelandet:391aa7d0@dnews...
> What class should I use if I want to display and paint on an image in a
> scrollbox.
>
> regards david

Hej David,

if you're using Swing, you could do something like this:

class ScrollyImage extends JComponent implements Scrollable {
    BufferedImage img=new BufferedImage(1000, 1000,
BufferedImage.TYPE_INT_RGB);

    public Dimension getPreferredSize() {
        return new Dimension(img.getWidth(), img.getHeight());
    }
    public void paintComponent(Graphics g) {
        g.drawImage(img, 0, 0, null);
    }
    public Dimension getPreferredScrollableViewportSize() {
        return new Dimension(img.getWidth()/2, img.getHeight()/2);
    }
    int getScrollableBlockIncrement(Rectangle visibleRect, int orientation,
int direction) {
        return 100;
    }
    boolean getScrollableTracksViewportHeight() { return false; }
    boolean getScrollableTracksViewportWidth() { return false; }
    int getScrollableUnitIncrement(Rectangle visibleRect, int orientation,
int direction) {
        return 10;
    }
}

To draw on the Image, get its Graphics (img.getGraphics()) and execute
drawing command with that.

HTH
Technical Details
Message-ID: <8fgana$el81@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <391aa7d0@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1089d0,d3ec6556bfa79a9a
X-Google-Attributes: gid1089d0,public
From: "Johan Forsberg" <jfo@SPAM_SPAM_EGGS_SPAMstmf.se>
Subject: Re: ScrollBox
Date: 2000/05/12
Message-ID: <8fgana$el81@bornews.borland.com>
X-Deja-AN: 622453373
References: <391aa7d0@dnews>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.api