public InputDialog(final String title, final Object[] data) {
    initOwner(null);

    setTitle(title);

    if (0 != data.length % 2) {
      throw new IllegalArgumentException("Object data must be even!");
    }

    final Group root = new Group();
    final Scene scene = new Scene(root);
    setScene(scene);

    final GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(5);
    gridpane.setVgap(5);

    for (int i = 0; i < data.length; i++) {
      if (0 == i % 2) {
        final Label label = new Label((String) data[i]);
        gridpane.add(label, 0, i / 2);
      } else {
        gridpane.add((Node) data[i], 1, (i - 1) / 2);
      }
    }

    gridpane.add(submit, 1, data.length / 2 + 1);
    GridPane.setHalignment(submit, HPos.RIGHT);
    root.getChildren().add(gridpane);
    sizeToScene();
    show();
  }
Ejemplo n.º 2
0
  private void updateChildren(boolean useButtons) {
    hboxLayout.getChildren().clear();
    hboxLayout.getChildren().addAll(createChildren(useButtons));

    vboxLayout.getChildren().clear();
    vboxLayout.getChildren().addAll(createChildren(useButtons));

    flowLayout.getChildren().clear();
    flowLayout.getChildren().addAll(createChildren(useButtons));

    List<Node> contents1 = createChildren(useButtons);
    gridLayout.getChildren().clear();
    gridLayout.add(contents1.get(0), 0, 0);
    gridLayout.add(contents1.get(1), 1, 0);
    gridLayout.add(contents1.get(2), 0, 1, 2, 1);

    List<Node> contents = createChildren(useButtons);
    borderLayout.getChildren().clear();
    borderLayout.setLeft(contents.get(0));
    borderLayout.setTop(contents.get(1));
    borderLayout.setRight(contents.get(2));
    borderLayout.setBottom(contents.get(3));
    borderLayout.setCenter(contents.get(4));

    stackLayout.getChildren().clear();
    stackLayout.getChildren().addAll(createChildren(useButtons));

    tileLayout.getChildren().clear();
    tileLayout.getChildren().addAll(createChildren(useButtons));
  }
Ejemplo n.º 3
0
 public static GridPane looArvutiLaud() {
   GridPane arvutiRuudustik = looRuudustik();
   for (Laev laev : Laevastik.arvutijaLaevad) {
     for (int i = 0; i < laev.laevaPikkus; i++) {
       String koordinaat = laev.laevaKoordinaadid.get(i);
       if (koordinaat.length()
           < 3) { // tuleneb laevade paigutamise loogikast. Ruudustik on suurem kui 10
         int rida = Integer.parseInt(String.valueOf(koordinaat.charAt(1)));
         int veerg = tahed.indexOf(koordinaat.charAt(0));
         Rectangle ruut = new Rectangle(50, 50, Color.TRANSPARENT);
         ruut.setId("laev");
         ruut.setStroke(Color.BLACK);
         arvutiRuudustik.add(ruut, rida - 1, veerg);
       } else {
         int veerg = tahed.indexOf(koordinaat.charAt(0));
         int rida = 10;
         Rectangle ruut = new Rectangle(50, 50, Color.TRANSPARENT);
         ruut.setId("laev");
         ruut.setStroke(Color.BLACK);
         arvutiRuudustik.add(ruut, rida - 1, veerg);
       }
     }
   }
   return arvutiRuudustik;
 }
 private void makeHexEquivalentStep(int stepID) {
   hexEquivalentStep.addFormattedStepHeader("hexadecimal equivalencies");
   hexEquivalentStep.setResultStepID(stepID);
   hexEquivalentStep.addStepComment(
       "This step shows how each "
           + "decimal value is assigned a representative equivalent when "
           + "converted. This is done through pre-determined "
           + "representations of each individual symbol as outlined "
           + "in the equivalency table shown to the right.");
   GridPane decimalTable = new GridPane();
   decimalTable = makeBigCharTable();
   for (int i = 0; i < decValues.size(); i++) {
     BigCharBox bigCharBox = new BigCharBox();
     decimalTable.add(bigCharBox, i, 0);
     BigCharLabel bigCharLabel = new BigCharLabel(decValues.get(i));
     decimalTable.add(bigCharLabel, i, 0);
   }
   GridPane equivalencyTable = new GridPane();
   equivalencyTable = makeBigCharTable();
   for (int i = 0; i < hexSymbols.size(); i++) {
     BigCharBox bigCharBox = new BigCharBox();
     equivalencyTable.add(bigCharBox, i, 0);
     BigCharLabel bigCharLabel = new BigCharLabel(hexSymbols.get(i));
     equivalencyTable.add(bigCharLabel, i, 0);
   }
   hexEquivalentStep.addStepContent(decimalTable);
   hexEquivalentStep.addStepPostContent(equivalencyTable);
 }
  private void showDialog(String title, String message, Throwable throwable) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle(title);
    alert.setHeaderText(title);
    alert.setContentText(message);
    StringWriter stringWriter = new StringWriter();
    PrintWriter printwriter = new PrintWriter(stringWriter);
    throwable.printStackTrace(printwriter);
    String exceptionText = stringWriter.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
  }
Ejemplo n.º 6
0
  public void open() throws IOException {

    paneCenter.getChildren().clear();

    String station = (String) cbStations.getValue();

    File f = new File("database\\" + station + "\\status.txt");
    FileReader fr1 = new FileReader(f);
    LineNumberReader ln = new LineNumberReader(fr1);
    int count = 0;
    while (ln.readLine() != null) {
      count++;
    }
    ln.close();
    fr1.close();

    FileReader fr2 = new FileReader(f);
    BufferedReader br = new BufferedReader(fr2);

    paneCenter.add(new Label("Last seen : " + (br.readLine())), 0, 0);

    for (int i = 1; i < count; i++) {
      paneCenter.add(new Label(br.readLine()), 0, i);
    }
    br.close();
    fr2.close();

    addQuantityToCB();
  }
Ejemplo n.º 7
0
  public GridPane addParameterPane() {
    // GridPane - Erzeugung und Initialisierung
    GridPane grid = new GridPane();
    grid.setVgap(5);

    // Überschrift - Erzeugung und Hinzufügen zu GridPane
    Text title = new Text("Einstellungen");
    grid.add(title, 0, 0);

    // Game Zone Size UI Elemente - Erzeugung und Hinzufügen zu GridPane
    Text gameZoneSizeLabel = new Text("Size of Gamezone:");
    grid.add(gameZoneSizeLabel, 0, 1);

    TextField gameZoneSizeTextField = new TextField();
    grid.add(gameZoneSizeTextField, 1, 1);

    // Cell Number UI Elemente - Erzeugung und Hinzufügen zu GridPane
    Text numberOfLifeCellsLabel = new Text("Number of Life Cells:");
    grid.add(numberOfLifeCellsLabel, 0, 2);

    TextField numberOfLifeCellsTextField = new TextField();
    grid.add(numberOfLifeCellsTextField, 1, 2);

    return grid;
  }
Ejemplo n.º 8
0
  public FXDialog() {
    // Setup general stage and main grid
    msgLabel = detLabel = null;
    stage = new Stage();
    stage.initModality(Modality.WINDOW_MODAL);
    grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(10, 10, 10, 10));

    // Add the OK button (it's a default)
    buttonArea = new HBox(10);
    Button okBtn = new Button("OK");
    okBtn.setOnAction(
        event -> {
          okPressed = true;
          stage.hide();
        });
    buttonArea.getChildren().add(okBtn);
    grid.add(buttonArea, 1, 2);

    // ImageView imageView = new ImageView();
    // grid.add(imageView, 0, 0);

    // Add a 50 width pane for spacing and also as we plan on adding an image at 0,0
    // some time in the future
    Pane pane = new Pane();
    pane.setMinWidth(50);
    grid.add(pane, 0, 1);

    stage.setScene(new Scene(grid, 250, 100));
    okPressed = false;
  }
Ejemplo n.º 9
0
  @Override
  protected BorderPane getPane() {

    BorderPane pane = new BorderPane();
    GridPane paneFullTime = new GridPane();

    paneFullTime.setAlignment(Pos.CENTER);
    paneFullTime.setPadding(new Insets(11, 12, 13, 14));
    paneFullTime.setHgap(5.5);
    paneFullTime.setVgap(5.5);

    paneFullTime.add(text, 0, 0);
    paneFullTime.add(tfSSN, 1, 0);

    paneFullTime.add(arrNonCreditChBox[0], 0, 2);
    paneFullTime.add(arrNonCreditChBox[1], 0, 3);
    paneFullTime.add(arrNonCreditChBox[2], 0, 4);
    paneFullTime.add(submitBt, 1, 5);

    pane.setCenter(paneFullTime);

    submitBt.setOnAction(
        e -> {
          checkingRequirements();
          connectToDB();
          submitToDB();
          pane.setCenter(new Congratulation().getPane());
        });
    return pane;
  }
 private void setUpStepTextField() {
   Label label = new Label("Podaj krok: ");
   step = new TextField();
   step.setPromptText("Podaj krok");
   GridPane.setMargin(step, new Insets(10, 50, 10, 50));
   GridPane.setMargin(label, new Insets(50, 50, 10, 50));
   gridPane.add(label, 0, 0);
   gridPane.add(step, 0, 1);
 }
  /** Shows this Notifications popup */
  public void show() {
    // Use a gridpane to display the component
    GridPane pane = new GridPane();
    // Need a new scene to display the popup
    Scene scene = new Scene(pane);

    // Set the padding and gaps to 5px
    pane.setPadding(new Insets(5));
    pane.setHgap(5);
    pane.setVgap(5);

    // Add the message as a label if there is one
    if (message != null) {
      Label lblMsg = new Label(message);

      lblMsg.setPadding(new Insets(20));
      pane.add(lblMsg, 0, 0, 3, 1);
    }

    // Add the yes/no buttons if there are any
    if (yesNoBtns) {
      Button btnYes = new Button("Yes");
      Button btnNo = new Button("No");

      // Add the events and set as default/cancel buttons
      btnYes.setDefaultButton(true);
      btnYes.setOnAction(yesNoEvent);
      btnNo.setCancelButton(true);
      btnNo.setOnAction(yesNoEvent);

      // Align them to the right
      GridPane.setHalignment(btnNo, HPos.RIGHT);
      GridPane.setHalignment(btnYes, HPos.RIGHT);

      // Push the buttons to the right
      Region spacer = new Region();
      GridPane.setHgrow(spacer, Priority.ALWAYS);

      pane.add(spacer, 0, 1);
      pane.add(btnNo, 1, 1);
      pane.add(btnYes, 2, 1);
    }

    // Create a new stage to show the scene
    Stage stage = new Stage();

    stage.setScene(scene);
    // Don't want the popup to be resizable
    stage.setResizable(false);
    // Set the title if there is one
    if (title != null) {
      stage.setTitle(title);
    }
    // Resize it and show it
    stage.sizeToScene();
    stage.showAndWait();
  }
Ejemplo n.º 12
0
  private GridPane createLoadingIndicator() {
    GridPane grid = createGridPane();
    ProgressIndicator loadingIndicator = new ProgressIndicator();
    Label labelLoading = new Label("Waiting for login");
    grid.add(loadingIndicator, 0, 0);
    grid.add(labelLoading, 0, 1);

    return grid;
  }
  @FXML
  private void HandleLinkButtonAction(ActionEvent event) {
    String link = SourceText.getSelectedText();

    // Create the custom dialog.
    Dialog<Pair<String, String>> dialog = new Dialog<>();
    dialog.setTitle("Détail du lien");
    dialog.setHeaderText("");

    // Set the icon (must be included in the project).
    dialog.setGraphic(
        new ImageView(MainApp.class.getResource("assets/static/icons/link.png").toString()));

    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    // Create the username and password labels and fields.
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));

    TextField tLink = new TextField();
    tLink.setText(link);
    TextField tLabel = new TextField();
    tLabel.setText(link);

    grid.add(new Label("Lien:"), 0, 0);
    grid.add(tLink, 1, 0);
    grid.add(new Label("Titre du lien"), 0, 1);
    grid.add(tLabel, 1, 1);

    dialog.getDialogPane().setContent(grid);

    // Request focus on the username field by default.
    Platform.runLater(tLink::requestFocus);

    // Convert the result to a username-password-pair when the login button
    // is clicked.
    dialog.setResultConverter(
        dialogButton -> {
          if (dialogButton == ButtonType.OK) {
            return new Pair<>(tLink.getText(), tLabel.getText());
          }
          return null;
        });

    Optional<Pair<String, String>> result = dialog.showAndWait();

    result.ifPresent(
        tLinkTLabel ->
            SourceText.replaceText(
                SourceText.getSelection(),
                "[" + tLinkTLabel.getValue() + "](" + tLinkTLabel.getKey() + ")"));

    SourceText.requestFocus();
  }
Ejemplo n.º 14
0
 public Puzzle(int[][] answers) {
   initializePuzzle(answers);
   masterGrid = new GridPane();
   GridPane grid1 = block1.returnGrid();
   GridPane grid2 = block2.returnGrid();
   GridPane grid3 = block3.returnGrid();
   masterGrid.add(grid1, 1, 1);
   masterGrid.add(grid2, 1, 2);
   masterGrid.add(grid3, 2, 1);
 }
Ejemplo n.º 15
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();
  }
Ejemplo n.º 16
0
 private void initTopBar() {
   title.setId("title");
   title.setWrapText(true);
   toggleEarthMode.setId("button");
   title.setTextAlignment(TextAlignment.CENTER);
   toggleEarthMode.setTextAlignment(TextAlignment.CENTER);
   toggleEarthMode.setWrapText(true);
   topBar.setHgap(7);
   topBar.add(title, 15, 0);
   topBar.add(toggleEarthMode, 0, 0);
 }
Ejemplo n.º 17
0
  @Override
  public Pane getVisSettings() {

    GridPane pane = new GridPane();
    pane.setPadding(new Insets(10, 0, 0, 0));
    pane.setHgap(5);
    pane.setVgap(5);

    // Dimension selection box
    ComboBox<String> dimCombo = new ComboBox<>();
    ObservableList<String> dimensions = FXCollections.observableArrayList();
    dimensions.add("X");
    dimensions.add("Y");
    dimensions.add("Z");
    dimCombo.setItems(dimensions);
    dimCombo.setValue(dimensions.get(2));
    dimCombo
        .valueProperty()
        .addListener(
            (ov, oldStr, newStr) -> {
              if (newStr.equals("X")) {
                renderer.setViewingDimension(0);
              } else if (newStr.equals("Y")) {
                renderer.setViewingDimension(1);
              } else {
                renderer.setViewingDimension(2);
              }
              renderer.render();
              Controller.getInstance().updateHistogram();
            });

    Label dimLabel = new Label();
    dimLabel.setText("Projection dimension: ");
    dimLabel.setLabelFor(dimCombo);

    pane.add(dimLabel, 0, 0);
    pane.add(dimCombo, 1, 0);

    // Scale checkbox
    CheckBox scaleBox = new CheckBox("Scale: ");
    scaleBox.setSelected(true);
    scaleBox
        .selectedProperty()
        .addListener(
            (ov, old_val, new_val) -> {
              renderer.setScaling(new_val);
              renderer.render();
            });
    pane.add(scaleBox, 0, 1);

    return pane;
  }
Ejemplo n.º 18
0
  private String showCreateOrRenameDialog(
      final String title,
      final String headerText,
      final File parent,
      final String name,
      final NameVerifier nameVerifier) {
    final Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(title);
    alert.setHeaderText(headerText);

    final GridPane contentContainer = new GridPane();
    contentContainer.setPadding(new Insets(8));
    contentContainer.setHgap(8);
    contentContainer.setVgap(8);

    contentContainer.add(new Label("Parent:"), 0, 0);
    final TextField parentTextField = new TextField();
    parentTextField.setEditable(false);

    parentTextField.setText(parent.getAbsolutePath());
    contentContainer.add(parentTextField, 1, 0);

    contentContainer.add(new Label("Name:"), 0, 1);

    final TextField dirNameTextField = new TextField();
    dirNameTextField.setText(name);
    GridPane.setHgrow(dirNameTextField, Priority.ALWAYS);
    contentContainer.add(dirNameTextField, 1, 1);

    final InvalidationListener updateDisableInvalidationListener =
        (observable) -> {
          final String dirName = dirNameTextField.getText();
          final Node okButton = alert.getDialogPane().lookupButton(ButtonType.OK);
          if (isEmpty(dirName)) okButton.setDisable(true);
          else {
            final boolean nameAcceptable = nameVerifier.isNameAcceptable(dirName);
            okButton.setDisable(!nameAcceptable);
          }
        };
    dirNameTextField.textProperty().addListener(updateDisableInvalidationListener);

    alert.getDialogPane().setContent(contentContainer);
    alert.setOnShowing(
        (event) -> {
          dirNameTextField.requestFocus();
          dirNameTextField.selectAll();
          updateDisableInvalidationListener.invalidated(null);
        });

    if (alert.showAndWait().get() == ButtonType.OK) return dirNameTextField.getText();
    else return null;
  }
Ejemplo n.º 19
0
  public void initContent(GridPane pane) {
    // pane.setGridLinesVisible(true);
    pane.setPadding(new Insets(20));
    pane.setHgap(10);
    pane.setVgap(20);

    // header label
    Label lblHeader = new Label("Alert Dialogs");
    pane.add(lblHeader, 1, 0);
    lblHeader.setTextFill(Color.DARKBLUE);
    lblHeader.setFont(Font.font("Calibri", FontWeight.BOLD, 36));

    // label for input text field
    Label lblInput = new Label("A Text field:");
    pane.add(lblInput, 0, 1);
    lblInput.setFont(Font.font("Calibri", FontWeight.NORMAL, 20));

    // input text field
    this.txfInput = new TextField();
    pane.add(txfInput, 1, 1);
    this.txfInput.setMinHeight(30.0);
    this.txfInput.setPromptText("Enter some text and save.");

    // horizontal box for buttons
    HBox hbox = new HBox(20);
    pane.add(hbox, 1, 2);
    hbox.setAlignment(Pos.CENTER);

    // info button
    Button btnInfo = new Button("Info");
    btnInfo.setOnAction(event -> this.infoAction());
    hbox.getChildren().add(btnInfo);

    // save button
    Button btnSave = new Button("Save");
    btnSave.setOnAction(event -> this.saveAction());
    hbox.getChildren().add(btnSave);

    // clear button
    Button btnClear = new Button("Clear");
    btnClear.setOnAction(event -> this.clearAction());
    hbox.getChildren().add(btnClear);

    // status text
    this.txtStatus = new Text();
    pane.add(txtStatus, 0, 4, 3, 1);
    this.txtStatus.setFont(Font.font("Calibri", FontWeight.NORMAL, 20));
    this.txtStatus.setFill(Color.FIREBRICK);
    this.txtStatus.setText("An example of Alert Dialogs. Enter some text and save.");

    btnInfo.requestFocus();
  }
  /**
   * Set lower and upper limits for an ordinate
   *
   * @param axis Axis to configure
   */
  void setOrdinateRange(final NumberAxis axis) {
    axis.setAutoRange(false);
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(0, 10, 0, 10));
    final TextField tfMax;
    final TextField tfMin;
    final TextField tfTick;
    final TextField tfFuente;
    grid.add(new Label("Axis"), 0, 0);
    grid.add(new Label(axis.getLabel()), 1, 0);
    grid.add(new Label("Lower"), 0, 1);
    grid.add(tfMin = new TextField(), 1, 1);
    grid.add(new Label("Upper"), 0, 2);
    grid.add(tfMax = new TextField(), 1, 2);
    grid.add(new Label("Space"), 0, 3);
    grid.add(tfTick = new TextField(), 1, 3);

    tfMin.setText(String.valueOf(axis.getLowerBound()));
    tfMax.setText(String.valueOf(axis.getUpperBound()));
    tfTick.setText(String.valueOf(axis.getTickUnit().getSize()));

    new PseudoModalDialog(skeleton, grid, true) {
      @Override
      public boolean validation() {
        axis.setLowerBound(Double.valueOf(tfMin.getText()));
        axis.setUpperBound(Double.valueOf(tfMax.getText()));
        axis.setTickUnit(new NumberTickUnit(Double.valueOf(tfTick.getText())));
        return true;
      }
    }.show();
  }
  /** @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean) */
  @Override
  protected void updateItem(ResultsItem item, boolean empty) {
    super.updateItem(item, empty);
    if (item != null) {
      setText("");

      GridPane gp = new GridPane();
      gp.setHgap(0.0);
      gp.setVgap(0.0);
      gp.setPadding(new Insets(5, 5, 5, 5));
      gp.setMinWidth(250);

      ColumnConstraints constraint1 = new ColumnConstraints();
      constraint1.setFillWidth(false);
      constraint1.setHgrow(Priority.NEVER);
      constraint1.setMinWidth(160);
      constraint1.setMaxWidth(160);
      gp.getColumnConstraints().add(constraint1);

      ColumnConstraints constraint2 = new ColumnConstraints();
      constraint2.setFillWidth(true);
      constraint2.setHgrow(Priority.SOMETIMES);
      gp.getColumnConstraints().add(constraint2);

      int row = 0;

      gp.add(wrapAndStyle(makeBoldLabel("Message"), row), 0, row);
      Label message = new Label(item.getMessage());
      message.setWrapText(true);
      message.maxWidthProperty().bind(this.widthProperty().subtract(180));
      gp.add(wrapAndStyle(message, row), 1, row++);

      gp.add(wrapAndStyle(makeBoldLabel("Severity"), row), 0, row);
      Label severity = new Label(item.getSeverity().getName());
      severity.setWrapText(true);
      severity.maxWidthProperty().bind(this.widthProperty().subtract(180));
      gp.add(wrapAndStyle(severity, row), 1, row++);

      gp.add(wrapAndStyle(makeBoldLabel("Rule UUID"), row), 0, row);
      Label ruleUUID = new Label(item.getRuleUuid());
      ruleUUID.setWrapText(true);
      ruleUUID.maxWidthProperty().bind(this.widthProperty().subtract(180));
      gp.add(wrapAndStyle(ruleUUID, row), 1, row++);

      gp.add(wrapAndStyle(makeBoldLabel("Error Code"), row), 0, row);
      Label errorCode = new Label(item.getErrorCode() + "");
      errorCode.setWrapText(true);
      errorCode.maxWidthProperty().bind(this.widthProperty().subtract(180));
      gp.add(wrapAndStyle(errorCode, row), 1, row++);

      setGraphic(gp);
      this.setStyle("-fx-border-width:  0 0 2 0; -fx-border-color: grey; ");

    } else {
      setText("");
      setGraphic(null);
      this.setStyle("");
    }
  }
Ejemplo n.º 22
0
  @Override
  public void start(final Stage primaryStage) throws Exception {
    final int w = 200;
    final int l = 5;
    final int size = w / l;
    final GridPane g = new GridPane();
    g.setPrefSize(w, w);

    final TooltipBehavior behavior = new TooltipBehavior();
    // マウスが乗ってから0.1秒後に表示
    behavior.setOpenDuration(new Duration(100));
    // ずっと表示
    behavior.setHideDuration(Duration.INDEFINITE);
    // マウスが放れてから0.3秒後に非表示
    behavior.setLeftDuration(new Duration(300));

    for (int y = 0; y < l; y++) {
      for (int x = 0; x < l; x++) {
        final Rectangle r = createNode(size);
        g.add(r, x, y);

        // 色をツールチップで表示する
        final Tooltip tooltip = new Tooltip(r.getFill().toString());
        // インストール
        behavior.install(r, tooltip);

        // 普通の動作との違いが見てみたい人は↑をコメントにして
        // ↓をコメント解除してみてください
        // Tooltip.install(r,tooltip);
      }
    }

    primaryStage.setScene(new Scene(g));
    primaryStage.show();
  }
Ejemplo n.º 23
0
 private GridPane initContent() {
   GridPane pane = new GridPane();
   Canvas canvas = new Canvas(200, 200);
   pane.add(canvas, 0, 0);
   this.drawShapes(canvas.getGraphicsContext2D());
   return pane;
 }
Ejemplo n.º 24
0
 public FXDialog setDetail(String what) {
   if (detLabel == null) {
     detLabel = new Label(what);
     grid.add(detLabel, 1, 1);
   } else detLabel.setText(what);
   return this;
 }
 @Override
 public void start(Stage primaryStage) throws Exception {
   primaryStage.setTitle("Numeryczne metody rozwiazywania metod rozniczkowych");
   setUpLineChart();
   setUpGridPane();
   setUpStepTextField();
   setUpEulerAction();
   setUpRKAction();
   setUpAnaliticAction();
   Label label = new Label();
   gridPane.add(label, 0, 5);
   Scene appScene = new Scene(gridPane, 1200, 760);
   primaryStage.setScene(appScene);
   primaryStage.show();
   gridPane.add(lineChart, 1, 0, 1, 7);
 }
Ejemplo n.º 26
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Random rand = new Random();

    GridPane layout = new GridPane();
    layout.setGridLinesVisible(true);
    layout.setAlignment(Pos.CENTER);
    layout.setVgap(2);
    layout.setHgap(2);
    layout.setPadding(new Insets(10, 10, 10, 10));

    int j = 0;
    for (int i = 0; i < 11; i++) {

      int newRandomNum = rand.nextInt((1 - 0) + 1) + 0;
      TextField number = new TextField();
      number.setText(Integer.toString(newRandomNum));

      if (i > 9) {
        if (j > 8) {
          break;
        } else {
          j++;
          i = 0;
        }
      }

      layout.add(number, j, i);
    }

    Scene scene = new Scene(layout, 300, 300);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
Ejemplo n.º 27
0
 public FXDialog setMessage(String what) {
   if (msgLabel == null) {
     msgLabel = new Label(what);
     grid.add(msgLabel, 1, 0);
   } else msgLabel.setText(what);
   return this;
 }
Ejemplo n.º 28
0
  public void initSeats(int numSeats, int numColumns) {
    row = 0;
    columns = 0;
    countSeats = 0;

    SeatShape.columns = numColumns;
    gridPane.hgapProperty().unbind();
    gridPane.hgapProperty().bind(bus.widthProperty().divide(numColumns).divide(8));

    seatsList.clear();
    gridPane.getChildren().clear();

    while (columns < numColumns) {
      while (row < NUM_ROWS + 1) {
        if (countSeats < numSeats) {
          SeatShape seatsShape = new SeatShape(countSeats + 1, gridPane.hgapProperty(), bus);
          if (row != 2) {
            countSeats++;
            seatsList.add(seatsShape);
          } else {
            seatsShape.setVisible(false);
          }
          seatsShape.setOnMouseClicked(
              (MouseEvent evt) -> {
                ((SeatShape) evt.getSource()).toogle();
              });
          gridPane.add(seatsShape, columns, row);
        }

        row++;
      }
      row = 0;
      columns++;
    }
  }
Ejemplo n.º 29
0
 @FXML
 void setGridPaneStarNumbers() {
   int gridLabel = 0;
   for (int i = 0; i < 11; i++) {
     gridLabel++;
     Button b = new Button(gridLabel + "");
     b.addEventHandler(
         MouseEvent.MOUSE_CLICKED,
         new EventHandler<MouseEvent>() {
           @Override
           public void handle(MouseEvent arg0) {
             Button b = (Button) arg0.getSource();
             b.getStyleClass().add("clicked");
             // TODO Auto-generated method stub
             if (setLottoStarNumber(Integer.parseInt(b.getText()))) {
               b.setEffect(new DropShadow());
               b.getStyleClass().add("clicked");
             } else {
               b.setEffect(null);
               b.getStyleClass().removeAll("clicked");
             }
           }
         });
     grid_starNumbers.add(b, i, 0);
   }
 }
Ejemplo n.º 30
0
 public void setMitjas(String tipus, double result, String unitats) {
   mitjas.setHeaderText("Càlcul de la mitja de la " + tipus);
   Label label1 = new Label(String.format("%.2f", result) + " " + unitats);
   GridPane grid = new GridPane();
   grid.add(label1, 1, 1);
   mitjas.getDialogPane().setContent(grid);
 }