spinningcube/src/main/java/org/apidesign/demo/spinningcube/Main.java
author Jaroslav Tulach <jtulach@netbeans.org>
Tue, 13 Aug 2013 21:19:31 +0200
changeset 45 3f85884ca049
parent 42 77d278ed1499
permissions -rw-r--r--
Prevent running on JDK7 - the WebView implementation on JDK7 is not good enough for CSS animations
jtulach@39
     1
/**
jtulach@39
     2
 * The MIT License (MIT)
jtulach@39
     3
 *
jtulach@39
     4
 * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jtulach@39
     5
 *
jtulach@39
     6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
jtulach@39
     7
 * of this software and associated documentation files (the "Software"), to deal
jtulach@39
     8
 * in the Software without restriction, including without limitation the rights
jtulach@39
     9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jtulach@39
    10
 * copies of the Software, and to permit persons to whom the Software is
jtulach@39
    11
 * furnished to do so, subject to the following conditions:
jtulach@39
    12
 *
jtulach@39
    13
 * The above copyright notice and this permission notice shall be included in
jtulach@39
    14
 * all copies or substantial portions of the Software.
jtulach@39
    15
 *
jtulach@39
    16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jtulach@39
    17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jtulach@39
    18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jtulach@39
    19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jtulach@39
    20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jtulach@39
    21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jtulach@39
    22
 * THE SOFTWARE.
jtulach@39
    23
 */
jtulach@39
    24
package org.apidesign.demo.spinningcube;
jtulach@39
    25
jtulach@39
    26
import net.java.html.boot.BrowserBuilder;
jtulach@39
    27
jtulach@39
    28
jtulach@39
    29
/** Bootstrap and initialization.
jtulach@39
    30
 * 
jtulach@39
    31
 * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jtulach@39
    32
 */
jtulach@39
    33
public final class Main {
jtulach@39
    34
    private Main() {
jtulach@39
    35
    }
jtulach@39
    36
    
jtulach@39
    37
    /** Launches the browser */
jtulach@39
    38
    public static void main(String... args) throws Exception {
jtulach@45
    39
        try {
jtulach@45
    40
            Class.forName("java.lang.FunctionalInterface");
jtulach@45
    41
        } catch (ClassNotFoundException classNotFoundException) {
jtulach@45
    42
            throw new IllegalStateException("This application does not run on JDK7, use at least JDK8");
jtulach@45
    43
        }
jtulach@39
    44
        BrowserBuilder.newBrowser().
jtulach@39
    45
            loadPage("pages/index.html").
jtulach@39
    46
            loadClass(Main.class).
jtulach@39
    47
            invoke("initialize", args).
jtulach@39
    48
            showAndWait();
jtulach@39
    49
        System.exit(0);
jtulach@39
    50
    }
jtulach@39
    51
    
jtulach@39
    52
    /** Called when page is ready */
jtulach@39
    53
    public static void initialize(String... args) throws Exception {
jtulach@39
    54
        Data d = new Data();
jtulach@42
    55
        d.setMessage("Hello World from HTML and Java!");
jtulach@39
    56
        d.applyBindings();
jtulach@39
    57
    }
jtulach@39
    58
}