You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Yura <Yu...@yahoo.com> on 2011/12/14 23:28:30 UTC

ScrollPane does not work in the java code

Hello,

I try to use Apache Pivot by means of simple java (not high bmpeix or
whatever like bxml - very high solution).

So, when I try to construct a very simple hierarhy of conainers it simply
did not work - empty window (or overlapped labels). I tried diff variants -
all the same. Is there any human way to use Apache Pivot without  high bxml? 
The simple as a door java code of startup() here below:

        window = new Window();
        ScrollBar scrlBar = new ScrollBar();
        scrlBar.setSize(2000, 15);
        scrlBar.setPreferredSize(2000, 15);
        
        ScrollPane myScroll = new
ScrollPane(ScrollBarPolicy.AUTO,ScrollBarPolicy.AUTO);
        myScroll.setSize(1000,1000);
        myScroll.setPreferredSize(1000, 1000);
        
        myScroll.add(scrlBar);
        
        for (int i = 0; i < 20; i++) {
        	Label lbl= new Label();
        	lbl.setText("Label: "+i);
        	lbl.setSize(100, 100);
        	myScroll.add(lbl);
		}
        
        
        TabPane myTabPane = new TabPane();
        myTabPane.setSize(1000,1000);
        myTabPane.setPreferredSize(1000, 1000);
        
        
        myTabPane.add(myScroll);
        window.setContent(new Border(myTabPane));
        //window.setContent(new Border(myCalendarPane.getBgTablePane()));
        //window.setContent(new Calendar());
        window.setTitle("Hello World!");
        window.setMaximized(true);

=>No scrollbars or when they are show up they just does not respond.
Is there any pecularities of using ScrollPane in java code not in high ...?
What classes it can normally include? Which classes (containers) may
normally include it? ETC

Thank you!


--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/ScrollPane-does-not-work-in-the-java-code-tp3586952p3586952.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

RE: ScrollPane does not work in the java code

Posted by Yura <Yu...@yahoo.com>.
Hello, Roger,

Thank you for not calling me as blind as a bat. Yes, now it works. I might
have been drunk, since I was aware of <view> tag in bxml (and also that you
made it optional in recent releases) and looked through the whole
ScrollPane(Skin) classes for it, but probably not the Viewport.
That scrollbar I took from one of the examples at the tutorial site, hoping
that it would somehow help in a magical way, sure, it was not meant to be an
internal part of a ScrollPane.
Sorry, for the mood of my first msg, I spent about three hours on different
stupid combinations of containers and components comparing it with different
bxml scripts.
But you should emphasize somewhere in the tutorial at least that despite
bxml (where you need not to define <view> tag any more), you must set up the
View property of the ScrollPane (inherited from the Viewport) .

By the way, is there any bxml-editors that control the syntaxes and
misspelling at least? Because I stick to java code only because of that.

Thank you for the view-property!
Yura


--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/ScrollPane-does-not-work-in-the-java-code-tp3586952p3594408.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

RE: ScrollPane does not work in the java code

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Hello,
	First of all, thanks for trying out Pivot!
	To (hopefully) answer your question:
1) In order to use a ScrollPane, you don't need a separate ScrollBar -- it will show or hide scrollbars as needed.
2) The right way to add a "scrollable" element to a ScrollPane is to set the "view" property of ScrollPane.
3) There can only be one "view" element of a ScrollPane, so you would need to put all your Label elements into a container of some kind, such as a BoxPane.
4) Setting "preferredSize" should be all that's needed to get the component sized correctly (without setting "size" directly).

So, the final code would look something like this (haven't tested this, so it might need some tweaking):
Window window = new Window();
ScrollPane myScroll = new ScrollPane(ScrollBarPolicy.AUTO,ScrollBarPolicy.AUTO);
myScroll.setPreferredSize(1000, 1000);
BoxPane bp = new BoxPane(Orientation.VERTICAL);
for (int i=0; i < 20; i++) {
    Label lbl = new Label();
    lbl.setText("Label: "+i);
    lbl.setPreferredSize(100, 100);
    bp.add(lbl);
}
myScroll.setView(bp);
And the rest should be okay as you have it.

Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@actian.com| Actian Corp. | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 | USA  | +1 650-587-5596 | fax: +1 650-587-5550


-----Original Message-----
From: Yura [mailto:YuraBadoo@yahoo.com] 
Sent: Wednesday, December 14, 2011 2:29 PM
To: user@pivot.apache.org
Subject: ScrollPane does not work in the java code

Hello,

I try to use Apache Pivot by means of simple java (not high bmpeix or
whatever like bxml - very high solution).

So, when I try to construct a very simple hierarhy of conainers it simply
did not work - empty window (or overlapped labels). I tried diff variants -
all the same. Is there any human way to use Apache Pivot without  high bxml? 
The simple as a door java code of startup() here below:

        window = new Window();
        ScrollBar scrlBar = new ScrollBar();
        scrlBar.setSize(2000, 15);
        scrlBar.setPreferredSize(2000, 15);
        
        ScrollPane myScroll = new
ScrollPane(ScrollBarPolicy.AUTO,ScrollBarPolicy.AUTO);
        myScroll.setSize(1000,1000);
        myScroll.setPreferredSize(1000, 1000);
        
        myScroll.add(scrlBar);
        
        for (int i = 0; i < 20; i++) {
        	Label lbl= new Label();
        	lbl.setText("Label: "+i);
        	lbl.setSize(100, 100);
        	myScroll.add(lbl);
		}
        
        
        TabPane myTabPane = new TabPane();
        myTabPane.setSize(1000,1000);
        myTabPane.setPreferredSize(1000, 1000);
        
        
        myTabPane.add(myScroll);
        window.setContent(new Border(myTabPane));
        //window.setContent(new Border(myCalendarPane.getBgTablePane()));
        //window.setContent(new Calendar());
        window.setTitle("Hello World!");
        window.setMaximized(true);

=>No scrollbars or when they are show up they just does not respond.
Is there any pecularities of using ScrollPane in java code not in high ...?
What classes it can normally include? Which classes (containers) may
normally include it? ETC

Thank you!


--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/ScrollPane-does-not-work-in-the-java-code-tp3586952p3586952.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.