AWT problem on linux

Diego Santa Cruz Diego.Santacruz at epfl.ch
Fri Sep 4 09:32:22 PDT 1998


Hi there,

	Thanks a lot for the suggestion, I've changed my code to use the style you
suggest and of course it is much better that way. But there is still a problem.
The thing is that I do not display the image directly in a Frame but I have a
component that displays images. The problem is that I cannot use setSize once I
receive the image dimensions. What I do is to return a default size in
getMinimumSize and others and once I receive the image dimensions through
imageUpdate i invalidate the component (which should also invalidate all its
ancestors, including its container) and then I validate the container (or
parent) as to force a new layout to be done. It works OK with Sun's JDK.

	The problem is that in kaffe the invalidate method does not seem to work: if I
call invalidate() and then I query the state through isValid() right away, it
returns true (when it should return false since I invalidated the component). So
in kaffe it seems that invalidate() does not work as it should and therefore it
is impossible to invalidate something and then validate it to force a new layout
to be done.

	I'm using kaffe 1.0.b1 on Linux.


Peter C. Mehlitz wrote:
> 
> >On Thu, Sep 03, 1998 at 12:27:07AM +0200, Diego Santa Cruz wrote:
> >> I've found the problem.
> >> The problem was that I did not wait until the image dimensions became available
> >> and thus it was setting the component size to (-1,-1) which made the window of
> >> just 1 pixel in height and extreamely large in width (several thousands pixels).
> >> The problem did not show up in Sun's JDK since there the dimensions are
> >> immediately available. I just added a loop with a sleep to wait for the
> >> dimensions.
> 
> No, sleeping isn't the right way to do that. I append a solution that
> plays it according to the specs.
> 
> If you try this with a small image, you will notice that the Frame size isn't a
> exact match. This is due to a Frame size inconsistency we could easily solve
> (by removing some code), but which would make it even more "incompatible" with
> JDK behavior (NOT specs). This is subject to my next message.
> 
> -- Peter
> 
> -------------------------------------------------------------------
> import java.awt.*;
> import java.awt.image.*;
> 
> public class Img extends Frame {
>         Image img;
>         public Img ( String title ) {
>                 super( title);
>         }
>         void showIt () {
>                 setSize( img.getWidth(this), img.getHeight( this));
>                 setVisible( true);
>         }
>         public void setImage ( String imgSpec ) {
>                 Toolkit tk = getToolkit();
>                 img = tk.getImage( imgSpec);
>                 if ( tk.prepareImage( img, -1,-1, this) )
>                         showIt();
>         }
>         public boolean imageUpdate ( Image img, int info, int x, int y, int w, int h ){
>                 if ( !isShowing() &&
>                          ((info & ImageObserver.WIDTH) != 0) &&
>                          ((info & ImageObserver.HEIGHT) != 0) ) {
>                         showIt();
>                         return true;
>                 }
>                 return super.imageUpdate( img, info, x, y, w, h);
>         }
>         public void paint ( Graphics g ) {
>                 Insets in = getInsets();
>                 g.drawImage( img, in.left, in.top, this);
>         }
>         public static void main ( String[] args ) {
>                 Img v = new Img( "Image Test");
>                 v.setImage( args[0]);
>         }
> }

-- 
-----------------------------------------------------------------------
Diego Santa Cruz                         mailto:Diego.Santacruz at epfl.ch
Signal Processing Laboratory (LTS)                http://ltswww.epfl.ch
Swiss Federal Institute of Technology (EPFL)
EL - Ecublens - CH-1015 Lausanne - Switzerland
Office:     ELH 130
Phone:      +41 - 21 - 693 56 45 (Office)
            +41 - 21 - 693 46 20 (LTS Lab)                 *   *
Fax:        +41 - 21 - 693 76 00                           'O^-'
Mobile:     +41 - 79 - 435 06 45                           ( o )
-------------------------------------------------------- oOO U OOo ---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vcard.vcf
Type: text/x-vcard
Size: 559 bytes
Desc: Card for Diego Santa Cruz
Url : http://kaffe.org/pipermail/kaffe/attachments/19980904/afb092d7/attachment-0006.vcf 


More information about the kaffe mailing list