I have a custom JInternalFrame that displays a TIFF using JAI to get a BufferedImage and displaying it using ImageIcon, a JLabel, and a JScrollPane. I'm using a JSlider to control the scaling and using getScaledInstance() to do the zooming. This works fine, my problem is I'm not entirely happy with the performance and I'm wondering if there's an easy way to speed it up. I'd like to pass the stuff that takes a while to execute to a new
thread and let it run there so the GUI remains responsive. My problem is I'm not entirely sure how to do this effectively AND safely.
icon.setImage(), label.invalidate(), pane.invalidate(), and repaint() are my main concerns. Which, if any, can be safely run from a thread other than the event-dispatching thread? I want to GUI to remain responsive, I don't care if it takes a short bit for the image to actually change just so long as it isn't holding up the GUI. I tried passing the whole thing off to a thread but I don't think that's thread safe and if I do the icon.setImage() and the rest in the event-dispatching thread it's slow.
Suggestions?