Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages
Started by David Hite
Tue, 08 Feb 2005 11:03
Image Rendering
Author: David Hite
Date: Tue, 08 Feb 2005 11:03
Date: Tue, 08 Feb 2005 11:03
8 lines
1213 bytes
1213 bytes
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. TIA! David Hite
Re: Image Rendering
Author: John McGrath [TeamB]
Date: Tue, 08 Feb 2005 19:21
Date: Tue, 08 Feb 2005 19:21
30 lines
2203 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads