javafx.scene.control.TextField源码实例Demo

类javafx.scene.control.TextField源码实例Demo

下面列出了javafx.scene.control.TextField 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bisq   文件: SupplyView.java
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);
}
 
源代码2 项目: MyBox   文件: FxmlControl.java
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);
        }
    });
}
 
源代码3 项目: constellation   文件: LongObjectEditorFactory.java
@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;
}
 
源代码4 项目: old-mzmine3   文件: MZRangeEditor.java
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);
}
 
源代码5 项目: gluon-samples   文件: MainView.java
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));

    }
 
源代码6 项目: chuidiang-ejemplos   文件: ExampleCss.java
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();
}
 
源代码7 项目: HubTurbo   文件: BoardTests.java
@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);
}
 
源代码8 项目: helloiot   文件: EditView.java
@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;
}
 
源代码9 项目: marathonv5   文件: RFXTextFieldTest.java
@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]);
}
 
源代码10 项目: tcMenu   文件: UILargeNumberMenuItem.java
@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;
}
 
源代码11 项目: marathonv5   文件: BrowserTab.java
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);
}
 
源代码12 项目: old-mzmine3   文件: RTToleranceEditor.java
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);
}
 
源代码13 项目: Intro-to-Java-Programming   文件: Exercise_18_36.java
@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());
}
 
源代码14 项目: BowlerStudio   文件: LinkConfigurationWidget.java
double textToNum(TextField mass) {
	try {
		return Double.parseDouble(mass.getText().trim());
	} catch (Throwable t) {
		mass.setText("0");
		return 0;
	}
}
 
源代码15 项目: BowlerStudio   文件: AdjustbodyMassWidget.java
double textToNum(TextField mass) {
	try {
		return Double.parseDouble(mass.getText().trim());
	}catch(Throwable t) {
		mass.setText("0");
		return 0;
	}
}
 
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();
}
 
源代码17 项目: VocabHunter   文件: SettingsController.java
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));
}
 
源代码18 项目: dm3270   文件: TransfersTab.java
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;
}
 
源代码19 项目: ApkToolPlus   文件: ViewUtils.java
/**
 * 恢復数据显示
 *  @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;
}
 
源代码20 项目: SONDY   文件: DataManipulationUI.java
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);
}
 
源代码21 项目: constellation   文件: FloatEditorFactory.java
@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;
}
 
源代码22 项目: marathonv5   文件: ResourceView.java
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();
            }
        }
    });
}
 
源代码23 项目: constellation   文件: DoubleEditorFactory.java
@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;
}
 
源代码24 项目: marathonv5   文件: JavaFXTextFieldElementTest.java
@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());
}
 
源代码25 项目: dm3270   文件: TransfersTab.java
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;
}
 
源代码26 项目: devcoretalk   文件: BitcoinAddressValidator.java
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());
}
 
源代码27 项目: marathonv5   文件: WebViewSample.java
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);
}
 
源代码28 项目: marathonv5   文件: JavaFXTextFieldElementTest.java
@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());
        }
    };
}
 
源代码29 项目: metastone   文件: IntegerListener.java
@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);
	}
}
 
源代码30 项目: jmonkeybuilder   文件: CreateSceneAppStateDialog.java
@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);
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 类方法
 同包方法