iamaamir

JqueryUI Launcher

Jun 16th, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.08 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.scene.Scene;
  3. import javafx.scene.layout.StackPane;
  4. import javafx.scene.web.*;
  5. import javafx.stage.Stage;
  6.  
  7. public class JQERYUILauncher extends Application {
  8.  
  9.     Scene createScene() {
  10.         final WebView webView = new WebView();
  11.         webView.getEngine().loadContent(getInlineHtml(Theme.excitebike, "minDate: '-0d', maxDate: '+0m +2w'", null, null));
  12.         Scene scene = new Scene(new StackPane(webView), 400, 350);
  13.         return scene;
  14.     }
  15.  
  16.     @Override
  17.     public void start(Stage stage) {
  18.         stage.setScene(createScene());
  19.         stage.sizeToScene();
  20.         stage.show();
  21.     }
  22.     //JQueryUI Themes
  23.     enum Theme {
  24.  
  25.         base("base"), blacktie("black-tie"), blitzer("blitzer"), cupertino("cupertino"), dotluv("dot-luv"),
  26.         excitebike("excite-bike"), hotsneaks("hot-sneaks"), humanity("humanity"), mintchoc("mint-choc"),
  27.         redmond("redmond"), smoothness("smoothness"), southstreet("south-street"), start("start"), swankypurse("swanky-purse"),
  28.         trontastic("trontastic"), uidarkness("ui-darkness"), uilightness("ui-lightness"), vader("vader");
  29.  
  30.         final private String themeName;
  31.  
  32.         Theme(String themeName) {
  33.             this.themeName = themeName;
  34.         }
  35.  
  36.         @Override
  37.         public String toString() {
  38.             return themeName;
  39.         }
  40.     }
  41.     //Basic Design
  42.     private String getInlineHtml(Theme theme, String initJavaScript, String customCSS, String googleCdnApiKey) {
  43.         return "<!DOCTYPE html>"
  44.                 + "<html lang=\"en\">"
  45.                 + "<head>"
  46.                 + "<meta charset=\"utf-8\">"
  47.                 + "<title>jQuery UI Datepicker - Display inline</title>"
  48.                 + (googleCdnApiKey != null ? ("<script type=\"text/javascript\" src=\"https://www.google.com/jsapi?key=" + googleCdnApiKey + "\"></script>") : "")
  49.                 + "<link rel=\"stylesheet\" href=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/" + theme + "/jquery-ui.css\">"
  50.                 + "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://yui.yahooapis.com/3.4.1/build/cssreset/cssreset-min.css\">"
  51.                 + "<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\"></script>"
  52.                 + "<script src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js\"></script>"
  53.                 + "<style type=\"text/css\">#ui-datepicker-div {display: none;} " + (customCSS != null ? customCSS : "") + "</style>"
  54.                 + "<script>"
  55.                 + "$(function() {"
  56.                 + "$(\"#datepicker\").datepicker({"
  57.                 + "onSelect: function(dateText, inst) { alert(dateText); }"
  58.                 + (initJavaScript != null ? ("," + initJavaScript) : "")
  59.                 + "});"
  60.                 + "});"
  61.                 + "</script>"
  62.                 + "</head>"
  63.                 + "<body><span id=\"datepicker\"></span></body>"
  64.                 + "</html>";
  65.     }
  66.  
  67.     public static void main(String[] args) {
  68.         Application.launch(args);
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment