pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David McNelis" <Dmcne...@sharedmarketing.com>
Subject RE: Trouble adding components dynamically
Date Mon, 01 Mar 2010 15:02:50 GMT
Hopefully this doesn't get too jacked up in email, but here is an
excerpt of the code and the wtkx files that I'm using.    I also tried
just adding a test label to the containerPane as well and that did not
show up either.  But if I wtkx:include the child component as a child of
the "containerPane" then the child component does display.

 

Code:

 

containerPane = (BoxPane)parentSerializer.get("containerPane");

 

for(int i=0, n=array.getLength(); i<n; i++){            

                WTKXSerializer wtkx = new WTKXSerializer();

                BoxPane singlePane = null;

 

                try {

                                singlePane =
(BoxPane)wtkx.readObject(this, "child.wtkx");

                } catch (IOException e) {

                                                                

                                e.printStackTrace();

                } catch (SerializationException e) {

                                                

                                e.printStackTrace();

                }

                                

                singlePane.setVisible(true);

                                

                containerPane.add(singlePane);

}

 

 

Parent component:

 

<Border xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk" preferredWidth="800" preferredHeight="600">

                

<content>

 

<ScrollPane horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill">

 

                <view>

 

                                <BoxPane orientation="vertical"
wtkx:id="containerPane">

                </BoxPane>

</view></ScrollPane></content></Border>

 

Child component:

 

<BoxPane xmlns:wtkx="http://pivot.apache.org/wtkx" 

xmlns="org.apache.pivot.wtk" preferredWidth="800" preferredHeight="600"
orientation="vertical">   

 

<BoxPane orientation="vertical" wtkx:id="childPane">

 

                                

<BoxPane orientation="horizontal">

                                <Label text="Blah blah"></Label>

                                <ListButton
wtkx:id="button1"></ListButton>

                                <Label text="Blah blah:"></Label>

                                <ListButton
wtkx:id="button2"></ListButton>

                </BoxPane>

                <BoxPane orientation="vertical">

                <Label text="Filler:"></Label>

 

                <Border>

                <content>

                <ScrollPane preferredHeight="25"

                                horizontalScrollBarPolicy="fill"

 
verticalScrollBarPolicy="fill_to_capacity">

                <view>

                <TextArea wtkx:id="textarea1"

                                preferredWidth="600" text="Sample Text">

                </TextArea>

                </view>

                </ScrollPane>

                </content>

                </Border>

                </BoxPane>

                <BoxPane orientation="vertical">

                <Label text="More stuff:"></Label>

 

                <Border>

                <content>

                <ScrollPane preferredHeight="100"

                horizontalScrollBarPolicy="fill"

                verticalScrollBarPolicy="fill_to_capacity">

                <view>

                                <TextArea wtkx:id="textarea2"

                                                preferredWidth="600"
text="Sample Text">

                                </TextArea>

                </view>

                </ScrollPane>

                </content>

                </Border>

</BoxPane>

</BoxPane>

</BoxPane>

 

From: Greg Brown [mailto:gkbrown@mac.com] 
Sent: Monday, March 01, 2010 8:40 AM
To: user@pivot.apache.org
Subject: Re: Trouble adding components dynamically

 

That sounds like it should work. Can you provide some sample code? That
might help identify the issue.

 

On Mar 1, 2010, at 9:28 AM, David McNelis wrote:





Morning,

 

I have a situation where I am cycling through an array and for each
element in the array I need to add a set of components to a BoxPane.  To
do this, I wrote a wtkx file that contained the components that I need
to create each time I go through the array.  As I go through an
iteration I read in the wtkx file with a WTKXSerializer.readObject,
casting into another BoxPane, then attempt to add the new object to my
parent.  Essentially like so:

 

WTKXSerializer wtkx = new WTKXSerializer();

BoxPane child = (BoxPane) wtxk.readObject(this,"myfile.wtkx");

 

parent.add(child);

 

This as I go through my application I get no errors, no warnings, but
myfile.wtkx does not actually display.  I tried doing something akin to
child.setVisible(true), but it hasn't made any difference. 

 

I thought that maybe there was an issue with my parent BoxPane, so I
tried including myfile.wtkx as a wtkx:include parameter in the parent
file, and to my surprise the components in myfile.wtkx displayed as I
would have expected it to using the programmatic method.  Am I doing
something clearly wrong?  Is there likely an issue with my parent or
child wtkx file that I should be looking for?

 

Also, the parent.add(child) is executing...its not like I never get to
that block of code...feel like I need to mention that since it's the
first thing that comes to mind as a simple issue.

 

Thanks for any thoughts.

 

David

 

 

 


Mime
View raw message