private void registerMouseDragHandlers(final Scene scene) {
    final boolean[] isDragging = new boolean[] {false};
    final double[] mouseX = new double[] {0};
    final double[] mouseY = new double[] {0};

    scene.setOnMousePressed(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            isDragging[0] = true;
            mouseX[0] = event.getX();
            mouseY[0] = event.getY();
          }
        });
    scene.setOnMouseReleased(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            isDragging[0] = false;
          }
        });
    scene.setOnMouseDragged(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            getTracker().stopTracking();
            double translateX = event.getX() - mouseX[0];
            double translateY = event.getY() - mouseY[0];
            getViewport().translateBy(Vector.cartesian(-translateX, -translateY));
            mouseX[0] = event.getX();
            mouseY[0] = event.getY();
          }
        });
  }
Пример #2
0
  public Controller(View root, Stage stage) {
    this.root = root;

    root.openFile.setOnAction(
        (value) -> {
          root.pdbObjects.getChildren().clear();
          File file = root.fileChooser.showOpenDialog(stage);
          readPDB(file.getAbsolutePath());
          root.fileLabel.setText(file.getName());
        });

    scene = new Scene(root, 700, 700, true);
    root.threeDView.widthProperty().bind(scene.widthProperty());
    root.threeDView.heightProperty().bind(Bindings.add(-50.0, scene.heightProperty()));

    scene.setOnMousePressed(
        (event) -> {
          mouseStartX = event.getSceneX();
          mouseStartY = event.getSceneY();
        });

    scene.setOnMouseDragged(
        (event) -> {
          double deltaX = event.getSceneX() - mouseStartX;
          double deltaY = event.getSceneY() - mouseStartY;
          if (event.isShiftDown()) {
            root.camera.setTranslateZ(root.getTranslateZ() + deltaY * 10);
          } else {
            worldRotateY.setAngle(deltaX);
            worldRotateZ.setAngle(deltaY);
          }
        });
  }
Пример #3
0
 /**
  * Utility method to discover the {@code Paint} used by {@code Label}
  *
  * @return Base Paint use of Labels
  */
 public static Paint getBaseTextColor() {
   final Label label = new Label(BASE_COLOR);
   final Scene scene = new Scene(new Group(label));
   scene.getRoot().styleProperty().setValue(getStyleProperty().getValue());
   label.applyCss();
   return label.getTextFill();
 }
  @Override
  public void start(Stage primaryStage) throws Exception {
    MyResourceLoader resloader = new MyResourceLoader();

    if (lines == null || lines.isEmpty()) {
      Platform.exit();
      return;
    }

    LineInterface oneLine = lines.get(0);
    // FavoritCoreDeviceV1 dev=new FavoritCoreDeviceV1(1,"Favorit Ventil V1",null,"Test
    // Description",ms);
    StepDriver ds = new StepDriver(1, "Pan Drive", null);
    // dev.setPrimerayLine(oneLine);

    ds.setPrimerayLine(oneLine);
    PanDriveComplexPanel panel = new PanDriveComplexPanel(oneLine, ds, lines);
    panel.setId("mainPanel");
    Scene scene = new Scene(panel);
    scene.getStylesheets().addAll(resloader.getExternalResourceURILink("application.css"));

    // vbox.setPrefHeight(970);
    primaryStage.setTitle("UTILITY PAN DRIVE");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Пример #5
0
 /**
  * Handlers check for keypresses left, right, up, down arrow keys If left is pressed, add value
  * of-5 to left move (decrease X to move left) right is pressed, add 5 to right move (increase X
  * to move up) up is pressed, add -5 to up (decrease Y to move up) down is pressed, add 5 to down
  * (increase Y to move down)
  *
  * @param scene Scene
  */
 public static void addMovementHandlers(Scene scene) {
   scene.addEventHandler(
       KeyEvent.KEY_PRESSED,
       k -> {
         if (k.getCode() == KeyCode.LEFT) {
           Configurations.getLoopService().setL(-5);
         }
         if (k.getCode() == KeyCode.RIGHT) {
           Configurations.getLoopService().setR(5);
         }
         if (k.getCode() == KeyCode.UP) {
           Configurations.getLoopService().setU(-5);
         }
         if (k.getCode() == KeyCode.DOWN) {
           Configurations.getLoopService().setD(5);
         }
       });
   scene.addEventHandler(
       KeyEvent.KEY_RELEASED,
       k -> {
         if (k.getCode() == KeyCode.LEFT) {
           Configurations.getLoopService().setL(0);
         }
         if (k.getCode() == KeyCode.RIGHT) {
           Configurations.getLoopService().setR(0);
         }
         if (k.getCode() == KeyCode.UP) {
           Configurations.getLoopService().setU(0);
         }
         if (k.getCode() == KeyCode.DOWN) {
           Configurations.getLoopService().setD(0);
         }
       });
 }
Пример #6
0
  @Override
  public void start(Stage ps) throws Exception {
    window = ps;
    control = new WindowControl();

    music = new MediaPlayer(new Media(Util.getResource("music.mp3").toString()));
    breakSound = new MediaPlayer(new Media(Util.getResource("asteroid_break.mp3").toString()));
    explosionSound = new MediaPlayer(new Media(Util.getResource("explosion.mp3").toString()));

    window.setTitle("Asteroids: Space adventure - By macjuul");

    Image icon_128 = Util.getImage("icon_128.png");
    Image icon_32 = Util.getImage("icon_32.png");
    Image icon_16 = Util.getImage("icon_16.png");

    window.getIcons().addAll(icon_128, icon_32, icon_16);

    window.setMinWidth(WIDTH);
    window.setMinHeight(HEIGHT);
    window.setWidth(WIDTH);
    window.setHeight(HEIGHT);

    Parent layout = (Parent) control.loadLayout();

    Scene s = new Scene(layout);

    // Set our stylesheet
    s.getStylesheets().add(Util.getResource("window/style.css").toExternalForm());

    s.setCursor(Cursor.CROSSHAIR);

    window.setScene(s);

    window
        .widthProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldN, Number newN) -> {
              WIDTH = newN.intValue();

              updateDimensions(true);
            });

    window
        .heightProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldN, Number newN) -> {
              HEIGHT = (int) newN.intValue();

              updateDimensions(true);
            });

    // Open the window
    window.show();

    window.setOnCloseRequest(
        e -> {
          Platform.exit();
          System.exit(0);
        });
  }
Пример #7
0
  @Override
  public void start(Stage primaryStage) {
    try {
      Group root = new Group();
      Scene scene = new Scene(root, 400, 400);
      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.show();

      final Rectangle rectBasicTimeline = new Rectangle();
      rectBasicTimeline.setX(0);
      rectBasicTimeline.setY(0);
      rectBasicTimeline.widthProperty().bind(scene.widthProperty());
      rectBasicTimeline.heightProperty().bind(scene.heightProperty());
      rectBasicTimeline.setFill(Color.RED);
      root.getChildren().add(rectBasicTimeline);
      final Timeline timeline = new Timeline();
      timeline.setCycleCount(Timeline.INDEFINITE);
      timeline.setAutoReverse(true);
      final KeyValue kv1 = new KeyValue(rectBasicTimeline.fillProperty(), Color.YELLOW);
      final KeyValue kv2 = new KeyValue(rectBasicTimeline.fillProperty(), Color.GREEN);
      final KeyValue kv3 = new KeyValue(rectBasicTimeline.fillProperty(), Color.BLUE);
      final KeyFrame kf1 = new KeyFrame(Duration.millis(5000), kv1);
      final KeyFrame kf2 = new KeyFrame(Duration.millis(10000), kv2);
      final KeyFrame kf3 = new KeyFrame(Duration.millis(15000), kv3);
      timeline.getKeyFrames().add(kf1);
      timeline.getKeyFrames().add(kf2);
      timeline.getKeyFrames().add(kf3);
      timeline.play();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #8
0
  private void initialiseEditConnectionsWindow() {
    // This is a dirty way to reload connection settings :) possibly could be removed if all
    // connections are closed before loading a new config file
    if (editConnectionsController != null) {
      eventManager.deregisterConnectionStatusObserver(editConnectionsController);
    }

    final FXMLLoader loader =
        FxmlUtils.createFxmlLoaderForProjectFile("EditConnectionsWindow.fxml");
    final AnchorPane connectionWindow = FxmlUtils.loadAnchorPane(loader);
    editConnectionsController = ((EditConnectionsController) loader.getController());
    editConnectionsController.setMainController(this);
    editConnectionsController.setEventManager(eventManager);
    editConnectionsController.setConnectionManager(connectionManager);
    editConnectionsController.setConfigurationManager(configurationManager);
    editConnectionsController.init();

    Scene scene = new Scene(connectionWindow);
    scene.getStylesheets().addAll(mainPane.getScene().getStylesheets());

    editConnectionsStage = new Stage();
    editConnectionsStage.setTitle("Connection list");
    editConnectionsStage.initModality(Modality.WINDOW_MODAL);
    editConnectionsStage.initOwner(getParentWindow());
    editConnectionsStage.setScene(scene);
  }
  public OptimizedVirtualCallStage(
      final JITWatchUI parent, final List<OptimizedVirtualCall> optimizedVirtualCalls) {
    initStyle(StageStyle.DECORATED);

    setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent arg0) {
            parent.handleStageClosed(OptimizedVirtualCallStage.this);
          }
        });

    VBox vbox = new VBox();
    vbox.setPadding(new Insets(8));
    vbox.setSpacing(8);

    Scene scene =
        UserInterfaceUtil.getScene(vbox, JITWatchUI.WINDOW_WIDTH, JITWatchUI.WINDOW_HEIGHT);

    setTitle("Optimized Virtual Calls");

    tableView = VCallTableBuilder.buildTable(parent, optimizedVirtualCalls);

    vbox.getChildren().add(tableView);

    tableView.prefHeightProperty().bind(scene.heightProperty());

    setScene(scene);
    show();
  }
Пример #10
0
  private void inicializaComponentes() {
    GridPane inputs = buildInputs();
    VBox image = getImage();

    HBox vbox = new HBox();
    vbox.getChildren().addAll(image, inputs);
    Scene scene = new Scene(new Group(vbox));
    scene.getStylesheets().add("style.css");
    this.setScene(scene);

    // fecha a tela com ESC
    scene
        .getAccelerators()
        .put(
            new KeyCodeCombination(KeyCode.ESCAPE, KeyCombination.SHORTCUT_ANY),
            new Runnable() {
              @Override
              public void run() {
                Platform.runLater(
                    new Runnable() {
                      @Override
                      public void run() {
                        hide();
                      }
                    });
              }
            });
  }
Пример #11
0
  /** Method that loads all necessary information and initiates the views, the keyhandlers etc. */
  public void loadProgramDataFromPdb() {
    // Extract nucleotide information
    rnaSequence3D = new RNASequence(getModel().getPdbfile());

    // Extract base-sequence and compute watson-crick bonds
    getModel().setSequence(rnaSequence3D.extractString());
    getModel().setBonds(rnaSequence3D.computeWCBonds());

    // Init selection Model
    initSelectionModel();

    // Init the Views
    initPrimaryView();
    initSecondaryView();
    initTertiaryView();

    // init focus selection listener
    initSelectionListener();
    selectionFocusBinding();

    // init keyhandler
    if (keyPressedEventHandler != null)
      scene.removeEventFilter(KeyEvent.KEY_PRESSED, keyPressedEventHandler);
    initKeyEventHandler();
    scene.addEventFilter(KeyEvent.KEY_PRESSED, keyPressedEventHandler);
  }
Пример #12
0
  @Override
  public void start(Stage stage) throws Exception {
    this.primaryStage = stage;
    primaryStage.setTitle("Matrix Digital Rain");

    Group root = new Group();
    Scene scene = new Scene(root, 1024, 768);
    scene.addEventHandler(
        KeyEvent.KEY_PRESSED,
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent keyEvent) {
            if (keyEvent.getCode() == KeyCode.F) {
              primaryStage.setFullScreen(!primaryStage.isFullScreen());
            }
            if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.Q) {
              primaryStage.close();
            }
          }
        });

    Canvas canvas = new Canvas();
    canvas.widthProperty().bind(primaryStage.widthProperty());
    canvas.heightProperty().bind(primaryStage.heightProperty());

    final GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.setFont(font);

    setupSimulation();

    new AnimationTimer() {
      @Override
      public void handle(long now) {
        update(now);

        gc.clearRect(0, 0, primaryStage.getWidth(), primaryStage.getHeight());
        gc.setFill(Color.rgb(0, 0, 1));
        gc.fillRect(0, 0, primaryStage.getWidth(), primaryStage.getHeight());

        int y = 0;
        int nbGlyphsPerRow = getNbGlyphsPerRow();
        int nbGlyphsPerColumn = getNbGlyphsPerColumn();

        for (int i = 0; i < nbGlyphsPerRow * nbGlyphsPerColumn; ++i) {
          gc.setFill(Color.rgb(0, path[i], 0));
          String text = String.valueOf(data[i]);
          gc.fillText(text, (i % nbGlyphsPerRow) * 12 + 1, y + 13);

          if (i % nbGlyphsPerRow == nbGlyphsPerRow - 1) {
            y += 12;
          }
        }
      }
    }.start();

    root.getChildren().add(canvas);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
Пример #13
0
  @Override
  public void start(Stage primaryStage) {

    System.out.println(isMongodRunning());

    if (!isMongodRunning()) {
      Process p;
      try {
        p = Runtime.getRuntime().exec(cmdArrayd);
        System.out.println("lancement du serveur");
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    utils.MongoAccess.connect();

    exportStage = primaryStage;
    try {
      Pane root = new Pane();

      Scene fiche_client_scene =
          new Scene((Parent) JfxUtils.loadFxml("/views/fiche_client.fxml"), 1275, 722);
      fiche_client_scene
          .getStylesheets()
          .add(getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(fiche_client_scene);
      primaryStage.show();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #14
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    top = new Top(this);
    tWindow = new TeacherWindow();
    sWindow = new StudentWindow();
    // Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Jeopardy");
    background.setImage(jeopardy);
    stack.getChildren().add(background);
    stack.getChildren().add(border);
    border.setTop(top);
    Scene scene = new Scene(stack, 800, 800);
    primaryStage.setScene(scene);
    background.fitWidthProperty().bind(scene.widthProperty());
    background.fitHeightProperty().bind(scene.heightProperty());
    primaryStage.show();

    top.tButton.setOnAction(
        e -> {
          System.out.println("clicked");
          displayTeacherWindow();
        });

    top.sButton.setOnAction(
        e -> {
          displayStudentWindow();
        });
  }
  @Test
  public void keyTriggerSetsCoordinatesToFocusOwner() {
    Rectangle rect = new Rectangle(100, 100);
    rect.setTranslateX(100);
    rect.setTranslateY(100);
    Group root = new Group(rect);
    Scene scene = new Scene(root);
    Stage stage = new Stage();
    stage.setScene(scene);
    stage.show();
    rect.requestFocus();

    rect.setOnContextMenuRequested(
        event -> {
          Assert.assertEquals(25.0, event.getX(), 0.0001);
          Assert.assertEquals(125, event.getSceneX(), 0.0001);
          Assert.assertEquals(225, event.getScreenX(), 0.0001);
          Assert.assertEquals(50.0, event.getY(), 0.0001);
          Assert.assertEquals(150, event.getSceneY(), 0.0001);
          Assert.assertEquals(250, event.getScreenY(), 0.0001);
          assertTrue(event.isKeyboardTrigger());
        });

    ((StubScene) scene.impl_getPeer()).getListener().menuEvent(101, 102, 201, 202, true);
  }
Пример #16
0
  private Group createButtonArea(final Scene scene) {
    // create button area
    final Group buttonGroup = new Group();
    // rounded rect
    Rectangle buttonArea =
        RectangleBuilder.create()
            .arcWidth(15)
            .arcHeight(20)
            .fill(new Color(0, 0, 0, .55))
            .x(0)
            .y(0)
            .width(60)
            .height(30)
            .stroke(Color.rgb(255, 255, 255, .70))
            .build();
    buttonGroup.getChildren().add(buttonArea);

    // move button group when scene is resized
    buttonGroup
        .translateXProperty()
        .bind(scene.widthProperty().subtract(buttonArea.getWidth() + 6));
    buttonGroup
        .translateYProperty()
        .bind(scene.heightProperty().subtract(buttonArea.getHeight() + 6));
    return buttonGroup;
  }
Пример #17
0
  @Override
  public void start(Stage stage) {
    stage.setTitle("URL Lister");
    Scene scene = new Scene(new Group(), 1250, 700);

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("Server: "), 0, 0);
    grid.add(new Label("URL: "), 0, 1);
    grid.add(subject, 1, 1, 3, 1);
    grid.add(text, 1, 60, 2, 10);
    grid.add(text2, 10, 60, 2, 10);
    grid.add(text3, 10, 20, 2, 5);
    grid.add(button, 0, 3);
    grid.add(button2, 5, 60);
    grid.add(button3, 5, 65);
    grid.add(notification, 1, 3, 3, 1);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();
  }
Пример #18
0
  @Override
  public void start(Stage stage) throws Exception {
    primaryStage = stage;

    primaryStage.setTitle("Générateur de trames de surveillances");

    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Main.class.getResource("../../../zoo/generator/view/RootLayout.fxml"));

    try {
      rootLayout = loader.load();
      Scene scene = new Scene(rootLayout);
      primaryStage.setScene(scene);

      // Main panel
      FXMLLoader loader2 = new FXMLLoader();
      loader2.setLocation(Main.class.getResource("../../../zoo/generator/view/MainPanel.fxml"));
      BorderPane o = loader2.load();

      scene.setRoot(o);

      MainPanelController controller = loader2.getController();
      controller.setRandomGenerationService(RandomGenerationService.getInstance());

      primaryStage.show();

      primaryStage.setOnCloseRequest(
          new EventHandler<WindowEvent>() {

            @Override
            public void handle(WindowEvent event) {
              System.out.println("Arrêt des threads");
              Thread[] threads = new Thread[100];

              int n = Thread.enumerate(threads);

              for (int i = 0; i < n; i++) {
                System.out.println(threads[i]);
              }

              // 1. Stop random generation
              RandomGenerationService.getInstance().stop();

              // 2. Stop server thread
              Server.getInstance().stop();

              // 3. Stop client threads
              ClientHandler.stopAll();

              System.out.println("Après l'arrêt des threads");
            }
          });

      Server.getInstance().start();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Пример #19
0
  public void createKeyInputHandling() {
    scene.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            switch (event.getCode()) {
              case UP:
                if (!input.inputKeys[KeyType.UpArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.UpArrow.ordinal()].setPressed();
                break;
              case DOWN:
                if (!input.inputKeys[KeyType.DownArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.DownArrow.ordinal()].setPressed();

                break;
              case LEFT:
                if (!input.inputKeys[KeyType.LeftArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.LeftArrow.ordinal()].setPressed();
                break;
              case RIGHT:
                if (!input.inputKeys[KeyType.RightArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.RightArrow.ordinal()].setPressed();
                break;
              case ENTER:
                if (!input.inputKeys[KeyType.Enter.ordinal()].isPressed())
                  input.inputKeys[KeyType.Enter.ordinal()].setPressed();
                break;
              default:
                break;
            }
          }
        });
    scene.setOnKeyReleased(
        new EventHandler<KeyEvent>() {

          @Override
          public void handle(KeyEvent event) {
            switch (event.getCode()) {
              case UP:
                input.inputKeys[KeyType.UpArrow.ordinal()].setReleased();
                break;
              case DOWN:
                input.inputKeys[KeyType.DownArrow.ordinal()].setReleased();
                break;
              case LEFT:
                input.inputKeys[KeyType.LeftArrow.ordinal()].setReleased();
                break;
              case RIGHT:
                input.inputKeys[KeyType.RightArrow.ordinal()].setReleased();
                break;
              case ENTER:
                input.inputKeys[KeyType.Enter.ordinal()].setReleased();
                break;
              default:
                break;
            }
          }
        });
  }
Пример #20
0
 @Override
 public void start(Stage stage) {
   Scene scene = new Scene(gpane, 520, 360);
   scene.getStylesheets().add("javafinalproject/style.css");
   stage.setTitle("JigSaw Puzzle");
   stage.setScene(scene);
   stage.show();
 }
Пример #21
0
  public void init() {
    this.connectionManager =
        new ConnectionManager(eventManager, statisticsManager, configurationManager);

    statisticsManager.loadStats();

    // Set up scene
    scene = getParentWindow().getScene();

    // Set up window events
    getParentWindow()
        .setOnCloseRequest(
            new EventHandler<WindowEvent>() {
              public void handle(WindowEvent t) {
                exit();
              }
            });
    scene
        .widthProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> observableValue,
                  Number oldSceneWidth,
                  Number newSceneWidth) {
                if (!getStage().isMaximized()) {
                  setLastWidth((double) newSceneWidth);
                }
              }
            });
    scene
        .heightProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> observableValue,
                  Number oldSceneHeight,
                  Number newSceneHeight) {
                if (!getStage().isMaximized()) {
                  setLastHeight((double) newSceneHeight);
                }
              }
            });

    // Clear any test tabs
    stage.setTitle("mqtt-spy");

    controlPanelPaneController.setMainController(this);
    controlPanelPaneController.setConfigurationMananger(configurationManager);
    controlPanelPaneController.setApplication(application);
    controlPanelPaneController.setEventManager(eventManager);
    controlPanelPaneController.setConnectionManager(connectionManager);
    controlPanelPaneController.init();

    new Thread(new ConnectionStatsUpdater(connectionManager)).start();
  }
Пример #22
0
  private void handleMouseEvent(MouseEvent me) {
    // Handle cursor
    final Scene scene = getScene();

    if (scene == null) {
      return;
    }

    // When another window is focused (just like the preview window),
    // we use default cursor
    if (scene.getWindow() != null && !scene.getWindow().isFocused()) {
      setCursor(Cursor.DEFAULT);
      return;
    }

    final LibraryListItem listItem = getItem();
    ILibraryItem item = null;

    if (listItem != null) {
      item = listItem.getLibItem();
    }

    boolean isSection = false;
    if (listItem != null && listItem.getSectionName() != null) {
      isSection = true;
    }

    if (me.getEventType() == MouseEvent.MOUSE_ENTERED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.OPEN_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_PRESSED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.CLOSED_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_RELEASED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.OPEN_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_EXITED) {
      setCursor(Cursor.DEFAULT);
    } else if (me.getEventType() == MouseEvent.MOUSE_CLICKED) {
      // On double click ask for addition of the drag able item on Content
      if (me.getClickCount() == 2 && me.getButton() == MouseButton.PRIMARY) {
        if (!isEmpty() && !isSection && item != null) {
          if (editorController.canPerformInsert(item)) {
            editorController.performInsert(item);
          }
        }
      }
    }
  }
Пример #23
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setVgap(10);
    grid.setHgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Scene sc = new Scene(grid, 500, 500);

    String css = Main.class.getResource("Login.css").toExternalForm();
    //        System.out.println(css);
    sc.getStylesheets().add(css);

    Text scenetitle = new Text("Welcome");
    //        scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle, 0, 0, 1, 1);

    Label userName = new Label("User Name:");
    grid.add(userName, 0, 1);

    TextField userTextField = new TextField("Мудак");
    grid.add(userTextField, 1, 1);

    Label pw = new Label("Password:"******"Sign in");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);
    grid.add(hbBtn, 1, 4);

    final Text actiontarget = new Text();
    grid.add(actiontarget, 1, 6);

    btn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            //                actiontarget.setFill(Color.FIREBRICK);
            actiontarget.setText("Pressed");
          }
        });

    //        grid.setGridLinesVisible(true);

    scenetitle.setId("welc");
    actiontarget.setId("act");

    primaryStage.setScene(sc);
    primaryStage.setTitle("Hello World");
    primaryStage.show();
  }
Пример #24
0
 /* (non-Javadoc)
  * Starts the JavaFX gui and reads fxml file
  *
  * @see javafx.application.Application#start(javafx.stage.Stage)
  */
 @Override
 public void start(Stage stage) throws Exception {
   Parent root = FXMLLoader.load(getClass().getResource("FxmlExample.fxml"));
   Scene scene = new Scene(root);
   scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
   stage.setTitle("FXML Example");
   stage.setScene(scene);
   stage.show();
 }
Пример #25
0
  @Override
  public void start(Stage primaryStage) throws MalformedURLException {

    initialize();

    primaryStage.setTitle("Media Player");
    Group root = new Group();
    Scene scene = new Scene(root, 540, 241);

    // create media player
    File file = new File(MEDIA_URL);
    Media media = null;
    try {
      if (file.exists()) {

        System.out.println("FILE EXISTS");
        media = new Media(file.toURI().toURL().toExternalForm());
        MediaPlayer mediaPlayer = new MediaPlayer(media);
        mediaPlayer.setAutoPlay(false);
        MediaControl mediaControl = new MediaControl(mediaPlayer);
        scene.setRoot(mediaControl);

        primaryStage.setScene(scene);
        primaryStage.show();
      } else {
        Dialogs.showErrorDialog(
            null, null, "Instrumental file not found. Please contact the administrator.", "ERROR");
      }
    } catch (Exception e) {
      System.out.println("FILE DOES NOT EXIST");
      // FileChooser fileChooser = new FileChooser();

      // Set extension filter
      // FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("MP3 files
      // (*.mp3)", "*.mp3");
      // fileChooser.getExtensionFilters().add(extFilter);

      // Show open file dialog
      // file = fileChooser.showOpenDialog(null);
      // String url =
      // "http://mp3crow.mobi/dl/aHR0cDovL2FwaS5zb3VuZGNsb3VkLmNvbS90cmFja3MvNjg4ODI2OTUvc3RyZWFtP2NsaWVudF9pZD1mZmEwYzc5YmY4YWVkYzBkOWIwYmIwNzQyNzhjZjI1MQ==yFRzUi1GcmVzaCAmIFNjcmF0Y2gtRCBvZiBEeW5hbWl4IElJIC0gUm9ja2luIHRvIHRoZSBCZWF0IHRoYXQgaXMgc28gRnJlc2hoaGhoaGho.mp3";
      // media = new Media(file.toURI().toURL().toExternalForm());
      // MediaPlayer mediaPlayer = new MediaPlayer(media);
      // mediaPlayer.setAutoPlay(false);
      // MediaControl mediaControl = new MediaControl(mediaPlayer);
      // scene.setRoot(mediaControl);

      String content = open();

      root.getChildren().add(new Button(content));

      primaryStage.setScene(scene);
      primaryStage.show();
      // Dialogs.showErrorDialog(null, null, "Instrumental file not found. Please contact the
      // administrator.", "ERROR");
    }
  }
Пример #26
0
  @Override
  public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("NbmDownloader.fxml"));

    Scene scene = new Scene(root);
    scene.getStylesheets().add(NbmDownloader.class.getResource("stylesheet.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
  }
Пример #27
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Group root = new Group();
    Group circles = new Group();
    for (int i = 0; i < 30; i++) {
      Circle circle = new Circle(150, Color.web("white", 0.05));
      circle.setStrokeType(StrokeType.OUTSIDE);
      circle.setStroke(Color.web("white", 0.16));
      circle.setStrokeWidth(4);
      circles.getChildren().add(circle);
    }
    root.getChildren().add(circles);
    Scene scene = new Scene(root, 800, 600, Color.BLACK);
    Rectangle colors =
        new Rectangle(
            scene.getWidth(),
            scene.getHeight(),
            new LinearGradient(
                0f,
                1f,
                1f,
                0f,
                true,
                CycleMethod.NO_CYCLE,
                new Stop[] {
                  new Stop(0, Color.web("#f8bd55")),
                  new Stop(0.14, Color.web("#c0fe56")),
                  new Stop(0.28, Color.web("#5dfbc1")),
                  new Stop(0.43, Color.web("#64c2f8")),
                  new Stop(0.57, Color.web("#be4af7")),
                  new Stop(0.71, Color.web("#ed5fc2")),
                  new Stop(0.85, Color.web("#ef504c")),
                  new Stop(1, Color.web("#f2660f")),
                }));
    colors.widthProperty().bind(scene.widthProperty());
    colors.heightProperty().bind(scene.heightProperty());
    root.getChildren().add(colors);

    Timeline timeline = new Timeline();
    for (Node circle : circles.getChildren()) {
      timeline
          .getKeyFrames()
          .addAll(
              new KeyFrame(
                  Duration.ZERO, // set start position at 0
                  new KeyValue(circle.translateXProperty(), random() * 800),
                  new KeyValue(circle.translateYProperty(), random() * 600)),
              new KeyFrame(
                  new Duration(40000), // set end position at 40s
                  new KeyValue(circle.translateXProperty(), random() * 800),
                  new KeyValue(circle.translateYProperty(), random() * 600)));
    }
    timeline.play();
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Пример #28
0
 @FXML
 public void switchToCreateUser(Event evt) throws IOException {
   stage = (Stage) btBeginLogIn.getScene().getWindow();
   root = FXMLLoader.load(getClass().getResource("CreateUser.fxml"));
   Scene scene = new Scene(root);
   scene.getStylesheets().add((new File("css/CreateUser.css")).toURI().toURL().toExternalForm());
   stage.setScene(scene);
   stage.setResizable(false);
   stage.show();
 }
Пример #29
0
 @FXML
 public void backToLobby() throws IOException {
   stage = (Stage) btGameLobbyExit.getScene().getWindow();
   root = FXMLLoader.load(getClass().getResource("Lobby.fxml"));
   Scene scene = new Scene(root);
   scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm());
   stage.setScene(scene);
   stage.setResizable(false);
   stage.show();
 }
Пример #30
0
  @Override
  public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));

    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/Styles.css");

    stage.setTitle("JavaFX and Maven");
    stage.setScene(scene);
    stage.show();
  }