🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #571

Re: Image Rendering

#571
From: John McGrath [TeamB]
Date: Tue, 08 Feb 2005 19:21
30 lines
2203 bytes
On 2/8/2005 at 6:03:47 AM, David Hite wrote:

> Hi - does anyone know of a component that will display an image 
> proportionally depending on the current size of the window (that is, 
> dynamically resize the image as the user sets the size of the screen
> smaller or larger)? The behavior of Windows XP Explorer with the View
> set to "FilmStrip" (and viewing images) is an example of what I'm
> looking for.

It would be very easy to write such a component.  Just extend JPanel and
override the paintComponent method to paint the image, specifying the
width and height.  Here is a rough (untested) stab at it:

   public void paintComponent( Graphics g ) {
      super.paintComponent( g );
      Dimension size = getSize();
      Insets insets = getInsets();
      int width = size.width - insets.left - insets.right;
      int height = size.height - insets.top - insets.bottom;
      g.drawImage( image, insets.left, insets.top, width, height, this );
   }

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <xn0dy9go23zbcs2000@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42089c92$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,aab81fc8e4238a13
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "John McGrath  [TeamB]" <ng-b@JPMcGrath.net>
Subject: Re: Image Rendering
Newsgroups: borland.public.jbuilder.java.swing
References: <42089c92$1@newsgroups.borland.com>
User-Agent: XanaNews/1.17.2.3
Message-ID: <xn0dy9go23zbcs2000@newsgroups.borland.com>
X-Ref: newsgroups.borland.com ~XNS:0000018F
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
NNTP-Posting-Host: 141.151.11.96
Date: 8 Feb 2005 11:21:05 -0800
X-Trace: newsgroups.borland.com 1107890465 141.151.11.96 (8 Feb 2005 11:21:05 -0800)
Lines: 30
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail