Java Code Examples for javafx.scene.control.TextField

The following examples show how to use javafx.scene.control.TextField. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: bisq   Source File: SupplyView.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private void createSupplyIncreasedInformation() {
    addTitledGroupBg(root, ++gridRow, 3, Res.get("dao.factsAndFigures.supply.issued"), Layout.GROUP_DISTANCE);

    Tuple3<Label, TextField, VBox> genesisAmountTuple = addTopLabelReadOnlyTextField(root, gridRow,
            Res.get("dao.factsAndFigures.supply.genesisIssueAmount"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    genesisIssueAmountTextField = genesisAmountTuple.second;
    GridPane.setColumnSpan(genesisAmountTuple.third, 2);

    compRequestIssueAmountTextField = addTopLabelReadOnlyTextField(root, ++gridRow,
            Res.get("dao.factsAndFigures.supply.compRequestIssueAmount")).second;
    reimbursementAmountTextField = addTopLabelReadOnlyTextField(root, gridRow, 1,
            Res.get("dao.factsAndFigures.supply.reimbursementAmount")).second;

    var chart = createBSQIssuedChart(seriesBSQIssuedMonthly2);

    var chartPane = wrapInChartPane(chart);
    root.getChildren().add(chartPane);
}
 
Example 2
Source Project: MyBox   Source File: FxmlControl.java    License: Apache License 2.0 6 votes vote down vote up
public static void setPathExistedValidation(final TextField input) {
    if (input == null) {
        return;
    }
    input.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable,
                String oldValue, String newValue) {
            final File file = new File(newValue);
            if (!file.exists() || !file.isDirectory()) {
                input.setStyle(badStyle);
                return;
            }
            input.setStyle(null);
        }
    });
}
 
Example 3
Source Project: constellation   Source File: LongObjectEditorFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    numberField = new TextField();
    numberField.textProperty().addListener((o, n, v) -> {
        update();
    });

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        numberField.setDisable(noValueCheckBox.isSelected());
        update();
    });

    controls.addRow(0, numberField);
    controls.addRow(1, noValueCheckBox);
    return controls;
}
 
Example 4
Source Project: old-mzmine3   Source File: MZRangeEditor.java    License: GNU General Public License v2.0 6 votes vote down vote up
public MZRangeEditor(PropertySheet.Item parameter) {
  if (!(parameter instanceof MZRangeParameter))
    throw new IllegalArgumentException();

  // The minimum value field
  minTxtField = new TextField();

  // The separator label
  Label separatorLabel = new Label("-");

  // The maximum value field
  maxTxtField = new TextField();

  // Spacing setting
  setSpacing(10);

  // Add the elements
  getChildren().addAll(minTxtField, separatorLabel, maxTxtField);
}
 
Example 5
private void updateHost() {

        Dialog<String> dialog = new Dialog<String>("Host", null);

        TextField hostField = new TextField(TicTacToe.getHost());
        dialog.setContent(hostField);

        Button okButton = new Button("OK");
        okButton.setOnAction(e -> {
            dialog.setResult(hostField.getText());
            dialog.hide();
        });

        BooleanBinding urlBinding = Bindings.createBooleanBinding(
                () -> isUrlValid(hostField.getText()),
                hostField.textProperty());
        okButton.disableProperty().bind(urlBinding.not());

        Button cancelButton = new Button("CANCEL");
        cancelButton.setOnAction(e -> dialog.hide());
        dialog.getButtons().addAll(okButton,cancelButton);
        dialog.showAndWait().ifPresent( url -> TicTacToe.setHost(url));

    }
 
Example 6
private void buildAndShowMainWindow(Stage primaryStage) {
    primaryStage.setTitle("Hello World!!");
    GridPane gridPane = new GridPane();
    gridPane.setAlignment(Pos.CENTER);
    gridPane.setHgap(10);
    gridPane.setVgap(10);
    gridPane.setPadding(new Insets(25, 25, 25, 25));

    button = new Button("Click me!");
    button.setId("TheButton");
    gridPane.add(button,1,1);

    text = new TextField();
    gridPane.add(text, 2, 1);

    clockLabel = new Label();
    gridPane.add(clockLabel, 1,2, 2, 1);

    Scene scene = new Scene(gridPane);
    primaryStage.setScene(scene);
    scene.getStylesheets().add(getClass().getResource("/form.css").toExternalForm());
    primaryStage.show();
}
 
Example 7
Source Project: HubTurbo   Source File: BoardTests.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void boards_panelCount_askForBoardNameWhenCurrentBoardHasNeverBeenSaved() {
    UI ui = TestController.getUI();
    PanelControl panelControl = ui.getPanelControl();

    pushKeys(CREATE_RIGHT_PANEL);
    pushKeys(CREATE_RIGHT_PANEL);
    awaitCondition(() -> 3 == panelControl.getPanelCount());

    traverseHubTurboMenu("Boards", "Save");
    waitUntilNodeAppears(boardNameInputId);
    ((TextField) GuiTest.find(boardNameInputId)).setText("Board 1");
    clickOn("OK");

    assertEquals("Board 1", UI.prefs.getLastOpenBoard().get());

    traverseHubTurboMenu("Boards", "Open", "Board 1");
    waitAndAssertEquals(3, panelControl::getPanelCount);
}
 
Example 8
Source Project: helloiot   Source File: EditView.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node constructContent() {
    
    boxview = new HBox();
    boxview.setSpacing(6.0);

    statusview = new TextField();
    statusview.setEditable(false);
    statusview.setFocusTraversable(false);
    statusview.getStyleClass().add("unitinputview");
    HBox.setHgrow(statusview, Priority.SOMETIMES);
    
    boxview.getChildren().add(statusview);

    initialize();
    return boxview;
}
 
Example 9
Source Project: marathonv5   Source File: RFXTextFieldTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void selectWithUtf8Chars() throws InterruptedException {
    final TextField textField = (TextField) getPrimaryStage().getScene().getRoot().lookup(".text-field");
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            textField.setText("å∫ç∂´ƒ©˙ˆ∆");
        }
    });
    LoggingRecorder lr = new LoggingRecorder();
    RFXComponent rTextField = new RFXTextInputControl(textField, null, null, lr);
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            rTextField.focusLost(null);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", select.getCall());
    AssertJUnit.assertEquals("å∫ç∂´ƒ©˙ˆ∆", select.getParameters()[0]);
}
 
Example 10
Source Project: tcMenu   Source File: UILargeNumberMenuItem.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected int internalInitPanel(GridPane grid, int idx) {
    idx++;

    grid.add(new Label("Decimal Places"), 0, idx);
    decimalPlaces = new TextField(String.valueOf(getMenuItem().getDecimalPlaces()));
    decimalPlaces.textProperty().addListener(this::coreValueChanged);
    TextFormatterUtils.applyIntegerFormatToField(decimalPlaces);
    grid.add(decimalPlaces, 1, idx);

    idx++;
    grid.add(new Label("Total Digits"), 0, idx);
    totalDigits = new TextField(String.valueOf(getMenuItem().getDigitsAllowed()));
    totalDigits.textProperty().addListener(this::coreValueChanged);
    TextFormatterUtils.applyIntegerFormatToField(totalDigits);
    grid.add(totalDigits, 1, idx);

    return idx;
}
 
Example 11
Source Project: marathonv5   Source File: BrowserTab.java    License: Apache License 2.0 6 votes vote down vote up
protected void addWebDriverExeBrowse() {
    String value = BrowserConfig.instance().getValue(getBrowserName(), "webdriver-exe-path");
    String def = new ExecutableFinder().find(getWebDriverExecutableName());
    wdExeField = new TextField();
    if (def != null)
        wdExeField.setPromptText(def);
    if (value != null)
        wdExeField.setText(value);
    browseWDExeButton = FXUIUtils.createButton("browse", "Browse WebDriver Executable", true, "Browse");
    FileSelectionHandler fileSelectionHandler = new FileSelectionHandler(this, null, null, browseWDExeButton,
            "Select WebDriver executable");
    fileSelectionHandler.setMode(FileSelectionHandler.FILE_CHOOSER);
    browseWDExeButton.setOnAction(fileSelectionHandler);

    basicPane.addFormField("WebDriver Executable:", wdExeField, browseWDExeButton);
}
 
Example 12
public RTToleranceEditor(PropertySheet.Item parameter) {
  if (!(parameter instanceof RTToleranceParameter))
    throw new IllegalArgumentException();

  // The value field
  valueField = new TextField();

  // The combo box
  ObservableList<String> options =
      FXCollections.observableArrayList("Absolute (sec)", "Relative (%)");
  comboBox = new ComboBox<String>(options);

  // FlowPane setting
  setHgap(10);

  // Add the elements
  getChildren().addAll(valueField, comboBox);
}
 
Example 13
Source Project: Intro-to-Java-Programming   Source File: Exercise_18_36.java    License: MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	SierpinskiTrianglePane trianglePane = new SierpinskiTrianglePane();
	TextField tfOrder = new TextField();
	tfOrder.setOnAction(
		e -> trianglePane.setOrder(Integer.parseInt(tfOrder.getText())));
	tfOrder.setPrefColumnCount(4);
	tfOrder.setAlignment(Pos.BOTTOM_RIGHT);

	// Pane to hold label, text field, and a button
	HBox hBox = new HBox(10);
	hBox.getChildren().addAll(new Label("Enter an order: "), tfOrder);
	hBox.setAlignment(Pos.CENTER);

	BorderPane borderPane = new BorderPane();
	borderPane.setCenter(trianglePane);
	borderPane.setBottom(hBox);

	// Create a scene and place it in the stage
	Scene scene = new Scene(borderPane, 200, 210);
	primaryStage.setTitle("Exercise_18_36"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage

	scene.widthProperty().addListener(ov -> trianglePane.paint());
	scene.heightProperty().addListener(ov -> trianglePane.paint());
}
 
Example 14
double textToNum(TextField mass) {
	try {
		return Double.parseDouble(mass.getText().trim());
	} catch (Throwable t) {
		mass.setText("0");
		return 0;
	}
}
 
Example 15
double textToNum(TextField mass) {
	try {
		return Double.parseDouble(mass.getText().trim());
	}catch(Throwable t) {
		mass.setText("0");
		return 0;
	}
}
 
Example 16
Source Project: constellation   Source File: TransactionTypeNodeProvider.java    License: Apache License 2.0 5 votes vote down vote up
public TransactionTypeNodeProvider() {
    schemaLabel = new Label(SeparatorConstants.HYPHEN);
    schemaLabel.setPadding(new Insets(5));
    treeView = new TreeView<>();
    transactionTypes = new ArrayList<>();
    detailsView = new HBox();
    detailsView.setPadding(new Insets(5));
    startsWithRb = new RadioButton("Starts with");
    filterText = new TextField();

    setCellFactory();
}
 
Example 17
Source Project: VocabHunter   Source File: SettingsController.java    License: Apache License 2.0 5 votes vote down vote up
private void initialiseField(final TextField field, final Supplier<Object> settingGetter) {
    StringProperty textProperty = field.textProperty();
    ReadOnlyBooleanProperty focusedProperty = field.focusedProperty();

    field.setText(settingGetter.get().toString());
    textProperty.addListener((o, oldValue, newValue) -> cleanNonNegativeInteger(field::setText, newValue, oldValue));
    focusedProperty.addListener((o, old, isFocused) -> applyDefaultIfEmpty(field::setText, field::getText, settingGetter));
}
 
Example 18
Source Project: dm3270   Source File: TransfersTab.java    License: Apache License 2.0 5 votes vote down vote up
private HBox getLine (Label label, TextField text, HBox hbox)
{
  HBox line = new HBox (10);

  line.getChildren ().addAll (label, text, hbox);
  label.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (100);
  text.setFont (defaultFont);
  text.setEditable (true);
  text.setFocusTraversable (true);

  return line;
}
 
Example 19
Source Project: ApkToolPlus   Source File: ViewUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 恢復数据显示
 *  @param textField
 * @param key
 */
public static String review(TextField textField, String key){
    String value = Config.get(key, null);
    if(!StringUtils.isEmpty(value)){
        textField.setText(value);
    }
    return value;
}
 
Example 20
Source Project: SONDY   Source File: DataManipulationUI.java    License: GNU General Public License v3.0 5 votes vote down vote up
public final void importUI(){
    GridPane gridLEFT = new GridPane();
    // Labels
    Label messagesLabel = new Label("Messages file");
    UIUtils.setSize(messagesLabel, Main.columnWidthLEFT/2, 24);
    Label networkLabel = new Label("Network file");
    UIUtils.setSize(networkLabel, Main.columnWidthLEFT/2, 24);
    Label datasetIdentificatorLabel = new Label("Dataset ID");
    UIUtils.setSize(datasetIdentificatorLabel, Main.columnWidthLEFT/2, 24);
    Label datasetDescriptionLabel = new Label("Dataset description");
    UIUtils.setSize(datasetDescriptionLabel, Main.columnWidthLEFT/2, 24);
    gridLEFT.add(messagesLabel,0,0);
    gridLEFT.add(new Rectangle(0,3),0,1);
    gridLEFT.add(networkLabel,0,2);
    gridLEFT.add(new Rectangle(0,3),0,3);
    gridLEFT.add(datasetIdentificatorLabel,0,4);
    gridLEFT.add(new Rectangle(0,3),0,5);
    gridLEFT.add(datasetDescriptionLabel,0,6);
    
    // Values
    messagesFileButton = createChooseFileButton("messagesFile");
    UIUtils.setSize(messagesFileButton,Main.columnWidthLEFT/2, 24);
    networkFileButton = createChooseFileButton("networkFile");
    UIUtils.setSize(networkFileButton,Main.columnWidthLEFT/2, 24);
    newDatasetIdentifierField = new TextField();
    newDatasetIdentifierField.setPromptText("unique identifier");
    UIUtils.setSize(newDatasetIdentifierField,Main.columnWidthLEFT/2, 24);
    newDatasetDescriptionField = new TextField();
    newDatasetDescriptionField.setPromptText("short dataset description");
    UIUtils.setSize(newDatasetDescriptionField,Main.columnWidthLEFT/2, 24);
    gridLEFT.add(messagesFileButton,1,0);
    gridLEFT.add(networkFileButton,1,2);
    gridLEFT.add(newDatasetIdentifierField,1,4);
    gridLEFT.add(newDatasetDescriptionField,1,6);
    HBox importDatasetBOTH = new HBox(5);
    importDatasetBOTH.getChildren().addAll(gridLEFT,createImportButton());
    grid.add(importDatasetBOTH,0,5);
}
 
Example 21
Source Project: constellation   Source File: FloatEditorFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Node createEditorControls() {
    final VBox controls = new VBox();
    controls.setAlignment(Pos.CENTER);

    numberField = new TextField();
    numberField.textProperty().addListener((o, n, v) -> {
        update();
    });

    controls.getChildren().add(numberField);
    return controls;
}
 
Example 22
Source Project: marathonv5   Source File: ResourceView.java    License: Apache License 2.0 5 votes vote down vote up
private void createTextField() {
    textField = new TextField(getString());
    textField.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                Resource value = getTreeItem().getValue();
                File file = new File(((FolderResource) value.getParent()).getFilePath().toFile(), textField.getText());
                if (file.exists()) {
                    FXUIUtils.showMessageDialog(null, "File " + file.getName() + " already exists", null, AlertType.ERROR);
                    cancelEdit();
                    return;
                }
                Resource renamed = value.rename(textField.getText());
                if (renamed != null) {
                    commitEdit(renamed);
                    Resource parent = (Resource) value.getParent();
                    if (parent != null) {
                        int index = parent.getChildren().indexOf(value);
                        parent.getChildren().remove(index);
                        parent.getChildren().add(index, renamed);
                    }
                } else {
                    cancelEdit();
                }
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            }
        }
    });
}
 
Example 23
Source Project: constellation   Source File: DoubleEditorFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Node createEditorControls() {
    final VBox controls = new VBox();
    controls.setAlignment(Pos.CENTER);

    numberField = new TextField();
    numberField.textProperty().addListener((o, n, v) -> {
        update();
    });

    controls.getChildren().add(numberField);
    return controls;
}
 
Example 24
Source Project: marathonv5   Source File: JavaFXTextFieldElementTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void getText() {
    TextField textFieldNode = (TextField) getPrimaryStage().getScene().getRoot().lookup(".text-field");
    AssertJUnit.assertEquals("Text", textField.getText());
    textField.marathon_select("Hello World");
    new Wait("Waiting for the text field value to be set") {
        @Override
        public boolean until() {
            return "Hello World".equals(textFieldNode.getText());
        }
    };
    AssertJUnit.assertEquals("Hello World", textField.getText());
}
 
Example 25
Source Project: dm3270   Source File: TransfersTab.java    License: Apache License 2.0 5 votes vote down vote up
private HBox getLine (RadioButton button, TextField text)
{
  HBox line = new HBox (10);
  line.getChildren ().addAll (button, text);
  button.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (300);
  text.setFont (defaultFont);
  text.setEditable (false);
  text.setFocusTraversable (false);
  button.setUserData (text);

  return line;
}
 
Example 26
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());
}
 
Example 27
Source Project: marathonv5   Source File: WebViewSample.java    License: Apache License 2.0 5 votes vote down vote up
public WebViewSample() {
    WebView webView = new WebView();
    
    final WebEngine webEngine = webView.getEngine();
    webEngine.load(DEFAULT_URL);
    
    final TextField locationField = new TextField(DEFAULT_URL);
    webEngine.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            webEngine.load(locationField.getText().startsWith("http://") 
                    ? locationField.getText() 
                    : "http://" + locationField.getText());
        }
    };
    locationField.setOnAction(goAction);
    
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    goButton.setOnAction(goAction);
    
    // Layout logic
    HBox hBox = new HBox(5);
    hBox.getChildren().setAll(locationField, goButton);
    HBox.setHgrow(locationField, Priority.ALWAYS);
    
    VBox vBox = new VBox(5);
    vBox.getChildren().setAll(hBox, webView);
    VBox.setVgrow(webView, Priority.ALWAYS);

    getChildren().add(vBox);
}
 
Example 28
Source Project: marathonv5   Source File: JavaFXTextFieldElementTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void marathon_select() {
    TextField textFieldNode = (TextField) getPrimaryStage().getScene().getRoot().lookup(".text-field");
    textField.marathon_select("Hello World");
    new Wait("Waiting for the text field value to be set") {
        @Override
        public boolean until() {
            return "Hello World".equals(textFieldNode.getText());
        }
    };
}
 
Example 29
Source Project: metastone   Source File: IntegerListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
	if (newText.matches("\\d*")) {
		int value = Integer.parseInt(newText);
		action.onChanged(value);
	} else {
		TextField textField = (TextField) observable;
		textField.setText(oldText);
	}
}
 
Example 30
Source Project: jmonkeybuilder   Source File: CreateSceneAppStateDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createContent(@NotNull final GridPane root) {
    super.createContent(root);

    final Label customBoxLabel = new Label(Messages.CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_BOX + ":");
    customBoxLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    customCheckBox = new CheckBox();
    customCheckBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final Label builtInLabel = new Label(Messages.CREATE_SCENE_APP_STATE_DIALOG_BUILT_IN + ":");
    builtInLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    builtInBox = new ComboBox<>();
    builtInBox.disableProperty().bind(customCheckBox.selectedProperty());
    builtInBox.getItems().addAll(BUILT_IN_NAMES);
    builtInBox.getSelectionModel().select(BUILT_IN_NAMES.first());
    builtInBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final Label customNameLabel = new Label(Messages.CREATE_SCENE_APP_STATE_DIALOG_CUSTOM_FIELD + ":");
    customNameLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));

    stateNameField = new TextField();
    stateNameField.disableProperty().bind(customCheckBox.selectedProperty().not());
    stateNameField.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));

    final GridPane settingsContainer = new GridPane();
    root.add(builtInLabel, 0, 0);
    root.add(builtInBox, 1, 0);
    root.add(customBoxLabel, 0, 1);
    root.add(customCheckBox, 1, 1);
    root.add(customNameLabel, 0, 2);
    root.add(stateNameField, 1, 2);

    FXUtils.addToPane(settingsContainer, root);

    FXUtils.addClassTo(builtInLabel, customBoxLabel, customNameLabel, CssClasses.DIALOG_DYNAMIC_LABEL);
    FXUtils.addClassTo(builtInBox, customCheckBox, stateNameField, CssClasses.DIALOG_FIELD);
}