Jak uzyskać skalowane wystąpienie bufferedImage

Chciałem uzyskać skalowane wystąpienie buforowanego obrazu i zrobiłem to:

public void analyzePosition(BufferedImage img, int x, int y){   
     img =  (BufferedImage) img.getScaledInstance(getWidth(), getHeight(), Image.SCALE_SMOOTH);
....
}

ale dostaję wyjątek:

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)

Chciałem wtedy rzucićToolkitImage następnie użyj metodygetBufferedImage Czytałem o innych artykułach. Problem polega na tym, że nie ma takiej klasy jaksun.awt.image.ToolkitImage Nie mogę tego rzucić, ponieważ Eclipse nawet nie widzi tej klasy. używamJava 1.7 ijre1.7.

questionAnswers(2)

yourAnswerToTheQuestion