functional/SceneGraphTests/src/test/scenegraph/fullscreen/FSTestApp.java

Print this page




  27 
  28 import java.util.logging.Level;
  29 import java.util.logging.Logger;
  30 import javafx.animation.*;
  31 import javafx.application.Application;
  32 import javafx.beans.value.ChangeListener;
  33 import javafx.beans.value.ObservableValue;
  34 import javafx.event.ActionEvent;
  35 import javafx.event.Event;
  36 import javafx.event.EventHandler;
  37 import javafx.geometry.Insets;
  38 import javafx.geometry.Pos;
  39 import javafx.scene.Scene;
  40 import javafx.scene.control.*;
  41 import javafx.scene.effect.InnerShadow;
  42 import javafx.scene.input.KeyCombination;
  43 import javafx.scene.input.MouseEvent;
  44 import javafx.scene.layout.*;
  45 import javafx.scene.paint.Color;
  46 import javafx.scene.shape.Circle;
  47 import javafx.scene.shape.CircleBuilder;
  48 import javafx.scene.shape.LineBuilder;
  49 import javafx.scene.text.Text;
  50 import javafx.stage.Modality;
  51 import javafx.stage.Screen;
  52 import javafx.stage.Stage;
  53 import javafx.util.Duration;
  54 import test.javaclient.shared.Utils;
  55 
  56 /**
  57 *
  58 * @author alexander
  59 */
  60 public class FSTestApp extends Application {
  61 
  62     //if stage resizable
  63     private static boolean resizable = true;
  64 
  65 
  66     private final StringBuilder log = new StringBuilder();
  67 
  68     /**
  69     * @param args the command line arguments
  70     */
  71     public static void main(String[] args) {
  72         if((args != null) && (args.length != 0))
  73             resizable = Boolean.valueOf(args[0]);
  74 
  75         Utils.launch(FSTestApp.class, args);
  76     }
  77 
  78     @Override
  79     public void start(final Stage primaryStage) {
  80         primaryStage.setTitle("FSTestApp");
  81         primaryStage.setResizable(resizable);
  82 
  83         GridPane buttonsPane = GridPaneBuilder.create()
  84                 .padding(new Insets(10))
  85                 .alignment(Pos.CENTER)
  86                 .columnConstraints(new ColumnConstraints(200), new ColumnConstraints(200))
  87                 .rowConstraints(new RowConstraints(30), new RowConstraints(30),
  88                         new RowConstraints(30), new RowConstraints(30),
  89                         new RowConstraints(30))
  90                 .build();
  91 
  92         final TextArea logTextArea = TextAreaBuilder.create()
  93                 .editable(false)
  94                 .build();
  95 
  96         //Timer for update logTextArea
  97         Timeline updateLogTimeline = TimelineBuilder.create()
  98                 .keyFrames(new KeyFrame(Duration.seconds(0.1), new EventHandler<ActionEvent>() {
  99 


 100                     public void handle(ActionEvent t) {
 101                         logTextArea.insertText(logTextArea.getLength(), log.toString());
 102                         log.delete(0, log.length());
 103 
 104                     }
 105                 }, ( KeyValue[])null))  // cast null to suppress compiler warning
 106                 .cycleCount(-1)
 107                 .build();
 108 
 109         //<editor-fold defaultstate="collapsed" desc="Menu">
 110         MenuBar menu = MenuBarBuilder.create()
 111                 .menus(
 112                 MenuBuilder.create()
 113                     .text("_Menu1")
 114                     .onShown(new EventHandler<Event>() {
 115 
 116                         public void handle(Event t) {
 117                             log.append("Menu 1 Shown\n");
 118                         }
 119                     })
 120                     .onHidden(new EventHandler<Event>() {
 121 
 122                         public void handle(Event t) {
 123                             log.append("Menu 1 Hidden\n");
 124                         }
 125                     })
 126                     .mnemonicParsing(true)
 127                     .items(
 128                         MenuItemBuilder.create()
 129                             .mnemonicParsing(true)
 130                             .onAction(new EventHandler<ActionEvent>() {
 131 
 132                                 public void handle(ActionEvent t) {
 133                                     log.append("Menu Item 1 Action\n");
 134                                 }
 135                             })
 136                             .accelerator(KeyCombination.keyCombination("ctrl+m"))
 137                             .text("Menu _Item 1")
 138                             .build(),
 139                         MenuItemBuilder.create()
 140                             .mnemonicParsing(true)
 141                             .text("Menu I_tem 2")
 142                             .build())
 143                     .build(),
 144                 MenuBuilder.create()
 145                     .mnemonicParsing(true)
 146                     .text("M_enu2")
 147                     .onShown(new EventHandler<Event>() {
 148 
 149                         public void handle(Event t) {
 150                             log.append("Menu 2 Shown\n");
 151                         }
 152                     })
 153                     .onHidden(new EventHandler<Event>() {
 154 
 155                         public void handle(Event t) {
 156                             log.append("Menu 2 Hidden\n");
 157                         }
 158                     })
 159                     .items(
 160                         MenuItemBuilder.create()
 161                             .mnemonicParsing(true)
 162                             .text("Menu _Item 1")
 163                             .build(),
 164                         MenuItemBuilder.create()
 165                             .mnemonicParsing(true)
 166                             .text("Menu I_tem 2")
 167                             .build(),
 168                         MenuItemBuilder.create()
 169                             .mnemonicParsing(true)
 170                             .text("Menu Ite_m 3")
 171                             .build())
 172                     .build())
 173                 .useSystemMenuBar(true)
 174                 .build();
 175         //</editor-fold>
 176 
 177         //<editor-fold defaultstate="collapsed" desc="Fullscreen indicator">
 178         final Circle fullscreenIndicator =
 179                 CircleBuilder.create()
 180                 .radius(6)
 181                 .fill(Color.RED)
 182                 .effect(new InnerShadow())
 183                 .build();
 184 
 185         primaryStage.fullScreenProperty().addListener(new ChangeListener<Boolean>() {
 186 
 187             @Override
 188             public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
 189                 fullscreenIndicator.setFill(newValue.booleanValue() ? Color.GREEN : Color.RED);
 190             }
 191         });
 192         //</editor-fold>
 193 
 194         //<editor-fold defaultstate="collapsed" desc="Fullscreen false Button">
 195         Button setFSFalseButton =  ButtonBuilder.create()
 196                 .text("Set fullscreen false")
 197                 .alignment(Pos.CENTER)
 198                 .prefWidth(180)
 199                 .onMouseClicked(new EventHandler<MouseEvent>() {
 200 
 201                     @Override
 202                     public void handle(MouseEvent arg0) {
 203                         primaryStage.setFullScreen(false);
 204                     }
 205                 })
 206                 .build();
 207 
 208         buttonsPane.add(setFSFalseButton, 0, 0);
 209         //</editor-fold>
 210 
 211         //<editor-fold defaultstate="collapsed" desc="Fullscreen true Button">
 212         Button setFSTrueButton =  ButtonBuilder.create()
 213                 .text("Set fullscreen true")
 214                 .alignment(Pos.CENTER)
 215                 .prefWidth(180)
 216                 .onMouseClicked(new EventHandler<MouseEvent>() {
 217 
 218                     @Override
 219                     public void handle(MouseEvent arg0) {
 220                         primaryStage.setFullScreen(true);
 221                     }
 222                 })
 223                 .build();
 224 
 225         buttonsPane.add(setFSTrueButton, 1, 0);
 226         //</editor-fold>
 227 
 228         //<editor-fold defaultstate="collapsed" desc="Center Button">
 229         Button centerButton =  ButtonBuilder.create()
 230                 .text("Center")
 231                 .alignment(Pos.CENTER)
 232                 .prefWidth(180)
 233                 .onMouseClicked(new EventHandler<MouseEvent>() {
 234 
 235                     @Override
 236                     public void handle(MouseEvent arg0) {
 237                         primaryStage.centerOnScreen();
 238                     }
 239                 })
 240                 .build();
 241 
 242         buttonsPane.add(centerButton, 0, 1);
 243         //</editor-fold>
 244 
 245         //<editor-fold defaultstate="collapsed" desc="Close Button">
 246         Button closeButton =  ButtonBuilder.create()
 247                 .text("Close")
 248                 .alignment(Pos.CENTER)
 249                 .prefWidth(180)
 250                 .onMouseClicked(new EventHandler<MouseEvent>() {
 251 
 252                     @Override
 253                     public void handle(MouseEvent arg0) {
 254                         primaryStage.close();
 255                     }
 256                 })
 257                 .build();
 258 
 259         buttonsPane.add(closeButton, 1, 1);
 260         //</editor-fold>
 261 
 262         //<editor-fold defaultstate="collapsed" desc="Size to scene Button">
 263         Button sizeToSceneButton =  ButtonBuilder.create()
 264                 .text("Size to scene")
 265                 .alignment(Pos.CENTER)
 266                 .prefWidth(180)
 267                 .onMouseClicked(new EventHandler<MouseEvent>() {
 268 
 269                     @Override
 270                     public void handle(MouseEvent arg0) {
 271                         primaryStage.sizeToScene();
 272                     }
 273                 })
 274                 .build();
 275 
 276         buttonsPane.add(sizeToSceneButton, 0, 2);
 277         //</editor-fold>
 278 
 279         //<editor-fold defaultstate="collapsed" desc="Show modality window Button">
 280         Button showModalityWindowButton =  ButtonBuilder.create()
 281                 .text("Show modality window")
 282                 .alignment(Pos.CENTER)
 283                 .prefWidth(180)
 284                 .onMouseClicked(new EventHandler<MouseEvent>() {
 285 
 286                     @Override
 287                     public void handle(MouseEvent arg0) {
 288                         Stage modalityStage = new Stage();
 289                         modalityStage.initModality(Modality.APPLICATION_MODAL);
 290                         modalityStage.setScene(createTestGridScene());
 291                         modalityStage.setResizable(resizable);
 292                         modalityStage.show();
 293                     }
 294                 })
 295                 .build();
 296 
 297         buttonsPane.add(showModalityWindowButton, 1, 2);
 298         //</editor-fold>
 299 
 300         //<editor-fold defaultstate="collapsed" desc="Resizable Button">
 301         Button resizableButton = ButtonBuilder.create()
 302                 .text(resizable ? "Not resizable" : "Resizable")
 303                 .alignment(Pos.CENTER)
 304                 .prefWidth(180)
 305                 .onMouseClicked(new EventHandler<MouseEvent>() {
 306 
 307                     @Override
 308                     public void handle(MouseEvent arg0) {
 309                         runJVMProcess(FSTestApp.this.getClass().getName(), String.valueOf(!resizable));
 310                         primaryStage.close();
 311                     }
 312                 }).build();
 313 
 314         buttonsPane.add(resizableButton, 0, 3);
 315         //</editor-fold>
 316 
 317         //<editor-fold defaultstate="collapsed" desc="Opacity Slider">
 318         Slider opacitySlider =  SliderBuilder.create()
 319                 .maxWidth(180)
 320                 .value(1)
 321                 .min(0)
 322                 .max(1)
 323                 .build();
 324         primaryStage.opacityProperty().bindBidirectional(opacitySlider.valueProperty());
 325 
 326 
 327         buttonsPane.add(opacitySlider, 1, 3);
 328         //</editor-fold>
 329 
 330         //<editor-fold defaultstate="collapsed" desc="System menu ToggleButton">
 331         ToggleButton useSystemMenuToggleButton =  ToggleButtonBuilder.create()
 332                 .text("Use system menu")
 333                 .alignment(Pos.CENTER)
 334                 .prefWidth(180)
 335                 .build();
 336 
 337         menu.useSystemMenuBarProperty().bindBidirectional(useSystemMenuToggleButton.selectedProperty());
 338 
 339         buttonsPane.add(useSystemMenuToggleButton, 0, 4);
 340         //</editor-fold>
 341 
 342         VBox root = VBoxBuilder.create()
 343                 .children(
 344                     menu,
 345                     HBoxBuilder.create()
 346                         .alignment(Pos.CENTER)
 347                         .padding(new Insets(5))
 348                         .children(
 349                             fullscreenIndicator,
 350                             new Text("Fullscreen"))
 351                         .build(),
 352                     buttonsPane,
 353                     logTextArea)
 354                 .build();
 355 
 356 
 357         primaryStage.setScene(new Scene(root, 400, 400));
 358         primaryStage.setMinHeight(400);
 359         primaryStage.setMinWidth(400);
 360         primaryStage.show();
 361 
 362         updateLogTimeline.play();
 363     }
 364 
 365     /**
 366      * Run class in new process
 367      * @param className name of class
 368      * @param arg run argument
 369      */
 370     private void runJVMProcess(String className, String arg) {
 371         try {
 372             String cp = System.getProperty("java.class.path");
 373             String pathToJava = System.getProperty("java.home") + "/bin/java";
 374 
 375             Runtime.getRuntime().exec(new String[]{pathToJava, "-cp", cp, className, arg});
 376         } catch (Exception ex) {
 377             Logger.getLogger(FSTestApp.class.getName()).log(Level.SEVERE, null, ex);
 378         }
 379     }
 380 
 381 
 382     /**
 383      * Create scene with grid.
 384      * @return new scene
 385      */
 386     private Scene createTestGridScene(){
 387         double height = getMaxScreenHeight();
 388         double width = getMaxScreenWidth();
 389 
 390 
 391         Pane root  = PaneBuilder.create()
 392                 .minHeight(height)
 393                 .minWidth(width)
 394                 .build();
 395 
 396         for (int x = 0; x < width; x+=10) {
 397             root.getChildren().add(
 398                     LineBuilder.create()
 399                         .startX(x)
 400                         .endX(x)
 401                         .startY(0)
 402                         .endY(height)
 403                         .build());
 404         }
 405 
 406         for (int y = 0; y < height; y+=10) {
 407             root.getChildren().add(
 408                     LineBuilder.create()
 409                         .startX(0)
 410                         .endX(width)
 411                         .startY(y)
 412                         .endY(y)
 413                         .build());
 414         }
 415 
 416         return new Scene(root, 200, 200);
 417     }
 418 
 419     /**
 420      * Get maximum height of all monitors.
 421      * @return maximum height
 422      */
 423     private double getMaxScreenHeight(){
 424         double result = 0;
 425 
 426         for(Screen screen : Screen.getScreens()){
 427             if(screen.getBounds().getHeight() > result){
 428                 result = screen.getBounds().getHeight();
 429             }
 430         }
 431 
 432         return result;
 433     }


  27 
  28 import java.util.logging.Level;
  29 import java.util.logging.Logger;
  30 import javafx.animation.*;
  31 import javafx.application.Application;
  32 import javafx.beans.value.ChangeListener;
  33 import javafx.beans.value.ObservableValue;
  34 import javafx.event.ActionEvent;
  35 import javafx.event.Event;
  36 import javafx.event.EventHandler;
  37 import javafx.geometry.Insets;
  38 import javafx.geometry.Pos;
  39 import javafx.scene.Scene;
  40 import javafx.scene.control.*;
  41 import javafx.scene.effect.InnerShadow;
  42 import javafx.scene.input.KeyCombination;
  43 import javafx.scene.input.MouseEvent;
  44 import javafx.scene.layout.*;
  45 import javafx.scene.paint.Color;
  46 import javafx.scene.shape.Circle;
  47 import javafx.scene.shape.Line;

  48 import javafx.scene.text.Text;
  49 import javafx.stage.Modality;
  50 import javafx.stage.Screen;
  51 import javafx.stage.Stage;
  52 import javafx.util.Duration;
  53 import test.javaclient.shared.Utils;
  54 
  55 /**
  56 *
  57 * @author alexander
  58 */
  59 public class FSTestApp extends Application {
  60 
  61     //if stage resizable
  62     private static boolean resizable = true;
  63 
  64 
  65     private final StringBuilder log = new StringBuilder();
  66 
  67     /**
  68     * @param args the command line arguments
  69     */
  70     public static void main(String[] args) {
  71         if((args != null) && (args.length != 0))
  72             resizable = Boolean.valueOf(args[0]);
  73 
  74         Utils.launch(FSTestApp.class, args);
  75     }
  76 
  77     @Override
  78     public void start(final Stage primaryStage) {
  79         primaryStage.setTitle("FSTestApp");
  80         primaryStage.setResizable(resizable);
  81 
  82         GridPane buttonsPane = new GridPane();
  83                 buttonsPane.setPadding(new Insets(10));
  84                 buttonsPane.setAlignment(Pos.CENTER);
  85                 buttonsPane.getColumnConstraints().add(new ColumnConstraints(200));
  86                 buttonsPane.getColumnConstraints().add(new ColumnConstraints(200));
  87                 buttonsPane.getRowConstraints().add(new RowConstraints(30));
  88                 buttonsPane.getRowConstraints().add(new RowConstraints(30));
  89                 buttonsPane.getRowConstraints().add(new RowConstraints(30));
  90                 buttonsPane.getRowConstraints().add(new RowConstraints(30));
  91         buttonsPane.getRowConstraints().add(new RowConstraints(30));


  92 
  93         final TextArea logTextArea = new TextArea();
  94                 logTextArea.setEditable(false);

  95 
  96         //Timer for update logTextArea
  97         Timeline updateLogTimeline = new Timeline(new KeyFrame(Duration.seconds(0.1), new EventHandler<ActionEvent>() {
  98                     public void handle(ActionEvent t) {
  99                         logTextArea.insertText(logTextArea.getLength(), log.toString());
 100                         log.delete(0, log.length());
 101 
 102                     }
 103                 }, ( KeyValue[])null));  // cast null to suppress compiler warning
 104                 updateLogTimeline.setCycleCount(-1);

 105 
 106         //<editor-fold defaultstate="collapsed" desc="Menu">
 107                 Menu menu1 = new Menu("_Menu1");
 108                 menu1.setOnShown(new EventHandler<Event>() {




 109                         public void handle(Event t) {
 110                                 log.append("Menu 1 Shown\n");
 111                         }
 112                 });
 113                 menu1.setOnHidden(new EventHandler<Event>() {

 114                         public void handle(Event t) {
 115                                 log.append("Menu 1 Hidden\n");
 116                         }
 117                 });
 118                 menu1.setMnemonicParsing(true);
 119                 MenuItem mi11 = new MenuItem("Menu _Item 1");
 120                 mi11.setAccelerator(KeyCombination.keyCombination("ctrl+m"));
 121                 mi11.setMnemonicParsing(true);
 122                 mi11.setOnAction(new EventHandler<ActionEvent>() {

 123                         public void handle(ActionEvent t) {
 124                                 log.append("Menu Item 1 Action\n");
 125                         }
 126                 });
 127                 MenuItem mi12 = new MenuItem("Menu I_tem 2");
 128                 mi12.setMnemonicParsing(true);
 129                 menu1.getItems().addAll(mi11, mi12);
 130                 
 131                 Menu menu2 = new Menu("M_enu2");
 132                 menu2.setMnemonicParsing(true);
 133                 menu2.setOnShown(new EventHandler<Event>() {






 134                         public void handle(Event t) {
 135                                 log.append("Menu 2 Shown\n");
 136                         }
 137                 });
 138                 menu2.setOnHidden(new EventHandler<Event>() {

 139                         public void handle(Event t) {
 140                                 log.append("Menu 2 Hidden\n");
 141                         }
 142                 });
 143                 MenuItem mi21 = new MenuItem("Menu _Item 1");
 144                 mi21.setMnemonicParsing(true);
 145                 MenuItem mi22 = new MenuItem("Menu I_tem 2");
 146                 mi22.setMnemonicParsing(true);
 147                 MenuItem mi23 = new MenuItem("Menu Ite_m 3");
 148                 mi23.setMnemonicParsing(true);
 149                 menu1.getItems().addAll(mi21, mi22, mi23);
 150                 
 151         MenuBar menu = new MenuBar(menu1, menu2);
 152         menu.setUseSystemMenuBar(true);






 153         //</editor-fold>
 154 
 155         //<editor-fold defaultstate="collapsed" desc="Fullscreen indicator">
 156         final Circle fullscreenIndicator = new Circle(6);
 157                 fullscreenIndicator.setFill(Color.RED);
 158                 fullscreenIndicator.setEffect(new InnerShadow());



 159 
 160         primaryStage.fullScreenProperty().addListener(new ChangeListener<Boolean>() {
 161 
 162             @Override
 163             public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
 164                 fullscreenIndicator.setFill(newValue.booleanValue() ? Color.GREEN : Color.RED);
 165             }
 166         });
 167         //</editor-fold>
 168 
 169         //<editor-fold defaultstate="collapsed" desc="Fullscreen false Button">
 170         Button setFSFalseButton = new Button("Set fullscreen false");
 171                 setFSFalseButton.setAlignment(Pos.CENTER);
 172                 setFSFalseButton.setPrefWidth(180);
 173                 setFSFalseButton.setOnMouseClicked(new EventHandler<MouseEvent>() {


 174                         @Override
 175                         public void handle(MouseEvent arg0) {
 176                                 primaryStage.setFullScreen(false);
 177                         }
 178                 });


 179         buttonsPane.add(setFSFalseButton, 0, 0);
 180         //</editor-fold>
 181 
 182         //<editor-fold defaultstate="collapsed" desc="Fullscreen true Button">
 183         Button setFSTrueButton = new Button("Set fullscreen true");
 184                 setFSTrueButton.setAlignment(Pos.CENTER);
 185                 setFSTrueButton.setPrefWidth(180);
 186                 setFSTrueButton.setOnMouseClicked(new EventHandler<MouseEvent>() {


 187                         @Override
 188                         public void handle(MouseEvent arg0) {
 189                                 primaryStage.setFullScreen(true);
 190                         }
 191                 });


 192         buttonsPane.add(setFSTrueButton, 1, 0);
 193         //</editor-fold>
 194 
 195         //<editor-fold defaultstate="collapsed" desc="Center Button">
 196         Button centerButton = new Button("Center");
 197                 centerButton.setAlignment(Pos.CENTER);
 198                 centerButton.setPrefWidth(180);
 199                 centerButton.setOnMouseClicked(new EventHandler<MouseEvent>() {


 200                         @Override
 201                         public void handle(MouseEvent arg0) {
 202                                 primaryStage.centerOnScreen();
 203                         }
 204                 });


 205         buttonsPane.add(centerButton, 0, 1);
 206         //</editor-fold>
 207 
 208         //<editor-fold defaultstate="collapsed" desc="Close Button">
 209         Button closeButton = new Button("Close");
 210                 closeButton.setAlignment(Pos.CENTER);
 211                 closeButton.setPrefWidth(180);
 212                 closeButton.setOnMouseClicked(new EventHandler<MouseEvent>() {


 213                         @Override
 214                         public void handle(MouseEvent arg0) {
 215                                 primaryStage.close();
 216                         }
 217                 });


 218         buttonsPane.add(closeButton, 1, 1);
 219         //</editor-fold>
 220 
 221         //<editor-fold defaultstate="collapsed" desc="Size to scene Button">
 222         Button sizeToSceneButton = new Button("Size to scene");
 223                 sizeToSceneButton.setAlignment(Pos.CENTER);
 224                 sizeToSceneButton.setPrefWidth(180);
 225                 sizeToSceneButton.setOnMouseClicked(new EventHandler<MouseEvent>() {


 226                         @Override
 227                         public void handle(MouseEvent arg0) {
 228                                 primaryStage.sizeToScene();
 229                         }
 230                 });


 231         buttonsPane.add(sizeToSceneButton, 0, 2);
 232         //</editor-fold>
 233 
 234         //<editor-fold defaultstate="collapsed" desc="Show modality window Button">
 235         Button showModalityWindowButton = new Button("Show modality window");
 236                 showModalityWindowButton.setAlignment(Pos.CENTER);
 237                 showModalityWindowButton.setPrefWidth(180);
 238                 showModalityWindowButton.setOnMouseClicked(new EventHandler<MouseEvent>() {


 239                         @Override
 240                         public void handle(MouseEvent arg0) {
 241                                 Stage modalityStage = new Stage();
 242                                 modalityStage.initModality(Modality.APPLICATION_MODAL);
 243                                 modalityStage.setScene(createTestGridScene());
 244                                 modalityStage.setResizable(resizable);
 245                                 modalityStage.show();
 246                         }
 247                 });


 248         buttonsPane.add(showModalityWindowButton, 1, 2);
 249         //</editor-fold>
 250 
 251         //<editor-fold defaultstate="collapsed" desc="Resizable Button">
 252         Button resizableButton = new Button();
 253                 resizableButton.setText(resizable ? "Not resizable" : "Resizable");
 254                 resizableButton.setAlignment(Pos.CENTER);
 255                 resizableButton.setPrefWidth(180);
 256                 resizableButton.setOnMouseClicked(new EventHandler<MouseEvent>() {

 257                         @Override
 258                         public void handle(MouseEvent arg0) {
 259                                 runJVMProcess(FSTestApp.this.getClass().getName(), String.valueOf(!resizable));
 260                                 primaryStage.close();
 261                         }
 262                 });

 263         buttonsPane.add(resizableButton, 0, 3);
 264         //</editor-fold>
 265 
 266         //<editor-fold defaultstate="collapsed" desc="Opacity Slider">
 267         Slider opacitySlider = new Slider(0, 1, 1);
 268                 opacitySlider.setMaxWidth(180);




 269         primaryStage.opacityProperty().bindBidirectional(opacitySlider.valueProperty());


 270                 buttonsPane.add(opacitySlider, 1, 3);
 271         //</editor-fold>
 272 
 273         //<editor-fold defaultstate="collapsed" desc="System menu ToggleButton">
 274         ToggleButton useSystemMenuToggleButton = new ToggleButton("Use system menu");
 275                 useSystemMenuToggleButton.setAlignment(Pos.CENTER);
 276                 useSystemMenuToggleButton.setPrefWidth(180);



 277                 menu.useSystemMenuBarProperty().bindBidirectional(useSystemMenuToggleButton.selectedProperty());
 278 
 279         buttonsPane.add(useSystemMenuToggleButton, 0, 4);
 280         //</editor-fold>
 281 
 282         HBox temp = new HBox(fullscreenIndicator, new Text("Fullscreen"));
 283                 temp.setAlignment(Pos.CENTER);
 284                 temp.setPadding(new Insets(5));
 285                 VBox root = new VBox(menu, temp, buttonsPane, logTextArea);











 286         primaryStage.setScene(new Scene(root, 400, 400));
 287         primaryStage.setMinHeight(400);
 288         primaryStage.setMinWidth(400);
 289         primaryStage.show();
 290 
 291         updateLogTimeline.play();
 292     }
 293 
 294     /**
 295      * Run class in new process
 296      * @param className name of class
 297      * @param arg run argument
 298      */
 299     private void runJVMProcess(String className, String arg) {
 300         try {
 301             String cp = System.getProperty("java.class.path");
 302             String pathToJava = System.getProperty("java.home") + "/bin/java";
 303 
 304             Runtime.getRuntime().exec(new String[]{pathToJava, "-cp", cp, className, arg});
 305         } catch (Exception ex) {
 306             Logger.getLogger(FSTestApp.class.getName()).log(Level.SEVERE, null, ex);
 307         }
 308     }
 309 
 310 
 311     /**
 312      * Create scene with grid.
 313      * @return new scene
 314      */
 315     private Scene createTestGridScene(){
 316         double height = getMaxScreenHeight();
 317         double width = getMaxScreenWidth();
 318 
 319 
 320         Pane root  = new Pane();
 321                 root.setMinHeight(height);
 322                 root.setMinWidth(width);

 323                 
 324         for (int x = 0; x < width; x+=10) {
 325             root.getChildren().add(new Line(x, x, 0, height));






 326         }
 327 
 328         for (int y = 0; y < height; y+=10) {
 329             root.getChildren().add(new Line(0, width, y, y));






 330         }
 331 
 332         return new Scene(root, 200, 200);
 333     }
 334 
 335     /**
 336      * Get maximum height of all monitors.
 337      * @return maximum height
 338      */
 339     private double getMaxScreenHeight(){
 340         double result = 0;
 341 
 342         for(Screen screen : Screen.getScreens()){
 343             if(screen.getBounds().getHeight() > result){
 344                 result = screen.getBounds().getHeight();
 345             }
 346         }
 347 
 348         return result;
 349     }