Creating image thumbnails is slow on Mac platform, suggestions for improvement?



My java application is given a list of image files. For each image, it
creates an image thumbnail and displays this thumbnail in a separate
JFrame. The creation of these thumbnails is very slow compared to the
Mac Preview application. Is there a way to speed this up?

Each thumbnail is displayed in a separate JFrame to allow the thumbnails
to be dragged and repositioned on the screen independently. Each
thumbnail is converted to an ImageIcon and displayed in a JButton.
Clicking on the button will rotate the image 90 degrees.

Here is the method which creates the JFrame. I'd appreciate any
suggestions how I can improve performance speed.



private final static int
FRAME_WIDTH = 0,
FRAME_HEIGHT = 20,
THUMB_WIDTH = 150,
THUMB_HEIGHT = 225;


private JFrame createFrame(File file)
{
Image image =
Toolkit.getDefaultToolkit().createImage(file.getPath());

Image thumb = image.getScaledInstance(THUMB_WIDTH, THUMB_HEIGHT,
Image.SCALE_SMOOTH);

JButton button = new JButton(new ImageIcon(thumb));
button.addActionListener(myButtonListener);

JFrame frame = new JFrame();
frame.setTitle(file.getName());
frame.setSize(FRAME_WIDTH + THUMB_WIDTH, FRAME_HEIGHT +
THUMB_HEIGHT);
frame.setLayout(new BorderLayout());
frame.add(button, BorderLayout.CENTER);

return frame;
}
.


Quantcast