Pivot Starter Kit Launched
To help developers get up and running with Pivot more quickly, we've posted a Pivot "starter kit" at pivot-toolkit.org. This zip file contains everything required to build and launch a simple Pivot application on the desktop or in a web browser:
To build, run ant from this directory. To run as an applet, load index.html in a web browser. To run as a desktop application, run starter.sh (UNIX) or starter.bat (Windows) from a command prompt (UNIX users may need to assign execute permissions to the launch script).
Content of starter_application.wtkx:
<?xml version="1.0" encoding="UTF-8"?>
<Window title="Pivot Starter Application"
xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008" xmlns="pivot.wtk">
<content>
<FlowPane styles="{padding:4, horizontalAlignment:'center', verticalAlignment:'center'}">
<PushButton wtkx:id="pushButton" buttonData="Click Me!"/>
</FlowPane>
</content>
</Window>
Content of StarterApplication.java:
package pivot.starter;
import pivot.collections.Dictionary;
import pivot.wtk.Alert;
import pivot.wtk.Application;
import pivot.wtk.Button;
import pivot.wtk.ButtonPressListener;
import pivot.wtk.Display;
import pivot.wtk.MessageType;
import pivot.wtk.PushButton;
import pivot.wtk.Window;
import pivot.wtkx.WTKXSerializer;
public class StarterApplication implements Application {
private Window window = null;
public void startup(Display display, Dictionary<String, String> properties) throws Exception {
// Load the WTKX source
WTKXSerializer wtkxSerializer = new WTKXSerializer();
window = (Window)wtkxSerializer.readObject("pivot/starter/starter_application.wtkx");
// Get a reference to the button and add a button press listener
PushButton pushButton =
(PushButton)wtkxSerializer.getObjectByName("pushButton");
pushButton.getButtonPressListeners().add(new ButtonPressListener() {
public void buttonPressed(Button button) {
Alert.alert(MessageType.INFO, "Welcome to Pivot!", window);
}
});
// Open the window
window.setMaximized(true);
window.open(display);
}
public boolean shutdown(boolean optional) {
// Close the window and exit
window.close();
return true;
}
public void suspend() {
}
public void resume() {
}
}
Requires Ant 1.7 and Java 5 or later to build.
| Attachment | Size |
|---|---|
| pivot-starter-kit.png | 32.62 KB |
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Frederico Rodri... replied on Wed, 2010/10/27 - 11:28am