|
-
Sep 30th, 2003, 04:24 PM
#1
Thread Starter
Addicted Member
Scroll a JPanel
Hi
Is there a way to make a JPanel scroll. I know it can be done using the JViewPort and JScrollbars, and implementing the JScrollable interface, but does anyone have anything like that already that i might be able to use. I guess i'm being lazy, but i'm also short on time.
I need to be able to scroll a panel, because on that i'm creating shapes, that are dynamically made and added, thus if the height of the total shapes changes, then it goes off the panel.
If the Jpanel is not scrollable, are there alternatives to this probelm?
Any input is appreciated..Thanx in advance
--770
-
Sep 30th, 2003, 04:39 PM
#2
Thread Starter
Addicted Member
I should really do some more research before posting and asking the question...
you can just apply a JPanel to a JScrollPane... ...
-770
-
Oct 5th, 2003, 01:46 PM
#3
Thread Starter
Addicted Member
back to this question...
i'm trying to add labels to this Jpanel, but it won't seem to show them..
(this is an applet)
so in the init() if i do
Code:
JLabel lblTest;
lblTest = new JLabel("TESTING");
panel.add(stackObject);
it works
but if i do the same code in any other method the label doesn't show up on the panel. i've tried to do panel.repaint(), which does nothing
this jpanel is connected to a jscrollpane (not sure if i have to do anything diff for the components to show up....i can add all the stuff i want in the init() method, but if i put the same code in a diff method, it doesn't work........ HELPPP
--770
-
Oct 6th, 2003, 01:52 AM
#4
Try to call panel.invalidate() or something like that before repaint.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 6th, 2003, 04:08 PM
#5
Thread Starter
Addicted Member
yes, i got it
i used revalidate(); and it works fine
but in other places i'm using repaint();...i tried replacing those places with revalidate(), but that doesn't work...
very werid...not sure why that is....
so it's a matter of trial and error of which one work for that particular code or component... which programming shouldn't be....lol
--770
-
Dec 9th, 2003, 04:56 AM
#6
Frenzied Member
Try setting the Layout Manager before u add any component to the panel..
To add into the scrollpane..
JScrollPane jp = new JScrollPane(myPanel);
then add jp to the main container...
and that should be enough...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|