Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!

Greg has posted 18 posts at DZone. You can read more from them at their website. View Full User Profile

Pivot Starter Kit Launched

10.21.2008
Email
Views: 2659
  • submit to reddit

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.

AttachmentSize
pivot-starter-kit.png32.62 KB
0
Published at DZone with permission of its author, Greg Brown.

(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

Hi all ... How do i get the Pivot toolkit ? Those links are broken... ;) Thanks in advance!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.