mardi 12 août 2014

Java - Dimension de JLabel retourne 0 - Stack Overflow


I want to resize an image and display it in a JLabel.


I have the function for resize image have dimension like parameter. So:


public ImageIcon Resze(Dimension dim) {...}

But the dimension of label returns 0 and because this I have exception


I use the Absolute Layout


I tried 3 ways


Way 1


 Dimension D= this.ico.getSize();

Way 2


just for print


 System.out.println(this.ico.getBounds().height );

Way 3


just for print


System.out.println(this.ico.getHeight() );

But the result is 0.


If someone could help, that would be great thanks.



I want to resize an image and display it in a JLabel.


I have the function for resize image have dimension like parameter. So:


public ImageIcon Resze(Dimension dim) {...}

But the dimension of label returns 0 and because this I have exception


I use the Absolute Layout


I tried 3 ways


Way 1


 Dimension D= this.ico.getSize();

Way 2


just for print


 System.out.println(this.ico.getBounds().height );

Way 3


just for print


System.out.println(this.ico.getHeight() );

But the result is 0.


If someone could help, that would be great thanks.


0 commentaires:

Enregistrer un commentaire