I would like to make auto scroll down in my container, how can I do that? This container shuldn't be focusable. I have heard about something like scrollRectToVisible, but I didn't realise how it works in some example. Could you help me?
Ok, mayby another question. There is possible to set max size for container? I mean, max visible size? Because althaugh my container is scrollable, it stretch to the whole display. If I put this to a Form, with BorderLayout to Centre, it will fill the BorderLayout.North area too. And of course, why if I set rect which I want to visible, it doesn't work? Everytime, it scroll down, just I except, but it also streched in vertical. For example, my component(container) at first occupy dimension (100,200). So my rect to visible is 0,0,100,200. To scroll down, when my container have dimension (100,400), I set my rect to (0,200,100,200), so I expect to see bottom part of my component. But that doesn't happen. I see bottom part, but unfortunately vissible is for example rect (0,100,100,300). So my container curtain the other component in my Form. There is any possible solution? Sorry for spam, but this is very important to me. Withaut this, I cant continue my project :(
"If I put this to a Form, with BorderLayout to Centre, it will fill the BorderLayout.North area too."
Something else must be wrong here - BorderLayout is designed to stretch the CENTER to fill all unused areas - if it's filling the NORTH, then it must be empty.
maybe as a test, leave out the CENTER and see if the NORTH shows up
"if it's filling the NORTH, then it must be empty."
maybe you are painting over it
[b]EDIT:[/b] Omg, now I know what is wrong. I have forgotten to invoke this.setScrollable(true). That is default to Form but not to my container :)
Message was edited by: iluminacja
I did that functionality in very simple way, but I am not sure that it is enough eficient. Here is my code :
public void scrollDown()
rect = new Rectangle(getScrollX(), getScrollY(), getWidth(), this.getLayoutHeight());
But, I supposse that in this way I repaint whole content pane but it is not necessary, because I see only part of it. So, if I calculated parameters to rect, wchich are already visible, and then use repaint() it would be more efficient?
You will always need to repaint the entire form when scrolling it.
Hi , I am exhausted looking for answer to my question. Functionality which I made works, but only if this container is the only one component in my Form. If I i add three Component in this way
south component works (to be honest, I dont know why), but north component is hiden by container. Could someone help me to solve this problem? And of course if its necessary to understand my problem, I can write here my code. And how use or maybe how override method scrollRectToVisible()?
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.