a***e 发帖数: 188 | 1 I'd like to scroll an JInternalFrame. I add a panel into this frame.
In the panel there is an image which dimension is larger than the
internalframe. I then create a Jscrollpane to accomodate the panel I
add,
but it doesn't work.
Your help will be highly appreciated! |
o**n 发帖数: 31 | 2 you need to setPreferredSize of JScrollPane.
【在 a***e 的大作中提到】 : I'd like to scroll an JInternalFrame. I add a panel into this frame. : In the panel there is an image which dimension is larger than the : internalframe. I then create a Jscrollpane to accomodate the panel I : add, : but it doesn't work. : Your help will be highly appreciated!
|
a***e 发帖数: 188 | 3 I have tried this just now, but it still doesn't work. I add the
JScrollPanel
instead of JPanel to the internalframe, right?
Do I need to add scrollbar by myself?
Thanks a lot.
frame.
the
I
【在 o**n 的大作中提到】 : you need to setPreferredSize of JScrollPane.
|
o**n 发帖数: 31 | 4 right.
I mean, you first add JScrollPane, and set its size, then
add a larger JPanel. Then add your JSP to the container.
should be ok.
【在 a***e 的大作中提到】 : I have tried this just now, but it still doesn't work. I add the : JScrollPanel : instead of JPanel to the internalframe, right? : Do I need to add scrollbar by myself? : Thanks a lot. : : frame. : the : I
|
a***e 发帖数: 188 | 5 Thanks a lot. Could you please tell me whether I should add
scrollbar manually
on JSP or on my own JPanel? or it can appear automatically?
In addition, should I set the size of JPanel?
Thank you again.
【在 o**n 的大作中提到】 : right. : I mean, you first add JScrollPane, and set its size, then : add a larger JPanel. Then add your JSP to the container. : should be ok.
|
o**n 发帖数: 31 | 6 it depends, generally you can let JSP determine the scrollbar
automatically.
For JPanel, if you like, you can setsize, really depends.
【在 a***e 的大作中提到】 : Thanks a lot. Could you please tell me whether I should add : scrollbar manually : on JSP or on my own JPanel? or it can appear automatically? : In addition, should I set the size of JPanel? : Thank you again.
|
a***e 发帖数: 188 | 7 Thanks a lot for your patient reply. But my problem is that I think
the scrollbar should appear(since the Image in JPanel is much larger
than the JPanel and JScrollPanel), but it doesn't.
The other question is that I need to locate some rectangles in the
image. What coordinate system is valid? I think since the image is in
JPanel, it should be JPanel, right?
Thanks again.
【在 o**n 的大作中提到】 : it depends, generally you can let JSP determine the scrollbar : automatically. : For JPanel, if you like, you can setsize, really depends.
|
a***e 发帖数: 188 | 8 The following is my code. It still doesn't work. In myPanel, I draw
an image.
myPanel.setLayout(null);
JScrollPane scroll = new JScrollPane();
scroll.setPreferredSize(new Dimension(100,100));
scroll.add(myPanel);
(imframe.getContentPane()).add(scroll);
Thanks.
【在 o**n 的大作中提到】 : it depends, generally you can let JSP determine the scrollbar : automatically. : For JPanel, if you like, you can setsize, really depends.
|
o**n 发帖数: 31 | 9 good luck, try below.
^^^^try new BorderLayout()
^^new JScrollPane(myPanel);
【在 a***e 的大作中提到】 : The following is my code. It still doesn't work. In myPanel, I draw : an image. : : myPanel.setLayout(null); : JScrollPane scroll = new JScrollPane(); : scroll.setPreferredSize(new Dimension(100,100)); : scroll.add(myPanel); : (imframe.getContentPane()).add(scroll); : Thanks.
|
z****u 发帖数: 15 | 10
think
in
Correct. The scrollpane is basically a viewport of the underlying
component you want to display. Of course the component's size is
bigger than the view port because that's the sole reason of the
scrollpane's existence. So if your rectangle is relative to the
underlying component, then you should use the component's coordinate
system.
I think the problem here is you did not set the SIZE OF YOUR IMAGE
PANEL (not the scrollpane. There's no need to set the size of the
scrollpane because by
【在 a***e 的大作中提到】 : The following is my code. It still doesn't work. In myPanel, I draw : an image. : : myPanel.setLayout(null); : JScrollPane scroll = new JScrollPane(); : scroll.setPreferredSize(new Dimension(100,100)); : scroll.add(myPanel); : (imframe.getContentPane()).add(scroll); : Thanks.
|