 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Anthony Mak Guest
|
Posted: Thu Sep 29, 2005 5:56 am Post subject: Problem with glasspane on JScrollPane |
|
|
I have a JApplet inside a JScrollPane and I am drawing on the glasspane
which I get from the JApplet,
glasspane
JApplet
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
|
|
| Back to top |
|
 |
Roedy Green Guest
|
Posted: Thu Sep 29, 2005 6:37 am Post subject: Re: Problem with glasspane on JScrollPane |
|
|
On 28 Sep 2005 22:56:08 -0700, "Anthony Mak" <anthony.mak (AT) iname (DOT) com>
wrote or quoted :
| Quote: | 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.
|
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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
| Back to top |
|
 |
Anthony Mak Guest
|
Posted: Fri Sep 30, 2005 4:52 am Post subject: Re: Problem with glasspane on JScrollPane |
|
|
Thanks for the quick reply, Roedy.
Roedy Green wrote:
| Quote: |
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.
| Quote: |
Your fiddlings perhaps require some repainting elsewhere?
|
I presume the code handling the JScrollPane should handle
the repainting of any componenets inside itself.
| Quote: |
Are you tying up the Swing thread?
|
What do you mean tying the thread?
| Quote: |
Are you poking Swing components with the wrong thread?
|
My application doesn't not use thread.
| Quote: |
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
| Quote: |
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
|
| Back to top |
|
 |
Roedy Green Guest
|
Posted: Fri Sep 30, 2005 6:20 am Post subject: Re: Problem with glasspane on JScrollPane |
|
|
On 29 Sep 2005 21:52:20 -0700, "Anthony Mak" <anthony.mak (AT) iname (DOT) com>
wrote or quoted :
| Quote: | 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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
| Back to top |
|
 |
|
|
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
|
|