Пример #1
0
  private void addListListener(TextField k, TextField v, Button deleteButton) {
    k.textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              buttonAddList.setDisable(false);
              HashMap<String, String> lists1 = Main.settings.getLists();
              String text = k.getText();
              String id = k.getId();
              String v1 = lists1.get(id);
              lists1.remove(id);
              lists1.put(text, v1);

              k.setId(text);

              Main.settings.setLists(lists1);
              save();
            });
    v.textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              k.setDisable(false);
              HashMap<String, String> lists1 = Main.settings.getLists();
              lists1.put(v.getId().substring(1), v.getText());
              Main.settings.setLists(lists1);
              save();
            });
    deleteButton.setOnAction(
        event -> {
          k.setVisible(false);
          v.setVisible(false);
          deleteButton.setVisible(false);
          Main.settings.getLists().remove(k.getText());
          save();
        });
  }
 /** Initializes the controller class. */
 @Override
 public void initialize(URL url, ResourceBundle rb) {
   logger.entry();
   OkButton.disableProperty()
       .bind(
           Bindings.isEmpty(FederationExecutionName.textProperty())
               .or(Bindings.isEmpty(FederateType.textProperty())));
   logger.exit();
 }
 @Override
 void bindItem(Property newItem) {
   tfKey.textProperty().bindBidirectional(newItem.keyProperty());
   if (newItem.getValue().matches("#[0-9a-fA-F]{6}")) {
     cpColor.setVisible(true);
     tfValue.setVisible(false);
     cpColor.setValue(Color.web(newItem.getValue()));
     newItem.valueProperty().bindBidirectional(cpColor.valueProperty(), colorConverter);
   } else {
     cpColor.setVisible(false);
     tfValue.setVisible(true);
     tfValue.textProperty().bindBidirectional(newItem.valueProperty());
   }
 }
Пример #4
0
 private void initSettingsPane() {
   trainTroopsSlider.setMin(0);
   trainTroopsSlider.setMax(Settings.MAX_TRAIN_TROOPS);
   trainTroopsSlider.setBlockIncrement(1);
   trainTroopsSlider
       .valueProperty()
       .addListener(
           (observable, oldValue, newValue) -> {
             trainTroopsSliderPreview.setText(
                 String.format("%d", MainController.toInt(newValue.doubleValue())));
           });
   final Troop[] availableTroops = model.getAvailableTroops();
   rax1ComboBox.getItems().addAll(availableTroops);
   rax2ComboBox.getItems().addAll(availableTroops);
   rax3ComboBox.getItems().addAll(availableTroops);
   rax4ComboBox.getItems().addAll(availableTroops);
   rax5ComboBox.getItems().addAll(availableTroops);
   rax6ComboBox.getItems().addAll(availableTroops);
   autoAttackComboBox.getItems().addAll(Attack.noStrategy());
   autoAttackComboBox.getItems().addAll(Attack.getAvailableStrategies());
   autoAttackComboBox.setValue(autoAttackComboBox.getItems().get(0));
   final ChangeListener<String> intFieldListener =
       (observable, oldValue, newValue) -> {
         try {
           if (!newValue.isEmpty()) {
             Integer.parseInt(newValue);
           }
         } catch (final NumberFormatException e) {
           ((TextField) ((StringProperty) observable).getBean()).setText(oldValue);
         }
       };
   goldField.textProperty().addListener(intFieldListener);
   elixirField.textProperty().addListener(intFieldListener);
   deField.textProperty().addListener(intFieldListener);
   maxThField.textProperty().addListener(intFieldListener);
   logLevelComboBox
       .getItems()
       .addAll(
           Level.FINEST,
           Level.FINER,
           Level.FINE,
           Level.CONFIG,
           Level.INFO,
           Level.WARNING,
           Level.SEVERE);
   logLevelComboBox.setValue(logLevelComboBox.getItems().get(1));
   updateUI();
 }
  @Override // This method is called by the FXMLLoader when initialization is complete
  public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
    assert workflowInstanceIdTextfield != null
        : "fx:id=\"workflowInstanceIdTextfield\" was not injected: check your FXML file 'WorkflowInstanceDetailFilter.fxml'.";

    workflowInstanceIdTextfield.textProperty().bindBidirectional(model.workflowInstanceId);
  }
Пример #6
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    exportBtn.disableProperty().bind(validationRegistry.invalidProperty());
    filePath
        .textProperty()
        .bindBidirectional(
            exportFile,
            new StringConverter<File>() {
              @Override
              public String toString(File object) {
                if (object == null) {
                  return null;
                }
                return object.getPath();
              }

              @Override
              public File fromString(String string) {
                try {
                  return new File(string);
                } catch (Exception e) {
                  return null;
                }
              }
            });
    validationRegistry.registerValidator(filePath, true, new NotEmptyValidator());
    validationRegistry.registerValidator(filePath, true, new ValidFilePathValidator());
    validationRegistry.registerValidator(filePath, true, new FileExtensionValidator(".xlsx"));

    progress.setProgress(-1D);
  }
 public SettingsPane() {
   draw();
   model =
       new SettingsModel(
           preloadLogtalkCheckBox.selectedProperty(), entryFilePathText.textProperty());
   style();
 }
  public TextFieldWithCopyIcon() {
    Label copyIcon = new Label();
    copyIcon.setLayoutY(3);
    copyIcon.getStyleClass().add("copy-icon");
    Tooltip.install(copyIcon, new Tooltip("Copy to clipboard"));
    AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
    AnchorPane.setRightAnchor(copyIcon, 0.0);
    copyIcon.setOnMouseClicked(
        e -> {
          String text = getText();
          if (text != null && text.length() > 0) {
            String copyText;
            if (copyWithoutCurrencyPostFix) {
              String[] strings = text.split(" ");
              if (strings.length > 1) copyText = strings[0]; // exclude the BTC postfix
              else copyText = text;
            } else {
              copyText = text;
            }
            Utilities.copyToClipboard(copyText);
          }
        });
    textField = new TextField();
    textField.setEditable(false);
    textField.textProperty().bindBidirectional(text);
    AnchorPane.setRightAnchor(copyIcon, 5.0);
    AnchorPane.setRightAnchor(textField, 30.0);
    AnchorPane.setLeftAnchor(textField, 0.0);
    textField.focusTraversableProperty().set(focusTraversableProperty().get());
    // TODO app wide focus
    // focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());

    getChildren().addAll(textField, copyIcon);
  }
Пример #9
0
  private void configureForm(StackPane root) {
    final Person person = new Person();
    person.setName("Sai PradeeP");
    VBox layout = new VBox();
    layout.setSpacing(15);
    TextField nameField = new TextField();
    nameField.textProperty().bindBidirectional(person.nameProperty());

    HBox nameLayout = new HBox();
    nameLayout.getChildren().addAll(new Label("Enter the name : "), nameField);

    HBox displayLayout = new HBox();
    final Label lbl = new Label();
    displayLayout.getChildren().addAll(new Label("You have entered : "), lbl);

    Button btn = new Button("Submit");
    btn.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            lbl.setText(person.getName());
          }
        });

    layout.getChildren().addAll(nameLayout, btn, new Separator(), displayLayout);
    root.getChildren().addAll(layout);
  }
Пример #10
0
 @Override
 public void initialize(final URL url, final ResourceBundle bundle) {
   exitItem.setOnAction(e -> Platform.exit());
   roomSelection.setItems(FXCollections.observableArrayList("arduino", "java", "groovy", "scala"));
   roomSelection.getSelectionModel().select(1);
   model.userName.bindBidirectional(userNameTextfield.textProperty());
   model.roomName.bind(roomSelection.getSelectionModel().selectedItemProperty());
   model.readyToChat.bind(
       model.userName.isNotEmpty().and(roomSelection.selectionModelProperty().isNotNull()));
   chatButton.disableProperty().bind(model.connected.not());
   messageTextField.disableProperty().bind(model.connected.not());
   messageTextField.textProperty().bindBidirectional(model.currentMessage);
   connectButton.disableProperty().bind(model.readyToChat.not());
   chatListView.setItems(model.chatHistory);
   messageTextField.setOnAction(
       event -> {
         handleSendMessage();
       });
   chatButton.setOnAction(
       evt -> {
         handleSendMessage();
       });
   connectButton.setOnAction(
       evt -> {
         try {
           clientEndPoint =
               new ChatClientEndpoint(
                   new URI("ws://quevedo2dam.azurewebsites.net/chat/" + model.roomName.get()));
           clientEndPoint.addMessageHandler(
               responseString -> {
                 Platform.runLater(
                     () -> {
                       model.chatHistory.add(
                           jsonMessageToString(responseString, model.roomName.get()));
                     });
               });
           model.connected.set(true);
         } catch (Exception e) {
           showDialog("Error: " + e.getMessage());
         }
       });
   aboutMenuItem.setOnAction(
       event -> {
         showDialog(
             "Example websocket chat bot written in JavaFX.\n\n Please feel free to visit my blog at www.hascode.com for the full tutorial!\n\n2014 Micha Kops");
       });
 }
Пример #11
0
  @Override
  public void initialize(URL arg0, ResourceBundle arg1) {
    btScan.disableProperty().bind(viewModel.scanAllowedProperty().not());
    lbScan.textProperty().bind(viewModel.messageProperty());
    tfScan.textProperty().bindBidirectional(viewModel.scannedValueProperty());

    btScan.setDefaultButton(true);
  }
 private void setupKeyEvents() {
   textField
       .textProperty()
       .addListener(
           (observable, oldValue, newValue) -> {
             handleUpdatedInput(newValue);
           });
 }
Пример #13
0
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX TextField example");

    VBox mainLayout = new VBox();

    HBox fieldLayout = new HBox();

    TextField textField = new TextField();
    Button button = new Button("X");
    button.setDisable(true);
    textField
        .textProperty()
        .addListener(
            (obj, oldVal, newVal) -> {
              if (newVal.trim().isEmpty()) {
                button.setDisable(true);
              } else {
                button.setDisable(false);
              }
            });

    textField.textProperty().bindBidirectional(obs);

    fieldLayout.getChildren().addAll(textField, button);

    HBox buttons = new HBox();
    Button clear = new Button("Clear");
    clear.setOnAction(e -> obs.set(""));
    Button setVal = new Button("Set value");
    setVal.setOnAction(e -> obs.set("Hello"));
    Button dump = new Button("Dump");
    dump.setOnAction(e -> System.err.println("Current: " + obs.get()));
    buttons.getChildren().addAll(clear, setVal, dump);

    mainLayout.getChildren().addAll(fieldLayout, buttons);

    // show the generated scene graph
    Scene scene = new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
  @Override
  // This method is called by the FXMLLoader when initialization is complete
  public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
    assert assignementTextField != null
        : "fx:id=\"assignementTextField\" was not injected: check your FXML file 'PersonnelDetailsPane.fxml'.";
    assert designationTextField != null
        : "fx:id=\"designationTextField\" was not injected: check your FXML file 'PersonnelDetailsPane.fxml'.";
    assert locationTestField != null
        : "fx:id=\"locationTestField\" was not injected: check your FXML file 'PersonnelDetailsPane.fxml'.";
    // initialize your logic here: all @FXML variables will have been
    // injected
    final StringExpression officialNameExpression =
        Bindings.selectString(officialProperty(), "rank", "designation")
            .concat(" ")
            .concat(Bindings.selectString(officialProperty(), "name"));

    designationTextField.textProperty().bind(officialNameExpression);
    assignementTextField
        .textProperty()
        .bind(Bindings.selectString(officialProperty(), "assignment", "visualName"));
  }
Пример #15
0
  public void initialize(URL location, ResourceBundle resources) {
    txtFieldGeldEingabe.textProperty().bindBidirectional(viewModel.geldEingabe());
    txtFieldZeitEingabe.textProperty().bindBidirectional(viewModel.zeitEinagabe());
    labelQualitaet.textProperty().bindBidirectional(viewModel.qualitaetText());
    labelZeit.textProperty().bindBidirectional(viewModel.zeitText());
    labelSkill.textProperty().bindBidirectional(viewModel.skillText());
    labelGehalt.textProperty().bindBidirectional(viewModel.gehaltText());
    labelGeld.textProperty().bindBidirectional(viewModel.geldText());
    labelGesundheit.textProperty().bindBidirectional(viewModel.gesundheitText());
    labelMotivation.textProperty().bindBidirectional(viewModel.motivationText());
    SliderGehalt.valueProperty().bindBidirectional(viewModel.gehaltProperty());
    SliderGehalt.setValue(1500);
    SliderGehalt.setShowTickMarks(false);
    SliderGehalt.setMajorTickUnit(1);
    SliderGehalt.setMinorTickCount(0);
    SliderGehalt.setBlockIncrement(100);
    SliderGehalt.setSnapToTicks(true);

    labelNeuesGehalt.textProperty().bind(SliderGehalt.valueProperty().asString("%.0f"));

    buttonStart.setOnAction(
        event -> {
          buttonNachsteRunde.setDisable(false);
          buttonStart.setDisable(true);
          txtFieldGeldEingabe.setDisable(true);
          txtFieldZeitEingabe.setDisable(true);
          viewModel.startRound();
        });

    buttonNachsteRunde.setOnAction(
        event -> {
          RadioButton rb = (RadioButton) ToggleGroupSelect.getSelectedToggle();
          viewModel.nextRound(rb.getText());
        });

    viewModel.setButtonNaechsteRunde(buttonNachsteRunde);
    viewModel.setButtonStart(buttonStart);
    viewModel.setTxtFieldGeldEingabe(txtFieldGeldEingabe);
    viewModel.setTxtFieldZeitEingabe(txtFieldZeitEingabe);
  }
Пример #16
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;
  }
Пример #17
0
  /** defines what happens, before the GUI is started */
  public void initialize(URL location, ResourceBundle resources) {

    // set the controller var in the Main class to this Controller
    Main.controller = this;

    updateList();
    log.debug("List updated");

    // Formatting of the listView
    listView.setFixedCellSize(60);
    listView.setItems(items);
    addButton.setSelected(true);
    log.debug("ListView cellSize changed, items assigned");

    // is activated if the text in the searchbox is changed
    searchBox
        .textProperty()
        .addListener(
            (observable, oldVal, newVal) -> {
              renewSearch(newVal);
            });

    // is called when the selected Search Radiobutton is changed
    searchToggle
        .selectedToggleProperty()
        .addListener(
            new ChangeListener<Toggle>() {
              public void changed(
                  ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
                renewSearch(searchBox.getText());
              }
            });

    // gets called if an item in the listview is selected -> will load the
    // currently selected item
    // in the overview on the left
    listView
        .getSelectionModel()
        .getSelectedItems()
        .addListener(
            new ListChangeListener<ItemBox>() {
              @Override
              public void onChanged(
                  javafx.collections.ListChangeListener.Change<? extends ItemBox> c) {
                // Update the overview section on the left side of the GUI
                updateOverview();
              }
            });

    setupMenuItems();
  }
Пример #18
0
  public boolean isOkPressed(int typeSignal) {
    ((StageLoader) btnOK.getScene().getWindow()).setMethod(() -> btnOK());
    if (tuSignal == null) return false;
    Stage w = (Stage) btnOK.getScene().getWindow();

    if (typeSignal == 3) {
      List<SpTuCommand> tuCommands =
          SingleFromDB.spTuCommands
              .stream()
              .filter(f -> f.getObjref() == tuSignal.getStateref())
              .collect(Collectors.toList());
      ChoiceBox<SpTuCommand> chBox = new ChoiceBox<>();
      tuCommands.forEach(chBox.getItems()::add);
      chBox
          .getSelectionModel()
          .selectedItemProperty()
          .addListener(
              (observ, oldValue, newValue) -> {
                value = newValue.getVal() + "";
              });
      if (chBox.getItems().size() > 0) chBox.getSelectionModel().selectFirst();
      if (SingleObject.selectedShape.getValueProp().get()
          == chBox.getSelectionModel().getSelectedItem().getVal()) {
        chBox.getSelectionModel().selectNext();
      }
      Platform.runLater(() -> chBox.requestFocus());
      bpTU.setCenter(chBox);
    } else if (typeSignal == 1) {
      TextField txtField = new TextField();
      txtField.setText(SingleObject.selectedShape.getValueProp().get() + "");
      txtField
          .textProperty()
          .addListener(
              (observ, oldValue, newValue) -> {
                try {
                  Double.parseDouble(newValue);
                  value = newValue;
                } catch (Exception e) {
                  txtField.setText(oldValue);
                }
              });
      Platform.runLater(() -> txtField.requestFocus());
      bpTU.setCenter(txtField);
    } else {
      System.out.println("=====   This is not TU or TI   =====");
    }
    w.showAndWait();

    return isOkClicked;
  }
Пример #19
0
  public MovieTile(Movie movie, Scene scene) {
    super();
    this.movie = movie;

    HBox hbox = new HBox(2);
    //	hbox.setPrefHeight(500);
    hbox.prefWidthProperty().bind(scene.widthProperty().divide(8));
    // hbox.prefHeightProperty().bind(scene.heightProperty().divide(2));

    ImageView imgView = new ImageView();
    imgView.setImage(new Image("file:" + movie.title.getValue() + ".jpg"));
    imgView.fitWidthProperty().bind(hbox.widthProperty().divide(2));
    //	imgView.setPreserveRatio(true);
    imgView.setSmooth(true);
    DropShadow ds = new DropShadow();
    ds.setRadius(10);
    ds.setOffsetX(-5);
    ds.setOffsetY(2);
    ds.setColor(Color.color(0, 0, 0, 0.3));
    imgView.setEffect(ds);

    VBox vbox = new VBox(2);

    HBox titleBox = new HBox(2);
    Text nameField = new Text();
    nameField.setTextOrigin(VPos.TOP);
    nameField.setStroke(Color.BLACK);
    nameField.textProperty().bind(movie.title);
    Text dateField = new Text();
    dateField.setTextOrigin(VPos.TOP);
    dateField.setStroke(Color.GRAY);
    dateField
        .textProperty()
        .bind(new SimpleStringProperty(" (").concat(movie.releaseDate).concat(")"));
    titleBox.getChildren().addAll(nameField, dateField);

    Text genreField = new Text();
    // genreField.prefHeightProperty().bind(hbox.heightProperty().divide(5/1));
    genreField.textProperty().bind(movie.genre);

    TextField comField = new TextField();
    // comField.prefHeightProperty().bind(hbox.heightProperty().divide(5/2));
    comField.textProperty().bind(movie.comments);
    vbox.getChildren().addAll(titleBox, genreField, comField);
    VBox.setVgrow(comField, Priority.ALWAYS);

    hbox.getChildren().addAll(imgView, vbox);
    this.getChildren().addAll(hbox);
  }
  @FXML
  void initialize() {
    amountLb.textProperty().bindBidirectional(viewModel.amountProperty());

    fromCurrencyBox.valueProperty().bindBidirectional(viewModel.fromCurrencyProperty());
    toCurrencyBox.valueProperty().bindBidirectional(viewModel.toCurrencyProperty());

    convertButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(final ActionEvent event) {
            viewModel.convert();
          }
        });
  }
Пример #21
0
    // Method to please FindBugs
    private void initialize(String url) {
      setValue(url);
      EventHandler<ActionEvent> onActionListener =
          new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
              //                    System.out.println("StylesheetItem : onActionListener");
              if (getValue().equals(currentValue)) {
                // no change
                return;
              }
              if (stylesheetTf.getText().isEmpty()) {
                remove(null);
              }
              //                        System.out.println("StyleEditorItem : COMMIT");
              editor.commit(StylesheetItem.this);
              if (event != null && event.getSource() instanceof TextField) {
                ((TextField) event.getSource()).selectAll();
              }
              updateButtons();
              updateOpenRevealMenuItems();
              currentValue = getValue();
            }
          };

      ChangeListener<String> textPropertyChange =
          new ChangeListener<String>() {

            @Override
            public void changed(
                ObservableValue<? extends String> ov, String prevText, String newText) {
              if (prevText.isEmpty() || newText.isEmpty()) {
                // Text changed FROM empty value, or TO empty value: buttons status change
                updateButtons();
                updateOpenRevealMenuItems();
              }
            }
          };
      stylesheetTf.textProperty().addListener(textPropertyChange);
      updateButtons();

      setTextEditorBehavior(stylesheetTf, onActionListener);

      // Initialize menu items text
      removeMi.setText(I18N.getString("inspector.list.remove"));
      moveUpMi.setText(I18N.getString("inspector.list.moveup"));
      moveDownMi.setText(I18N.getString("inspector.list.movedown"));
    }
Пример #22
0
  public void generateFieldFowChSw(WirelessAdapter wirelessAdapter) {
    String channelDefaultValue =
        ConfigurationLoader.getConfiguration().getApplicationConfiguration().getChannelsToScan();

    HBox container = new HBox();
    container.setStyle("-fx-border-color: rgba(200, 200, 200, 1);" + "-fx-border-width: 1;");
    container.setPadding(new Insets(padding, padding, padding, padding));
    container.setSpacing(spacing);
    container.setAlignment(Pos.CENTER_LEFT);

    TextField textFieldFowChSw = new TextField();
    textFieldFowChSw.setPrefWidth(50);
    textFieldFowChSw.setText(channelDefaultValue);

    Label currentChanelNumberLabel = new Label();

    container.getChildren().add(textFieldFowChSw);
    container.getChildren().add(currentChanelNumberLabel);

    wirelessAdapter.addChannelSwitchingListener(
        channelNumber -> {
          Platform.runLater(
              () -> {
                currentChanelNumberLabel.setText(String.valueOf(channelNumber));
              });
        });

    textFieldFowChSw
        .textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (textFieldFowChSw
                  .getText()
                  .matches(
                      "(?<channelStart>\\d{1,2}[^15-99]*?)(-(?<channelEnd>\\d{1,2}[^15-99]*?))?")) {
                wirelessAdapter.setChannelRoundSwitcher(
                    new RoundVar(Utils.generateArrayToRound(textFieldFowChSw.getText())));
              }
              if (newValue.matches("( *)")) {
                // recursive execute this listener with correct value
                textFieldFowChSw.setText(channelDefaultValue);
              }
            });

    Platform.runLater(() -> controlBntsVBox.getChildren().add(container));
  }
  public BitcoinAddressValidator(NetworkParameters params, TextField field, Node... nodes) {
    this.params = params;
    this.nodes = nodes;

    // Handle the red highlighting, but don't highlight in red just when the field is empty because
    // that makes
    // the example/prompt address hard to read.
    new TextFieldValidator(field, text -> text.isEmpty() || testAddr(text));
    // However we do want the buttons to be disabled when empty so we apply a different test there.
    field
        .textProperty()
        .addListener(
            (observableValue, prev, current) -> {
              toggleButtons(current);
            });
    toggleButtons(field.getText());
  }
  @FXML
  void initialize() {
    viewModel.setLogger(new LengthConvertorLogger("./LengthConvertorLogger.xml"));

    final ChangeListener<Boolean> focusValueChangeListener =
        new ChangeListener<Boolean>() {
          @Override
          public void changed(
              final ObservableValue<? extends Boolean> observable,
              final Boolean oldValue,
              final Boolean newValue) {
            viewModel.valueChanged(oldValue, newValue);
          }
        };

    final ChangeListener<LengthUnit> focusLengthUnitChangeListener =
        new ChangeListener<LengthUnit>() {
          @Override
          public void changed(
              final ObservableValue<? extends LengthUnit> observable,
              final LengthUnit oldValue,
              final LengthUnit newValue) {
            viewModel.lengthUnitsChanged(oldValue, newValue);
          }
        };

    inputValueTextBox.textProperty().bindBidirectional(viewModel.inputValueProperty());
    inputValueTextBox.focusedProperty().addListener(focusValueChangeListener);

    inputUnitComboBox.valueProperty().bindBidirectional(viewModel.inputUnitProperty());
    inputUnitComboBox.valueProperty().addListener(focusLengthUnitChangeListener);

    outputUnitComboBox.valueProperty().bindBidirectional(viewModel.outputUnitProperty());
    outputUnitComboBox.valueProperty().addListener(focusLengthUnitChangeListener);

    convertButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(final ActionEvent event) {
            viewModel.convert();
          }
        });
  }
Пример #25
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    vbox = new VBox();
    vbox.setSpacing(15.0);
    Scene scene = new Scene(vbox, 800, 600);

    String initVal = "Tobias Jonas - Jonato IT Solutions";

    BarcodeView barcodeView = new BarcodeView(BarcodeEncoding.QR_CODE, initVal);
    TextField textfield = new TextField(initVal);

    barcodeView.dataProperty().bind(textfield.textProperty());

    Button close = new Button("Close");
    close.setOnAction(e -> primaryStage.close());
    vbox.getChildren().addAll(barcodeView, textfield, close);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
Пример #26
0
  @Override
  public void initUI() {
    AnchorPane anchorPane = new AnchorPane();
    anchorPane.setPrefHeight(90.0);
    anchorPane.setPrefWidth(384.0);

    Label label = new Label(getApplication().getMessageSource().getMessage("name.label"));
    TextField input = new TextField();
    input.setPrefWidth(200.0);

    Button button = new Button();
    button.setPrefWidth(200.0);
    JavaFXUtils.configure(
        button, (JavaFXAction) actionFor(controller, "sayHello").getToolkitAction());

    Label output = new Label();
    label.setPrefWidth(360.0);

    model.inputProperty().bindBidirectional(input.textProperty());
    model.outputProperty().bindBidirectional(output.textProperty());

    anchorPane.getChildren().addAll(label, input, button, output);

    setLeftAnchor(label, 14.0);
    setTopAnchor(label, 14.0);
    setLeftAnchor(input, 172.0);
    setTopAnchor(input, 11.0);
    setLeftAnchor(button, 172.0);
    setTopAnchor(button, 45.0);
    setLeftAnchor(output, 14.0);
    setTopAnchor(output, 80.0);

    Tab tab = new Tab("Java");
    tab.setGraphic(new FontAwesomeIcon(FontAwesome.FA_COFFEE));
    tab.setClosable(false);
    tab.setContent(anchorPane);
    parentView.getTabPane().getTabs().add(tab);
  }
Пример #27
0
  public void initialize() {
    txtAPIKey
        .textProperty()
        .addListener(
            (obs, ov, nv) -> {
              ObservableList<String> styleClass = txtAPIKey.getStyleClass();
              if (!APIKey.isValid(nv)) {
                styleClass.removeAll("field-ok");
                if (!styleClass.contains("field-error")) styleClass.add("field-error");
              } else {
                styleClass.removeAll("field-error");
                if (!styleClass.contains("field-ok")) styleClass.add("field-ok");
              }
            });

    String apiKey = GW2Tools.inst().getAppSettings().apiKey.getValue();
    if (apiKey != null && apiKey.length() > 0) {
      txtAPIKey.setText(apiKey);
      chkbxRememberKey.setSelected(true);
    }

    GW2Tools.inst().getAssets().updateGW2Assets(this);
  }
Пример #28
0
 @FXML
 private void initialize() {
   initMenu();
   strokes.setCellFactory(param -> new ModelCell<>(lang));
   strokes
       .getSelectionModel()
       .selectedItemProperty()
       .addListener((observable, oldValue, newValue) -> onSelect(newValue));
   isSelected.bind(strokes.getSelectionModel().selectedItemProperty().isNotNull());
   search
       .textProperty()
       .addListener(
           observable -> {
             if (search.getText() == null || search.getText().isEmpty()) {
               allStrokes.setPredicate(set -> true);
             } else {
               allStrokes.setPredicate(
                   set ->
                       set.uiString(lang).toLowerCase().contains(search.getText().toLowerCase()));
             }
           });
   populate();
 }
 /** Initializes the controller class. */
 @Override
 public void initialize(URL url, ResourceBundle rb) {
   logger.entry();
   OkButton.disableProperty().bind(ObjectInstanceDesignator.textProperty().isEmpty());
   logger.exit();
 }
Пример #30
0
  public NewItemDialog(InventoryTab parent) {
    setTitle("Create New Item");

    getDialogPane().getButtonTypes().addAll(createButtonType, ButtonType.CANCEL);

    dialogContent.setHgap(10);
    dialogContent.setVgap(10);
    dialogContent.setPadding(new Insets(20, 100, 10, 10));

    itemName.setPromptText("Item Name");
    description.setPromptText("Description");
    imgUrl.setPromptText("Add a picture");
    // set spinner for the price
    SpinnerValueFactory<Double> spinnerFactory =
        new SpinnerValueFactory.DoubleSpinnerValueFactory(0.00, 100.00, 0.00, 0.01);
    priceSpinner.setValueFactory(spinnerFactory);
    priceSpinner.setEditable(true);
    // spinner for stock
    stockSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100, 0, 1));
    stockSpinner.setEditable(true);

    // add elements into grid
    dialogContent.add(img, 1, 0, 1, 4);
    dialogContent.add(imgUrl, 1, 4);
    dialogContent.add(browse, 2, 4);
    dialogContent.add(new Label("Item Name:"), 2, 0);
    dialogContent.add(itemName, 4, 0);
    dialogContent.add(new Label("Description:"), 2, 1);
    dialogContent.add(description, 4, 1);
    dialogContent.add(new Label("Price:"), 2, 2);
    dialogContent.add(new Label("$"), 3, 2);
    dialogContent.add(priceSpinner, 4, 2);
    dialogContent.add(new Label("No. of Stock:"), 2, 3);
    dialogContent.add(stockSpinner, 4, 3);

    // Enable/Disable Create button depending on whether info was entered.
    btnCreate = this.getDialogPane().lookupButton(createButtonType);
    btnCreate.setDisable(true);
    itemName
        .textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              validateCreateButton();
            });
    description
        .textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              validateCreateButton();
            });

    getDialogPane().setContent(dialogContent);

    // event handler for browse button
    browse.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(final ActionEvent e) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Choose an Image");
            fileChooser.setInitialDirectory(new File(System.getProperty("user.dir") + "\\images"));
            fileChooser
                .getExtensionFilters()
                .addAll(new ExtensionFilter("Image Files", "*.png", "*.jpg", "*.gif"));

            File file = fileChooser.showOpenDialog(((InventoryTab) parent).getWindow());
            if (file != null) {
              imgUrl.setText(file.toString());
              // http://gamedev.stackexchange.com/questions/72924/how-do-i-add-an-image-inside-a-rectangle-or-a-circle-in-javafx
              Image image = new Image(file.toURI().toString());
              ImagePattern imagePattern = new ImagePattern(image);
              img.setFill(imagePattern);
              validateCreateButton();
            }
          }
        });

    // Convert the result to a MokuStockItem when the create button is clicked.
    setResultConverter(
        dialogButton -> {
          if (dialogButton == createButtonType) {
            // error handling
            String desc, url;
            if (description.getText().isEmpty()) {
              desc = "";
            } else {
              desc = description.getText();
            }
            if (imgUrl.getText().isEmpty()) {
              url = "";
            } else {
              url = imgUrl.getText();
            }
            return new MokuStockItem(
                parent,
                0,
                itemName.getText(),
                desc,
                Double.parseDouble(priceSpinner.getEditor().getText()),
                Integer.parseInt(stockSpinner.getEditor().getText()),
                url);
          }
          return null;
        });
  }