Exemplo n.º 1
2
  public static void message(String msg, StackPane pane) {

    Label warningL = new Label(msg);
    Labels.setLabelStyle(warningL, Custom.TEXT_SIZE_LARGER, true);
    warningL.setTextAlignment(TextAlignment.CENTER);

    StackPane warningPane = new StackPane();
    warningPane.getChildren().add(warningL);
    warningPane.setStyle(Custom.WINDOW_STYLING);
    warningPane.setMinWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMaxWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMinHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setMaxHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setBorder(
        new Border(
            new BorderStroke(
                Paint.valueOf("#000000"),
                BorderStrokeStyle.SOLID,
                new CornerRadii(30),
                new BorderWidths(5))));

    pane.getChildren().add(warningPane);

    PauseTransition pause = new PauseTransition(Duration.millis(1500));
    pause.setOnFinished(
        (f) -> {
          pane.getChildren().remove(warningPane);
          goBack();
        });
    pause.play();
  }
Exemplo n.º 2
0
 private void switchToItemList() {
   // Replace initial button by the item list (vbox)
   if (root.getChildren().contains(rootInitialBt)) {
     root.getChildren().remove(rootInitialBt);
     root.getChildren().add(super.getValueEditor());
   }
 }
Exemplo n.º 3
0
  @Ignore
  @Test
  public void setCurrentPageIndexAndNavigateWithMouse() {
    pagination.setPageCount(25);
    pagination.setPageFactory(
        new Callback<Integer, Node>() {
          @Override
          public Node call(Integer pageIndex) {
            Node n = createPage(pageIndex);
            return n;
          }
        });

    root.setPrefSize(400, 400);
    root.getChildren().add(pagination);
    show();

    root.impl_reapplyCSS();
    root.layout();
    tk.firePulse();
    assertTrue(pagination.isFocused());

    double xval = (pagination.localToScene(pagination.getLayoutBounds())).getMinX();
    double yval = (pagination.localToScene(pagination.getLayoutBounds())).getMinY();

    scene.impl_processMouseEvent(
        MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval + 170, yval + 380));
    tk.firePulse();

    assertEquals(3, pagination.getCurrentPageIndex());
  }
Exemplo n.º 4
0
  static void display(String title) {
    Stage window = new Stage();
    StackPane layout = new StackPane();
    Scene scene = new Scene(layout, 300, 150);

    Button btnFile = new Button("File");
    btnFile.setMaxHeight(Double.MAX_VALUE);
    btnFile.setMaxWidth(Double.MAX_VALUE);

    Button btnEdit = new Button("Edit");
    btnEdit.setMaxHeight(Double.MAX_VALUE);
    btnEdit.setMaxWidth(Double.MAX_VALUE);

    Button btnSave = new Button("Save");
    btnSave.setMaxHeight(Double.MAX_VALUE);
    btnSave.setMaxWidth(Double.MAX_VALUE);

    Button btnClose = new Button("close");
    btnClose.setOnAction(e -> window.close());

    VBox vBox = new VBox();
    vBox.getChildren().addAll(btnFile, btnEdit, btnSave, btnClose);
    vBox.setVgrow(btnFile, Priority.ALWAYS);
    vBox.setVgrow(btnEdit, Priority.ALWAYS);
    vBox.setVgrow(btnSave, Priority.ALWAYS);
    vBox.setAlignment(Pos.CENTER);

    layout.getChildren().add(vBox);

    window.setTitle(title);
    window.setScene(scene);
    window.show();
  }
  public void start(Stage primaryStage) throws Exception {
    window = primaryStage;

    Label label1 = new Label("Welcome to the first scene");
    Button button1 = new Button("Go to scene 2");

    button1.setOnAction(e -> window.setScene(scene2));

    // layout 1 - children in vertical column
    // spaced out by 20 pixels
    VBox layout1 = new VBox(20);
    // add to the layout
    layout1.getChildren().addAll(label1, button1);
    // create the first scene
    scene1 = new Scene(layout1, 200, 200);

    // button2
    Button button2 = new Button("Go to scene 1");
    button2.setOnAction(e -> window.setScene(scene1));

    // layout 2
    StackPane layout2 = new StackPane();
    // add to the layout
    layout2.getChildren().add(button2);
    // create the scene
    scene2 = new Scene(layout2, 600, 300);

    // set default scene where to start the program
    window.setScene(scene1);
    window.setTitle("Title here");
    window.show();
  }
Exemplo n.º 6
0
  /**
   * ****************************************************************** Miscellaneous Tests *
   * ******************************************************************
   */
  @Test
  public void setCurrentPageIndexAndNavigateWithKeyBoard() {
    pagination.setPageCount(25);
    pagination.setPageFactory(
        new Callback<Integer, Node>() {
          @Override
          public Node call(Integer pageIndex) {
            Node n = createPage(pageIndex);
            return n;
          }
        });
    root.setPrefSize(400, 400);
    root.getChildren().add(pagination);
    show();

    tk.firePulse();
    assertTrue(pagination.isFocused());

    KeyEventFirer keyboard = new KeyEventFirer(pagination);
    keyboard.doRightArrowPress();
    tk.firePulse();

    assertEquals(1, pagination.getCurrentPageIndex());

    keyboard.doRightArrowPress();
    tk.firePulse();

    assertEquals(2, pagination.getCurrentPageIndex());
  }
  /** Called when ever either min, max or value changes, so thumb's layoutX, Y is recomputed. */
  void positionThumb() {
    ScrollBar s = getSkinnable();
    double clampedValue = Utils.clamp(s.getMin(), s.getValue(), s.getMax());
    trackPos =
        (s.getMax() - s.getMin() > 0)
            ? ((trackLength - thumbLength)
                * (clampedValue - s.getMin())
                / (s.getMax() - s.getMin()))
            : (0.0F);

    if (!IS_TOUCH_SUPPORTED) {
      if (s.getOrientation() == Orientation.VERTICAL) {
        trackPos += decButton.prefHeight(-1);
      } else {
        trackPos += decButton.prefWidth(-1);
      }
    }

    thumb.setTranslateX(
        snapPosition(
            s.getOrientation() == Orientation.VERTICAL
                ? snappedLeftInset()
                : trackPos + snappedLeftInset()));
    thumb.setTranslateY(
        snapPosition(
            s.getOrientation() == Orientation.VERTICAL
                ? trackPos + snappedTopInset()
                : snappedTopInset()));
  }
  @Override
  public void start(Stage primaryStage) {
    ImageView us = new ImageView(new Image("File:C:/Java/site/image/us.gif"));
    Label lb1 = new Label("US\n50 States", us);
    lb1.setStyle("-fx-border-color: green; -fx-border-width: 2");
    lb1.setContentDisplay(ContentDisplay.BOTTOM);
    lb1.setTextFill(Color.RED);

    Label lb2 = new Label("Circle", new Circle(50, 50, 25));
    lb2.setContentDisplay(ContentDisplay.TOP);
    lb2.setTextFill(Color.ORANGE);

    Label lb3 = new Label("Rectangle", new Rectangle(10, 10, 50, 25));
    lb3.setContentDisplay(ContentDisplay.RIGHT);

    Label lb4 = new Label("Ellipse", new Ellipse(50, 50, 50, 25));
    lb4.setContentDisplay(ContentDisplay.LEFT);

    Ellipse ellipse = new Ellipse(50, 50, 50, 25);
    ellipse.setStroke(Color.GREEN);
    ellipse.setFill(Color.WHITE);
    StackPane stackPane = new StackPane();

    stackPane.getChildren().addAll(ellipse, new Label("JavaFX"));
    Label lb5 = new Label("A pane inside a label", stackPane);
    lb5.setContentDisplay(ContentDisplay.BOTTOM);

    HBox pane = new HBox(20);
    pane.getChildren().addAll(lb1, lb2, lb3, lb4, lb5);

    Scene scene = new Scene(pane, 700, 150);
    primaryStage.setTitle("LabelWithGraphic");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
  /**
   * Adds a "grass" component to the map, aka a null component Useful if the user wants to delete a
   * map component they placed in the map
   *
   * @param x the x coordinate where to add the grass
   * @param y the y coordinate where to add the grass
   * @param map the map to add the grass to
   * @param mapGridGUIDecorator the GUI decorator associated with this map
   * @param mapGridPane the gridPane that would need to be updated with the new view
   * @param imgView the associated image to place in the x,y cell
   */
  private void addGrass(
      int x,
      int y,
      Map map,
      MapGridGUIDecorator mapGridGUIDecorator,
      GridPane mapGridPane,
      ImageView imgView) {
    Coordinate coord = new Coordinate(x, y);
    map.clearCell(coord);

    StackPane sp = mapGridGUIDecorator.redrawCell(x, y, mapGridPane);

    sp.setOnMouseClicked(
        click -> {
          ComponentType currentFocused = MapMakerController.getCurrentFocused();
          if (currentFocused == ComponentType.INTERSECTION) {
            addIntersection(x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView);
          } else if (currentFocused == ComponentType.ROADNS) {
            addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView);
          } else if (currentFocused == ComponentType.ROADEW) {
            addRoadEW(x, y, map, mapGridGUIDecorator, mapGridPane, roadEWImgView);
          }
        });

    // put focus back on Grass
    MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
    MapMakerController.setCurrentFocused(ComponentType.GRASS);
    imgView.requestFocus();
  }
Exemplo n.º 10
0
  @Override
  public void start(Stage primaryStage) {

    primaryStage.setTitle("http://java-buddy.blogspot.com/");

    prepareMyList();
    ListView<MyObject> listView = new ListView<MyObject>();
    ObservableList<MyObject> myObservableList = FXCollections.observableList(myList);
    listView.setItems(myObservableList);

    listView.setCellFactory(
        new Callback<ListView<MyObject>, ListCell<MyObject>>() {
          @Override
          public ListCell<MyObject> call(ListView<MyObject> p) {

            ListCell<MyObject> cell =
                new ListCell<MyObject>() {
                  @Override
                  protected void updateItem(MyObject t, boolean bln) {
                    super.updateItem(t, bln);
                    if (t != null) {
                      setText(t.getDay() + ":" + t.getNumber());
                    }
                  }
                };

            return cell;
          }
        });

    StackPane root = new StackPane();
    root.getChildren().add(listView);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
  }
Exemplo n.º 11
0
  private static Node createVlanNode(String nodeLabel, Pane canvas, ContextMenu contextMenu) {
    int infNumber = 0;

    if (Data.hubMap.size() == 0) {
      infNumber = 1;
    } else {
      for (Map.Entry<String, HUB> entry : Data.hubMap.entrySet()) {
        if (entry.getValue().getInfs().size() == 0) {
          infNumber += 1;
        } else {
          infNumber += entry.getValue().getInfs().size();
        }
      }
    }
    int vlanHeight = ((infNumber * 100) + ((infNumber - 1) * 50));
    Rectangle node = new Rectangle(Data.nodeWidth, vlanHeight);
    node.setFill(Color.ORANGE);

    Label lnodeName = new Label(nodeLabel);

    StackPane nodeContainer = new StackPane();
    nodeContainer.getChildren().addAll(node, lnodeName);
    nodeContainer.relocate(Data.vlanstartPosX, Data.vlanstartPosY);

    return nodeContainer;
  }
Exemplo n.º 12
0
 @PostConstruct
 void init() {
   StackPane buttons = new StackPane(failed, open);
   buttons.getStyleClass().add("progress-icons");
   this.getChildren().addAll(bar, buttons, runButton);
   eventStudio().addAnnotatedListeners(this);
 }
 @Test
 public void testAddingEmptyChoiceBoxToLiveScene() {
   StackPane pane = new StackPane();
   pane.getChildren().add(box);
   startApp(pane);
   assertEquals(0, box.getItems().size());
 }
  @Override
  public void start(Stage primaryStage) {
    String url = handler.getConnectionUrl();

    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    webEngine.load(url);

    StackPane root = new StackPane();
    root.getChildren().add(browser);

    Scene scene = new Scene(root, 650, 500);

    primaryStage.setTitle("Acces Token Getter");
    primaryStage.setScene(scene);
    primaryStage.show();

    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          public void handle(WindowEvent we) {
            try {
              String urlWithAT = webEngine.getLocation();
              handler.setInputUrl(urlWithAT);
              handler.parseUrl();
              handler.writeAccesTokenToFile(OUTPUT_FILE_NAME);
              System.out.print("See file: " + OUTPUT_FILE_NAME);
            } catch (Exception e) {
              System.out.print(e.getMessage());
            }
          }
        });
  }
Exemplo n.º 15
0
  public static StackPane looKasutajaLaud() {
    StackPane kasutjaLaud = new StackPane();
    GridPane ruudustik = looRuudustik();
    // kasutjaLaud.getChildren().add(ruudustik);
    for (Laev laev : Laevastik.kasutajaLaevad) {
      double x =
          laev.laevaKuju
              .getTranslateX(); // küsin kõik laeva omadused ja annan need passiivselt edasi
      double y = laev.laevaKuju.getTranslateY();
      double a = laev.laevaKuju.getWidth();
      double b = laev.laevaKuju.getHeight();
      Paint pilt = laev.laevaKuju.getFill();
      Rectangle ship = new Rectangle(a, b, Color.TRANSPARENT);
      StackPane.setAlignment(ship, Pos.TOP_LEFT);
      ship.setTranslateX(x);
      ship.setTranslateY(y);
      ship.setFill(pilt);
      kasutjaLaud.getChildren().add(ship);

      for (int i = 0; i < laev.laevaPikkus; i++) {
        String koordinaat = laev.laevaKoordinaadid.get(i);
        int rida = Integer.parseInt(String.valueOf(koordinaat.charAt(0)));
        int veerg = Integer.parseInt(String.valueOf(koordinaat.charAt(1)));
        Rectangle kujund = (Rectangle) ruutLaual(ruudustik, rida, veerg);
        if (kujund != null) {
          kujund.setId("laev");
        }
      }
    }
    kasutjaLaud.getChildren().add(ruudustik);
    return kasutjaLaud;
  }
Exemplo n.º 16
0
 private void resetProperties() {
   overlayPane.setVisible(false);
   contentHolder.setTranslateX(0);
   contentHolder.setTranslateY(0);
   contentHolder.setScaleX(1);
   contentHolder.setScaleY(1);
 }
 @Override
 protected double computePrefHeight(double width) {
   final Insets controlInsets = control.getInsets();
   final double top = snapSize(controlInsets.getTop());
   final double bottom = snapSize(controlInsets.getBottom());
   final Insets indicatorInsets = indicator.getInsets();
   final double iLeft = snapSize(indicatorInsets.getLeft());
   final double iRight = snapSize(indicatorInsets.getRight());
   final double iTop = snapSize(indicatorInsets.getTop());
   final double iBottom = snapSize(indicatorInsets.getBottom());
   final double indicatorMax =
       snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom)));
   final Insets progressInsets = progress.getInsets();
   final double pLeft = snapSize(progressInsets.getLeft());
   final double pRight = snapSize(progressInsets.getRight());
   final double pTop = snapSize(progressInsets.getTop());
   final double pBottom = snapSize(progressInsets.getBottom());
   final double progressMax =
       snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom)));
   final Insets tickInsets = tick.getInsets();
   final double tTop = snapSize(tickInsets.getTop());
   final double tBottom = snapSize(tickInsets.getBottom());
   final double indicatorHeight =
       indicatorMax + progressMax + tTop + tBottom + progressMax + indicatorMax;
   return top + indicatorHeight /*+ textGap  + doneText.getLayoutBounds().getHeight()*/ + bottom;
 }
 @Override
 protected double computePrefWidth(double height) {
   final Insets controlInsets = control.getInsets();
   final double left = snapSize(controlInsets.getLeft());
   final double right = snapSize(controlInsets.getRight());
   final Insets indicatorInsets = indicator.getInsets();
   final double iLeft = snapSize(indicatorInsets.getLeft());
   final double iRight = snapSize(indicatorInsets.getRight());
   final double iTop = snapSize(indicatorInsets.getTop());
   final double iBottom = snapSize(indicatorInsets.getBottom());
   final double indicatorMax =
       snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom)));
   final Insets progressInsets = progress.getInsets();
   final double pLeft = snapSize(progressInsets.getLeft());
   final double pRight = snapSize(progressInsets.getRight());
   final double pTop = snapSize(progressInsets.getTop());
   final double pBottom = snapSize(progressInsets.getBottom());
   final double progressMax =
       snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom)));
   final Insets tickInsets = tick.getInsets();
   final double tLeft = snapSize(tickInsets.getLeft());
   final double tRight = snapSize(tickInsets.getRight());
   final double indicatorWidth =
       indicatorMax + progressMax + tLeft + tRight + progressMax + indicatorMax;
   return left
       + indicatorWidth
       + /*Math.max(indicatorWidth, doneText.getLayoutBounds().getWidth()) + */ right;
 }
Exemplo n.º 19
0
  @Override
  public void handle(KeyEvent event) {
    if (!(event.getSource() instanceof TextArea)) {
      return;
    }
    if (System.currentTimeMillis() - lastCommandTime < 200) {
      return;
    }
    final Stage dialog = new Stage();
    final StackPane pane = new StackPane();
    dialog.setScene(new Scene(pane));
    final VBox vbox = new VBox();
    pane.getChildren().add(vbox);

    vbox.setAlignment(Pos.CENTER);
    vbox.getChildren().add(new Label());
    vbox.getChildren().add(new Label("   hey! ツラタン...   "));
    vbox.getChildren().add(new Label());
    final Button bottom = new Button();
    bottom.setText("OK");
    bottom.setOnAction(
        boxEvent -> {
          dialog.close();
        });
    vbox.getChildren().add(bottom);
    vbox.getChildren().add(new Label(""));
    dialog.showAndWait();
    lastCommandTime = System.currentTimeMillis();
  }
  /**
   * Adds a section of road with 2 lanes that travels in the directions east and west
   *
   * @param x the x coordinate where to add the road
   * @param y the y coordinate where to add the road
   * @param map the map to add the road to
   * @param mapGridGUIDecorator the GUI decorator associated with this map
   * @param mapGridPane the gridPane that would need to be updated with the new view
   * @param imgView the associated image to place in the x,y cell
   */
  private void addRoadEW(
      int x,
      int y,
      Map map,
      MapGridGUIDecorator mapGridGUIDecorator,
      GridPane mapGridPane,
      ImageView imgView) {
    Coordinate coord = new Coordinate(x, y);
    Road road = new Road(coord, coord);
    try {
      road.addLane(new Lane(coord, coord, MapDirection.EAST));
      road.addLane(new Lane(coord, coord, MapDirection.WEST));
      map.addRoad(road);
      StackPane sp = mapGridGUIDecorator.redrawCell(x, y, mapGridPane);

      sp.setOnMouseClicked(
          click -> {
            ComponentType currentFocused = MapMakerController.getCurrentFocused();
            if (currentFocused == ComponentType.INTERSECTION) {
              addIntersection(x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView);
            } else if (currentFocused == ComponentType.ROADNS) {
              addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView);
            } else if (currentFocused == ComponentType.GRASS) {
              addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView);
            }
          });

      // put focus back on RoadEW
      MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
      MapMakerController.setCurrentFocused(ComponentType.ROADEW);
      imgView.requestFocus();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 21
0
  @PostConstruct
  public void onStartPerspective(
      PerspectiveLayout perspectiveLayout,
      FXComponentLayout layout,
      ResourceBundle resourceBundle) {
    // Top Buttons component
    StackPane topPane = new StackPane();

    // Center Component
    StackPane centerPane = new StackPane();
    centerPane.setAlignment(Pos.TOP_CENTER);

    // Bottom Component
    bottomPane = new StackPane();
    bottomPane.setAlignment(Pos.BOTTOM_CENTER);

    // Bottom Bar Component
    bottomBar = new StackPane();
    bottomBar.setAlignment(Pos.BOTTOM_CENTER);

    // Attach to PERSPECTIVE
    mainSplit = constructSplitPane(constructScrollPane(centerPane), bottomPane);
    mainPane = constructMainPane(mainSplit, bottomBar);
    perspectiveLayout.registerTargetLayoutComponent(GuiConfig.TARGET_CONTAINER_TOP, topPane);
    perspectiveLayout.registerTargetLayoutComponent(GuiConfig.TARGET_CONTAINER_ABOUT, centerPane);
    perspectiveLayout.registerTargetLayoutComponent(GuiConfig.TARGET_CONTAINER_PANE, bottomPane);
    perspectiveLayout.registerTargetLayoutComponent(GuiConfig.TARGET_CONTAINER_BAR, bottomBar);

    // Define main pane
    borderPane = constructBorderPane(perspectiveLayout, topPane, mainPane);
  }
  // REMOVE ME
  public static Node createIconContent() {
    StackPane sp = new StackPane();
    BorderPane borderPane = new BorderPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    borderPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle recTop = new Rectangle(62, 5, Color.web("#349b00"));
    recTop.setStroke(Color.BLACK);
    Rectangle recBottom = new Rectangle(62, 14, Color.web("#349b00"));
    recBottom.setStroke(Color.BLACK);
    Rectangle recLeft = new Rectangle(20, 41, Color.TRANSPARENT);
    recLeft.setStroke(Color.BLACK);
    Rectangle recRight = new Rectangle(20, 41, Color.TRANSPARENT);
    recRight.setStroke(Color.BLACK);
    Rectangle centerRight = new Rectangle(20, 41, Color.TRANSPARENT);
    centerRight.setStroke(Color.BLACK);
    borderPane.setRight(recRight);
    borderPane.setTop(recTop);
    borderPane.setLeft(recLeft);
    borderPane.setBottom(recBottom);
    borderPane.setCenter(centerRight);

    sp.getChildren().addAll(rectangle, borderPane);
    return new Group(sp);
  }
  private void initComponents() {
    Platform.runLater(
        () -> {
          myPane = new StackPane();
          myWebComponent = new WebView();
          myEngine = myWebComponent.getEngine();

          if (myShowProgress) {
            myProgressBar = makeProgressBarWithListener();
            myWebComponent.setVisible(false);
            myPane.getChildren().addAll(myWebComponent, myProgressBar);
          } else {
            myPane.getChildren().add(myWebComponent);
          }
          if (myLinkInNewBrowser) {
            initHyperlinkListener();
          }
          Scene scene = new Scene(myPane);
          myPanel.setScene(scene);
          myPanel.setVisible(true);
          updateLaf(
              LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo);
        });

    add(myPanel, BorderLayout.CENTER);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  }
Exemplo n.º 24
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    // creating Layout
    final Group root = new Group();
    Scene scene = new Scene(root, 400, 400);
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    StackPane waitingPane = new StackPane();
    final ProgressBar progress = new ProgressBar();
    Label load = new Label("loading things...");
    progress.setTranslateY(-25);
    load.setTranslateY(25);
    waitingPane.getChildren().addAll(new Rectangle(400, 400, Color.WHITE), load, progress);
    root.getChildren().add(waitingPane);

    // Task for computing the Panels:
    Task<Void> task =
        new Task<Void>() {
          @Override
          protected Void call() throws Exception {
            for (int i = 0; i < 20; i++) {
              try {
                Thread.sleep(new Random().nextInt(1000));
              } catch (InterruptedException ex) {
                ex.printStackTrace();
              }
              final double prog = i * 0.05;
              Platform.runLater(
                  new Runnable() {
                    public void run() {
                      progress.setProgress(prog);
                    }
                  });
            }
            return null;
          }
        };

    // stateProperty for Task:
    task.stateProperty()
        .addListener(
            new ChangeListener<Worker.State>() {

              @Override
              public void changed(
                  ObservableValue<? extends State> observable,
                  State oldValue,
                  Worker.State newState) {
                if (newState == Worker.State.SUCCEEDED) {
                  loadPanels(root);
                }
              }
            });

    // start Task
    new Thread(task).start();

    primaryStage.show();
  }
 @Override
 public Point2D _getMidpoint() {
   StackPane tabRegion = getTabRegion();
   Bounds boundsInParent = tabRegion.getBoundsInParent();
   double x = boundsInParent.getWidth() / 2;
   double y = boundsInParent.getHeight() / 2;
   return tabRegion.localToParent(x, y);
 }
 @Test
 public void testSelectingItemBeforeFirstShow() {
   StackPane pane = new StackPane();
   pane.getChildren().add(box);
   box.getItems().addAll("Apple", "Orange", "Banana");
   box.getSelectionModel().select("Orange");
   startApp(pane);
   assertEquals(1, box.getSelectionModel().getSelectedIndex());
 }
Exemplo n.º 27
0
 private void bindSizeTo(StackPane track, ScrollBar scrollBar) {
   if (scrollBar.getOrientation() == Orientation.VERTICAL) {
     widthProperty().bind(track.widthProperty());
     heightProperty().bind(thickness);
   } else {
     widthProperty().bind(thickness);
     heightProperty().bind(track.widthProperty());
   }
 }
 @Override
 public void start(Stage stage) throws Exception {
   StackPane sp = new StackPane();
   sp.getChildren().add(createDemoNode());
   Scene scene = new Scene(sp, 768, 512);
   stage.setScene(scene);
   stage.setTitle("Orson Charts: RangeMarkerFXDemo1.java");
   stage.show();
 }
  protected Node buildtoolsFiltroAlumno(boolean index) {

    HBox hBox = new HBox(10);
    hBox.setMaxHeight(maxHeightCabezera);
    hBox.setMaxWidth(DefaultAncho);
    hBox.setMinWidth(DefaultAncho);
    hBox.setPadding(new Insets(10, 10, 5, 10));
    hBox.setStyle("-fx-background-color:black");

    hBox.getChildren().add(txtFiltroTitulo);
    hBox.getChildren()
        .add(
            TextBuilder.create()
                .text("|")
                .fill(Color.WHITE)
                .font(Font.font("MS UI Gothic", FontWeight.BOLD, 28))
                .build());
    hBox.getChildren().add(txtFiltroAutor);
    hBox.getChildren()
        .add(
            TextBuilder.create()
                .text("|")
                .fill(Color.WHITE)
                .font(Font.font("MS UI Gothic", FontWeight.BOLD, 28))
                .build());
    hBox.getChildren().add(txtFiltroEditorial);
    hBox.getChildren()
        .add(
            TextBuilder.create()
                .text("|")
                .fill(Color.WHITE)
                .font(Font.font("MS UI Gothic", FontWeight.BOLD, 28))
                .build());
    hBox.getChildren().add(txtRanking);
    hBox.getChildren()
        .add(
            TextBuilder.create()
                .text("|")
                .fill(Color.WHITE)
                .font(Font.font("MS UI Gothic", FontWeight.BOLD, 28))
                .build());
    // Agregando el Efecto Bloom
    Bloom bloom = BloomBuilder.create().threshold(0f).build();
    hBox.setEffect(bloom);

    if (index) {
      StackPane agrupador = new StackPane();
      agrupador.getChildren().add(hBox);
      agrupador.getChildren().add(imgIndex);
      StackPane.setAlignment(imgIndex, Pos.BOTTOM_RIGHT);
      StackPane.setMargin(imgIndex, new Insets(0, -6, -17, 0));
      return agrupador;
    } else {
      return hBox;
    }
  }
Exemplo n.º 30
0
 private void initChangeListeners() {
   overlayCloseProperty()
       .addListener(
           (o, oldVal, newVal) -> {
             if (overlayPane != null) {
               if (newVal) overlayPane.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler);
               else overlayPane.removeEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler);
             }
           });
 }