AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JScrollPane doesn't scroll a JPanel?

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Mark Murphy
Guest





PostPosted: Wed Nov 19, 2003 12:00 am    Post subject: JScrollPane doesn't scroll a JPanel? Reply with quote



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
JPanels.

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!

Mark Murphy
mmurphy000 -at- yahoo.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.