Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2005

Tip: Looking for answers? Try searching our database.

Problem with glasspane on JScrollPane

Thread view: 
Anthony Mak - 29 Sep 2005 06:56 GMT
I have a JApplet inside a JScrollPane and I am drawing on the glasspane
which I get from the JApplet,

glasspane

V
JApplet

V
JScrollPane

The problem is, sometimes my scrollbars are not visible, and sometimes
when I scroll on either the vertical or horizontal scrollbar, the other
one is covered by the glasspane. And sometimes the glasspane covers
part of the toolbar at the top. I don't understand why the glasspane
can cover the scrollpane or the toolbar because my glasspane is gotten
from the japplet which is INSIDE my scrollpane which is inside my
JFrame.

Please help.
Merci. Arigatou.

Anthony Mak
Roedy Green - 29 Sep 2005 07:37 GMT
>The problem is, sometimes my scrollbars are not visible, and sometimes
>when I scroll on either the vertical or horizontal scrollbar, the other
[quoted text clipped - 3 lines]
>from the japplet which is INSIDE my scrollpane which is inside my
>JFrame.

I have no glasspane experience, but perhaps you want to get the
glasspane of the JScrollPane instead.

Your fiddlings perhaps require some repainting elsewhere?

Are you tying up the Swing thread?

Are you poking Swing components with the wrong thread?

Without code it is hard to tell what the matter could be.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Anthony Mak - 30 Sep 2005 05:52 GMT
Thanks for the quick reply, Roedy.

> I have no glasspane experience, but perhaps you want to get the
> glasspane of the JScrollPane instead.

The problem is JScrollPane doesn't have a getglasspane() method.
So I am creating a dummy JApplet (which has getglasspane() ), and
putting it inside my JScrollPane.

> Your fiddlings perhaps require some repainting elsewhere?

I presume the code handling the JScrollPane should handle
the repainting of any componenets inside itself.

> Are you tying up the Swing thread?

What do you mean tying the thread?

> Are you poking Swing components with the wrong thread?

My application doesn't not use thread.

> Without code it is hard to tell what the matter could be.

CODE:

This shows how I put a graph object inside an japplet inside a
jscrollpane inside a jframe. And I get a glasspane from the japplet for
painting purpose.

   dummy_container = new JApplet(); //Need to put graph into a dummy
applet to get a glasspane. So that can draw custom tooltip onto this
glasspane.
   dummy_container.getContentPane().add(graph); //Put jgraph inside an
applet in order to get a glasspane to draw custom tooltip
   glasspane = (JPanel) dummy_container.getGlassPane();
   glasspane.setVisible(true);
   glasspane.setLayout(null);
   scrollpane = new JScrollPane(new JPanel().add(dummy_container));

scrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

scrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
   main_pane.add(scrollpane, BorderLayout.CENTER);

I know using a dummy japplet in order to get a glasspane is not very
clean. :)

Anthony

> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.
Roedy Green - 30 Sep 2005 07:20 GMT
>> Are you tying up the Swing thread?
>
>What do you mean tying the thread?

see http://mindprod.com/jgloss/thread.html
http://mindprod.com/jgloss/threadsafe.html
http://mindprod.com/jgloss/swing.html

Basically there two errors can make that will tie up the Swing thread
so it can't attend to painting, events, keystrokes etc.

1. sleep

2. do some lengthy task in an event handler.  Instead spin it off as
its own Thread, being careful to poke any Swing components via
invokeLater on your new thread. see SwingWorker in the Thread entry to
do that neatly.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.