Like separators, borders are used to visually partition application content. Like Separator, the Border class provides an optional title property that can be used to assign a heading to the border. However, unlike separators, borders are containers. A border accepts a single content component that it sizes to fit its available client area.
The example below shows two Border components, each of which contains a label. The border on the left has a title and showcases the default border style. The border on the left has no title and applies some custom style values:
The WTKX for this example is shown below:
<Window title="Borders" maximized="true" xmlns:wtkx="http://pivot.apache.org/wtkx" xmlns="org.apache.pivot.wtk"> <content> <TablePane styles="{horizontalSpacing:10}"> <columns> <TablePane.Column width="1*"/> <TablePane.Column width="1*"/> </columns> <rows> <TablePane.Row height="1*"> <Border title="Border 1"> <content> <Label text="Default border with title" styles="{horizontalAlignment:'center', verticalAlignment:'center', wrapText:true}"/> </content> </Border> <Border styles="{color:'#ff0000', titleColor:'#000000', thickness:10, cornerRadii:20}"> <content> <Label text="Custom border with 10-pixel thick red border, rounded corners, and no title" styles="{horizontalAlignment:'center', verticalAlignment:'center', wrapText:true}"/> </content> </Border> </TablePane.Row> </rows> </TablePane> </content> </Window>
The Java source simply serves to load the WTKX:
package org.apache.pivot.tutorials.layout; import org.apache.pivot.collections.Map; 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 Borders implements Application { private Window window = null; public void startup(Display display, Map<String, String> properties) throws Exception { WTKXSerializer wtkxSerializer = new WTKXSerializer(); window = (Window)wtkxSerializer.readObject(this, "borders.wtkx"); window.open(display); } public boolean shutdown(boolean optional) { if (window != null) { window.close(); } return false; } public void suspend() { } public void resume() { } public static void main(String[] args) { DesktopApplicationContext.main(Borders.class, args); } }
Next: Stack Panes