You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Denis Kononenko <de...@yahoo.com> on 2009/09/14 13:18:24 UTC

Layout managers

Hi,

i create example application

mainframe.java
--------------
package ru.kononenko.pivot1;

import java.io.IOException;

import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.collections.Map;
import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtkx.WTKXSerializer;

public class MainFrame implements Application {
    private Window wnd = null;
    
    @Override
    public void startup(Display display, Map<String, String> map) throws IOException,
                                                        SerializationException {
        WTKXSerializer serializer = new WTKXSerializer();
        wnd = (Window)serializer.readObject(this, "gui.wtkx");
        wnd.open(display);
    }

    @Override
    public boolean shutdown(boolean b) {
        if (wnd != null) {
            wnd.close();
        }        
        return false;
    }

    @Override
    public void suspend() {
    }

    @Override
    public void resume() {
    }
    
    public static void main(String[] args) {
        DesktopApplicationContext.main(MainFrame.class, args);
    }
}

gui.wtkx
--------
<?xml version="1.0" encoding="UTF-8"?>

<Window title="Menus" maximized="true" xmlns:wtkx="http://pivot.apache.org/wtkx"
        xmlns:content="org.apache.pivot.wtk.content" xmlns="org.apache.pivot.wtk">

    <content>
        <BoxPane orientation="vertical" styles="{verticalAlignment:'center', backgroundColor: '#FFFF00'}">
            <PushButton buttonData="Press me"/>
        </BoxPane>
    </content>
</Window>



How maximize button on full window.
how to stretch the button vertically?

TablePane: how to stretch the row 100% with table


Thanks.



      


Re: Layout managers

Posted by Vicente de Rivera III <th...@gmail.com>.
If the Label is contained in a TablePane (even if the Label is contained in
a BoxPane w/c is contained by the TablePane), the column where it is located
should have a width or 1*, it won't work if it's -1

btw, took me sometime to figure out that wrapText for Labels that has a
> parent BoxPane, works only if the parent BoxPane has an orientation and the
> style fill:true
>

Re: Layout managers

Posted by Todd Volkert <tv...@gmail.com>.
If you're using table panes with only 1 row and column, then perhaps you
don't need them at all - can you send a snippet of WTKX so we can have a
look at your specific case?

On Thu, Oct 1, 2009 at 4:03 AM, Vicente de Rivera III <
thirdy.derivera@gmail.com> wrote:

> How about a BoxPane that fills both vertically and horizontally? The same
> as a TablePane with 1* width column and a couple of 1* height row.
>
> Right now in my code, I have lots of TablePane code, I was hoping if
> there's a better way.
>
> btw, took me sometime to figure out that wrapText for Labels that has a
> parent BoxPane, works only if the parent BoxPane has an orientation and the
> style fill:true
>

Re: Layout managers

Posted by Greg Brown <gk...@mac.com>.
BoxPane actually used to support that behavior, but it was refactored out in Pivot 1.3 since it was superfluous (TablePane is a better way to achieve this type of layout).

G
 
On Thursday, October 01, 2009, at 04:03AM, "Vicente de Rivera III" <th...@gmail.com> wrote:
>

Re: Layout managers

Posted by Vicente de Rivera III <th...@gmail.com>.
How about a BoxPane that fills both vertically and horizontally? The same as
a TablePane with 1* width column and a couple of 1* height row.

Right now in my code, I have lots of TablePane code, I was hoping if there's
a better way.

btw, took me sometime to figure out that wrapText for Labels that has a
parent BoxPane, works only if the parent BoxPane has an orientation and the
style fill:true

Re: Layout managers

Posted by Todd Volkert <tv...@gmail.com>.
> How maximize button on full window.
>

If you want the button to take up the whole space of the window, you could
just set it as the content of the window:

 <Window title="Menus" maximized="true" xmlns:wtkx="
http://pivot.apache.org/wtkx"
       xmlns:content="org.apache.pivot.wtk.content"
xmlns="org.apache.pivot.wtk">
   <content>
       <PushButton buttonData="Press me"/>
   </content>
</Window>

how to stretch the button vertically?
>

I'd use a horizontal BoxPane with the "fill" style set to true:

 <Window title="Menus" maximized="true" xmlns:wtkx="
http://pivot.apache.org/wtkx"
       xmlns:content="org.apache.pivot.wtk.content"
xmlns="org.apache.pivot.wtk">
   <content>
       <BoxPane orientation="horizontal" styles="{fill:true,
backgroundColor: '#FFFF00'}">
           <PushButton buttonData="Press me"/>
       </BoxPane>
   </content>
</Window>


> TablePane: how to stretch the row 100% with table
>

The components in the row will be as wide as their column.  To get a column
to take up the available space in the table pane, use a relative width.

For example, this table pane's sole column has a relative width of 1 (1*),
meaning it'll take up all the available space of the table pane.  As such,
the button takes up all of that width.

<Window title="Menus" maximized="true" xmlns:wtkx="
http://pivot.apache.org/wtkx"
       xmlns:content="org.apache.pivot.wtk.content"
xmlns="org.apache.pivot.wtk">
   <content>
       <TablePane styles="{backgroundColor: '#FFFF00'}">
           <columns>
               <TablePane.Column width="1*"/>
           </columns>
           <rows>
               <TablePane.Row height="-1">
                   <PushButton buttonData="Press me"/>
               </TablePane.Row>
           </rows>
       </TablePane>
   </content>
</Window>

But in the following example, we change the column's width to be default
(-1), meaning that it's only as wide as it needs to be.  As such, the column
is just wide enough to give the button its preferred width.

<Window title="Menus" maximized="true" xmlns:wtkx="
http://pivot.apache.org/wtkx"
       xmlns:content="org.apache.pivot.wtk.content"
xmlns="org.apache.pivot.wtk">
   <content>
       <TablePane styles="{backgroundColor: '#FFFF00'}">
           <columns>
               <TablePane.Column width="-1"/>
           </columns>
           <rows>
               <TablePane.Row height="-1">
                   <PushButton buttonData="Press me"/>
               </TablePane.Row>
           </rows>
       </TablePane>
   </content>
</Window>

I'd check out the not-yet-public table pane tutorial at
http://incubator.apache.org/pivot/1.3/tutorials/table_panes.html for more
info.

Hope that helps,
-T