I've never had problems with JScrollPane like I'm running into here...
I am trying to create a Swing UI for VNC, based on the TightVNC
(http://www.tightvnc.org) applet code. The TightVNC applet is in AWT,
and so I'm trying to convert their use of Applet and Canvas to
What I have now is a JFrame (test application) containing a
JTabbedPane, each tab of which contains a JPanel (reimplementation of
their Applet subclass), which contains a JScrollPane, which contains a
JPanel (reimplementation of their Canvas subclass). The inner-most
JPanel is where the VNC image gets painted, via an Image.
The problem is, the scrollbars never show up, even if I set them to be
always on. The image displays fine, cropped to the size of the overall
JFrame. The problem also occurs if I skip the JTabbedPane and have the
JFrame directly hold my outer JPanel, so the JTabbedPane wouldn't seem
to be interefering.
The inner JPanel implements getPreferredSize(), which is returning
proper values (1024x768, the size of the screen on the VNC server) at
the time the JScrollPane is instantiated. I have tried both
JScrollPane(canvas) and scroll.setViewportView(canvas) to attach the
inner JPanel to the JScrollPane. I have tried
scroll.getViewport.setViewSize(canvas.getPreferredSize()), in case it
somehow wasn't getting the preferred size. Nothing's worked.
I am using the stock BorderLayout for the outer JPanel; the inner
JPanel overrides update(Graphics g) and paint(Graphics g) and draws
itself (via the buffered image).
Since I've never had problems like this with JScrollPane, I'm guessing
my problem is tied to the inner JPanel doing its own drawing, though
I'd expect getPreferredSize() would cover that scenario.
Anybody got any ideas? Thanks!
mmurphy000 -at- yahoo.com
||11/19/2003 12:00:33 AM