Article View: borland.public.jbuilder.java.swing
Article #12770Inconsistent painting
From: Wil Rodriguez
Date: Sun, 15 Nov 1998 00:00
Date: Sun, 15 Nov 1998 00:00
38 lines
1802 bytes
1802 bytes
I've put together a very simple application. All you do is select an
image file (jpeg or gif) through the File Dialog box and the app
displays it. The thing is that the images are not always diplayed right
away. If an image is not displayed right away I have to resize the app
to see the image.
I've tried adding validate() to the JFrame, the TransparentImage, and
the JScrollpane with no success. Either the validate() call does
nothing or it stretches the image to the full dimension of the
JScrollPane.
Is there a tutorial out there on when and how to use the
repaint()/validate() functions? I know others have overcome this
problem before.
The code:
void jmiOpen_actionPerformed(ActionEvent e) {
filer.show(); // Open File Dialog
String imageFile = filer.getDirectory() + filer.getFile(); // Get
file selected
try {
//image is of type TransparentImage inside of a JScrollPane
container
image.setImageName(imageFile); // load the new image
image.setSize(image.getPreferredSize()); //use new image's
dimension
this.repaint(); // this = JFrame
} catch (IOException imgException) {
System.out.println(imgException.toString());
}
System.out.println(imageFile);
}
Any help appreciated.
Thanks!
Technical Details
Message-ID:
<364F8438.6398AEB3@rocketmail.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,a15fd3542a12d6db,start X-Google-Attributes: gid111d45,public From: Wil Rodriguez <wilrod@rocketmail.com> Subject: Inconsistent painting Date: 1998/11/15 Message-ID: <364F8438.6398AEB3@rocketmail.com> X-Deja-AN: 412238875 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing