pretty new here, but here is a little test code that explains my problem. The value printed is -1. I just donβt have the slightest idea on how to return the pixel width of my image, did I miss something very obvious here? This whole ImageObserver object does not make sense !!!
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class imagetest2 extends JPanel {
Image i =Toolkit.getDefaultToolkit().getImage();
public int test(){
int x = i.getWidth(null);
return x;
}
}
class imagetest {
public static void main(String args[]){
imagetest2 tesst = new imagetest2();
System.out.print(tesst.test());
}
}
source
share