I wanted to get a scaled instance of a buffered image, and I did:
public void analyzePosition(BufferedImage img, int x, int y){ img = (BufferedImage) img.getScaledInstance(getWidth(), getHeight(), Image.SCALE_SMOOTH); .... }
but I get an exception:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.awt.image.ToolkitImage cannot be cast to java.awt.image.BufferedImage at ImagePanel.analyzePosition(ImagePanel.java:43)
Then I needed to click ToolkitImage , and then use the getBufferedImage method, which I read about in other articles. The problem is that there is no class like sun.awt.image.ToolkitImage which I cannot use for it because Eclipse does not even see this class. I am using Java 1.7 and jre1.7 .

java toolkit bufferedimage scale
Yoda
source share