最近发布了最的Pivot的RIA技术. 估计JAVA社区看JavaFX目前来说无法与Flex,SilverLight抗衡所采取的一种折中作法. 或者有文言其为JAVA APPLET的再生. 我简单的尝试了一下,其原理也许是利用了AJAX的部分原理,使applet与service通信, 另外使用了最新改良过的 Java 6 updated 10 的applet 加速方式, 把原来慢慢吞吞的JAVA APPLET 变得能与Flex之备一争的感觉.

在客户端的代码样子如下:

<FlowPane styles="{padding:4, horizontalAlignment:'center', verticalAlignment:'center'}">
<PushButton id="pushButton" buttonData="'Click Me!'"/>
</FlowPane>

而用工具包生成的字节代码的源码为如下:

/*
 * Copyright (c) 2008 VMware, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package pivot.tutorials.buttons;
 
import pivot.wtk.Alert;
import pivot.wtk.Application;
import pivot.wtk.Button;
import pivot.wtk.ButtonPressListener;
import pivot.wtk.Component;
import pivot.wtk.Display;
import pivot.wtk.PushButton;
import pivot.wtk.Window;
import pivot.wtkx.ComponentLoader;
 
public class PushButtons implements Application {
    private Window window = null;
 
    public void startup() throws Exception {
        ComponentLoader.initialize();
        ComponentLoader componentLoader = new ComponentLoader();
 
        Component content =
            componentLoader.load("pivot/tutorials/buttons/push_buttons.wtkx");
 
        // Get a reference to the button and add a button press listener
        PushButton pushButton =
            (PushButton)componentLoader.getComponent("pushButton");
        pushButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Alert.alert(Alert.Type.INFO, "You clicked me!", window);
            }
        });
 
        window = new Window();
        window.setContent(content);
        window.getAttributes().put(Display.MAXIMIZED_ATTRIBUTE,
            Boolean.TRUE);
        window.open();
    }
 
    public void shutdown() throws Exception {
        window.close();
    }
 
    public void suspend() throws Exception {
    }
 
    public void resume() throws Exception {
    }
}

如果你安装了JRE6,可以试试它的效果,点击此处

continue reading.....