pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brendan cheng <ccp...@hotmail.com>
Subject RE: How to dynamically add component to window
Date Sat, 17 Sep 2011 10:07:13 GMT

Chris,
Thanks so much and it works!
Actually, I was trying to inject a series of box pane from the bxml files.  Do I have to use
the bxml Serializer repeatedly?Or do I have to use java code instead of?  how to handle the
variables in BXML because they have the same names.?
Brendan 
> Date: Sat, 17 Sep 2011 16:27:47 +0700
> Subject: Re: How to dynamically add component to window
> From: cbartlett.x@gmail.com
> To: user@pivot.apache.org
> 
> Brendan,
> 
> I think this is your problem.
> >         rightScrollPane.add(commentPane);
> 
> Try replacing it with
> rightScrollPane.setView(commentPane);
> 
> 
> Some background if you are interested ...
> 
> ScrollPane is an instance of ViewPort, which is in turn an instance of
> Container. http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/ScrollPane.html
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Viewport.html
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Container.html
> 
> Some Containers (like BoxPane) simply display whatever child
> Components were added to the Sequence<Component> that Container
> provides.
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/BoxPane.html
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/collections/Sequence.html
> 
> Others Containers (like ScrollPane) are a little more complex and can
> display additional UI elements.  In the case of ScrollPane, it can
> display a 'rowHeader', 'columnHeader', and 'corner' as well as a
> 'view'.
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/ScrollPane.html#setRowHeader(org.apache.pivot.wtk.Component)
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/ScrollPane.html#setColumnHeader(org.apache.pivot.wtk.Component)
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/ScrollPane.html#setCorner(org.apache.pivot.wtk.Component)
> http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Viewport.html#setView(org.apache.pivot.wtk.Component)
> 
> ScrollPane therefore needs to manage the Sequence<Component> provided
> by Container, so you need to tell it what to do with the Components
> that you give to it, rather than adding them to the
> Sequence<Component> directly (which is what
> rightScrollPane.add(commentPane) looks to be doing).
> 
> In your example you want to show your 'rightScrollPane' Component as
> the ScrollPane's 'view'.
> 'view' is the default property of ScrollPane (inherited from
> ViewPort).  This is defined via the @DefaultProperty annotation.
> http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/Viewport.java
> 
> Unfortunately, the DefaultProperty annotation is not shown in the
> Pivot 2.0 Javadocs, but it is always visible in the source code.  From
> 2.0.1 (which will hopefully be released soon) the DefaultProperty
> annotation *will* be visible in the Javadocs.
> 
> Chris
> 
> 2011/9/17 Brendan cheng <ccp999@hotmail.com>:
> > Hi,
> > I must say I'm totally new to Pivot.  I'm trying add a box pane to my
> > window's scroll pane but even the code compiled properly, the box pane just
> > doesn't show up.
> > Here is the snippet from my main program.
> >
> > @Override
> >
> >     public void startup(Display display, Map<String, String> properties)
> > throws Exception {
> >
> >         String language = properties.get(LANGUAGE_KEY);
> >
> >         Locale locale = (language == null) ? Locale.getDefault() : new
> > Locale(language);
> >
> >         Resources resources = new Resources(ClientWindow.class.getName(),
> > locale);
> >
> >         BXMLSerializer bxmlSerializer = new BXMLSerializer();
> >
> >         window =
> > (ClientWindow)bxmlSerializer.readObject(getClass().getResource("client_window.bxml"),
> >
> >             resources);
> >
> >         ScrollPane rightScrollPane = (ScrollPane)
> > bxmlSerializer.getNamespace().get("rightScrollPane");
> >
> >         BoxPane commentPane = null;
> >
> >         try {
> >
> > commentPane =
> > (CommentPane)bxmlSerializer.readObject(getClass().getResource("thumbnail/comment_pane.bxml"),
> >
> >     resources);
> >
> > } catch (IOException e) {
> >
> > e.printStackTrace();
> >
> > } catch (SerializationException e) {
> >
> > e.printStackTrace();
> >
> > }
> >
> >         rightScrollPane.add(commentPane);
> >
> >         window.open(display);(display);
> >
> > What do you recommend to do this job in pivot?
> >
> > Thanks in advance!
> >
> > Brendan
 		 	   		  
Mime
View raw message