private boolean validateText(String text) {
   try {
     int i = Integer.parseInt(text);
     if (i > 50 || i < 0) {
       Stage dialogStage = new Stage();
       dialogStage.initModality(Modality.WINDOW_MODAL);
       dialogStage.setScene(
           new Scene(
               VBoxBuilder.create()
                   .children(new Text("Wartoœæ kroku musi byæ wiêksza od 0 oraz mniejsza od 50."))
                   .alignment(Pos.CENTER)
                   .padding(new Insets(25))
                   .build()));
       dialogStage.show();
       return false;
     }
   } catch (NumberFormatException nfe) {
     Stage dialogStage = new Stage();
     dialogStage.initModality(Modality.WINDOW_MODAL);
     dialogStage.setScene(
         new Scene(
             VBoxBuilder.create()
                 .children(new Text("Wpisana wartosc musi byc liczba calkowita"))
                 .alignment(Pos.CENTER)
                 .padding(new Insets(25))
                 .build()));
     dialogStage.show();
     return false;
   }
   return true;
 }
Example #2
0
 /** Test of renderChildren method, of class Activity. */
 @Test
 public void testCreateChildren() throws Exception {
   System.out.println("renderChildren");
   // Setup
   ChildPane childPane = new ChildPane();
   childPane.setChild("Child");
   VBox vbox = VBoxBuilder.create().children(childPane).build();
   Parent parent = new Parent();
   parent.setScene(vbox);
   Data data = new Data();
   Map<Field, Object> fieldParams = new HashMap<Field, Object>();
   for (Field field : data.getClass().getDeclaredFields()) {
     field.setAccessible(true);
     fieldParams.put(field, field.get(data));
   }
   RenderParameter renderParam = new RenderParameter();
   String id = renderParam.putParam("checkForLabel", "CheckForLabel");
   childPane.setId(id);
   parent.createChildren(fieldParams, renderParam, ValidationResult.getEmptyResult());
   // Assertoin
   Child child = (Child) parent.getChildActivities(Child.class).get(0);
   assertNotNull(child);
   assertNotNull(child.getScene());
   assertEquals(childPane, child.getScene());
   assertEquals(parent, child.getParent());
   VBox cvbox = (VBox) child.getScene().getChildren().get(0);
   assertTrue(cvbox.getChildren().get(0) instanceof Button);
   assertTrue(cvbox.getChildren().get(1) instanceof Label);
   assertEquals(data.checkForButton, ((Button) cvbox.getChildren().get(0)).getText());
   assertEquals("CheckForLabel", ((Label) cvbox.getChildren().get(1)).getText());
 }
Example #3
0
  public ProjectPlaybackPanel(ProjectItem canvas) {
    super(canvas);
    linkButtonContainer = HBoxBuilder.create().build();
    playbackContainer =
        HBoxBuilder.create()
            .alignment(Pos.CENTER)
            .spacing(9)
            .children(
                separator(),
                playButton,
                separator(),
                time,
                requests,
                failures,
                resetButton(),
                limitsButton())
            .build();

    getChildren()
        .setAll(
            VBoxBuilder.create()
                .spacing(0)
                .children(playbackContainer, linkButtonContainer)
                .build());

    setPadding(new Insets(7, 0, 0, 0));
    getStyleClass().add("project-playback-panel");
    setMaxWidth(750);
  }
Example #4
0
 @Override
 protected Parent getRootNode() {
   return VBoxBuilder.create()
       .children(
           ButtonBuilder.create().id("button1").text("Button A").defaultButton(true).build(),
           ButtonBuilder.create().id("button2").text("Button B").build(),
           TextFieldBuilder.create().id("text").build())
       .build();
 }
 public TaskProgressIndicator() {
   getChildren()
       .setAll(
           VBoxBuilder.create()
               .children(
                   label = LabelBuilder.create().text("Please wait...").build(),
                   progress = ProgressBarBuilder.create().build())
               .build());
 }
  public void start(final Stage stage) throws Exception {
    final Label statusLabel = new Label("Status");
    final Button runButton = new Button("Run");
    final ListView<String> peopleView = new ListView<String>();
    peopleView.setPrefSize(220, 162);
    final ProgressBar progressBar = new ProgressBar();
    progressBar.prefWidthProperty().bind(peopleView.prefWidthProperty());

    runButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            final Task task =
                new Task<ObservableList<String>>() {
                  @Override
                  protected ObservableList<String> call() throws InterruptedException {
                    updateMessage("Finding friends . . .");
                    for (int i = 0; i < 10; i++) {
                      Thread.sleep(200);
                      updateProgress(i + 1, 10);
                    }
                    updateMessage("Finished.");
                    return FXCollections.observableArrayList(
                        "John", "Jim", "Geoff", "Jill", "Suki");
                  }
                  //          @Override protected void done() {
                  //            super.done();
                  //            System.out.println("This is bad, do not do this, this thread " +
                  // Thread.currentThread() + " is not the FXApplication thread.");
                  //            runButton.setText("Voila!");
                  //          }
                };

            statusLabel.textProperty().bind(task.messageProperty());
            runButton.disableProperty().bind(task.runningProperty());
            peopleView.itemsProperty().bind(task.valueProperty());
            progressBar.progressProperty().bind(task.progressProperty());
            task.stateProperty()
                .addListener(
                    new ChangeListener<Worker.State>() {
                      @Override
                      public void changed(
                          ObservableValue<? extends Worker.State> observableValue,
                          Worker.State oldState,
                          Worker.State newState) {
                        if (newState == Worker.State.SUCCEEDED) {
                          System.out.println(
                              "This is ok, this thread "
                                  + Thread.currentThread()
                                  + " is the JavaFX Application thread.");
                          runButton.setText("Voila!");
                        }
                      }
                    });

            new Thread(task).start();
          }
        });

    final VBox layout =
        VBoxBuilder.create()
            .spacing(8)
            .children(
                VBoxBuilder.create()
                    .spacing(5)
                    .children(
                        HBoxBuilder.create().spacing(10).children(runButton, statusLabel).build(),
                        progressBar)
                    .build(),
                peopleView)
            .build();
    layout.setStyle("-fx-background-color: cornsilk; -fx-padding:10; -fx-font-size: 16;");
    Scene scene = new Scene(layout);
    stage.setScene(scene);
    stage.show();
  }
 @Override
 protected Parent getRootNode() {
   TextField textField = new TextField();
   return VBoxBuilder.create().children(textField).build();
 }