Making my JDesktopPane scrollable
Posted on 2003-11-17
Greetings. I'm creating an application that takes an MDI approach, so I've implemented JDesktopPane and have created JInternalFrame's as the interior windows. I'd like to make this scrollable so that when any of the interior windows is clipped, appropriate scroll-bars are displayed. I've done some research on this, and from what I've seen most people accomplish this by creating a subclass of JDesktopPane (call it, say, JScrollableDesktopPane) and have this subclass implement the Scrollable interface.
Well, I've tried this, and I can't seem to get it to work. I think I'm just unclear as to how I'm supposed to use this JScrollableDesktopPane once I've made an instance of it. Here's what I'm currently trying, and is not working:
1) Create an instance of JScrollableDesktopPane (which is just JDesktopPane that implements Scrollable)
2) Create an instance of JScrollPane, passing my JScrollableDesktopPane in
3) Setting my main JFrame's content pane (setContentPane) to the instance of JScrollPane
Am I completely off here, or am I on the right track. Any advice is greatly appreciated!