javafx.scene.control.TextField Java Examples
The following examples show how to use
javafx.scene.control.TextField.
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 File: MainView.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #2
Source File: ExampleCss.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 6 votes |
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 #3
Source File: BoardTests.java From HubTurbo with GNU Lesser General Public License v3.0 | 6 votes |
@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 #4
Source File: RTToleranceEditor.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
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 #5
Source File: SupplyView.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
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 #6
Source File: EditView.java From helloiot with GNU General Public License v3.0 | 6 votes |
@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 #7
Source File: RFXTextFieldTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@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 #8
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 6 votes |
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 #9
Source File: BrowserTab.java From marathonv5 with Apache License 2.0 | 6 votes |
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 #10
Source File: MZRangeEditor.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
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 #11
Source File: LongObjectEditorFactory.java From constellation with Apache License 2.0 | 6 votes |
@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 #12
Source File: UILargeNumberMenuItem.java From tcMenu with Apache License 2.0 | 6 votes |
@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 #13
Source File: DemoPane.java From FxDock with Apache License 2.0 | 5 votes |
public DemoPane(String type) { super(type); CheckBox cb = new CheckBox("boolean property"); LocalSettings.get(this).add("CHECKBOX", cb); TextField textField = new TextField(); LocalSettings.get(this).add("TEXTFIELD", textField); // VPane vb = new VPane(); // a(vb, 2, 0.25, 0.25, HPane.FILL); // a(vb, 2, 30, 30, 100); // a(vb, 2, 0.2, 0.2, 0.6); // a(vb, 2, HPane.PREF, HPane.FILL, HPane.PREF); // a(vb, 2, HPane.FILL, HPane.FILL, HPane.FILL); // a(vb, 2, 20, HPane.FILL, 20); // a(vb, 2, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL, HPane.FILL); // a(vb, 2, 50, HPane.FILL, HPane.FILL, 50); HPane vb = new HPane(2); vb.add(cb); vb.add(textField); BorderPane bp = new BorderPane(); bp.setCenter(createColorNode(type)); bp.setBottom(vb); setCenter(bp); this.pseq = seq++; setTitle("pane " + pseq); // set up context menu off the title field FX.setPopupMenu(titleField, this::createTitleFieldPopupMenu); }
Example #14
Source File: LoadFileController.java From Sword_emulator with GNU General Public License v3.0 | 5 votes |
private void bind(File originFile, Button selectButton, SwordPrefs defaultPath, TextField fileText) { if (originFile != null) { fileText.setText(originFile.getAbsolutePath()); } selectButton.setOnAction(event -> { FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("COE文件", "*.coe"), new FileChooser.ExtensionFilter("HEX文件", "*.hex"), new FileChooser.ExtensionFilter("二进制文件", "*.*") ); File selected; try { fileChooser.setInitialDirectory(new File(defaultPath.get())); selected = fileChooser.showOpenDialog(FxUtils.getStage(ramText)); } catch (Exception e) { e.printStackTrace(); // retry without initial directory fileChooser.setInitialDirectory(null); try { selected = fileChooser.showOpenDialog(FxUtils.getStage(ramText)); } catch (Exception e2) { e2.printStackTrace(); selected = null; } } if (selected != null) { fileText.setText(selected.getAbsolutePath()); defaultPath.set(selected.getParent()); } }); }
Example #15
Source File: BsqBalanceUtil.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public int addGroup(GridPane gridPane, int gridRow) { int startIndex = gridRow; addTitledGroupBg(gridPane, gridRow, 4, Res.get("dao.wallet.dashboard.myBalance")); availableBalanceTextField = FormBuilder.addTopLabelReadOnlyTextField(gridPane, gridRow, Res.get("dao.availableBsqBalance"), Layout.FIRST_ROW_DISTANCE).second; verifiedBalanceTextField = FormBuilder.addTopLabelReadOnlyTextField(gridPane, ++gridRow, Res.get("dao.verifiedBsqBalance")).second; unconfirmedChangTextField = FormBuilder.addTopLabelReadOnlyTextField(gridPane, ++gridRow, Res.get("dao.unconfirmedChangeBalance")).second; unverifiedBalanceTextField = FormBuilder.addTopLabelReadOnlyTextField(gridPane, ++gridRow, Res.get("dao.unverifiedBsqBalance")).second; gridRow = startIndex; int columnIndex = 2; addTitledGroupBg(gridPane, gridRow, columnIndex, 4, ""); lockedForVoteBalanceTextField = FormBuilder.addTopLabelReadOnlyTextField(gridPane, gridRow, columnIndex, Res.get("dao.lockedForVoteBalance"), Layout.FIRST_ROW_DISTANCE).second; lockedInBondsBalanceTextField = FormBuilder.addTopLabelReadOnlyTextField(gridPane, ++gridRow, columnIndex, Res.get("dao.lockedInBonds")).second; reputationBalanceTextField = FormBuilder.addTopLabelReadOnlyTextField(gridPane, ++gridRow, columnIndex, Res.get("dao.reputationBalance")).second; Tuple3<Label, TextField, VBox> tuple3 = FormBuilder.addTopLabelReadOnlyTextField(gridPane, ++gridRow, columnIndex, Res.get("dao.availableNonBsqBalance")); // Match left column ++gridRow; // TODO add unlockingBondsBalanceTextField availableNonBsqBalanceLabel = tuple3.first; availableNonBsqBalanceTextField = tuple3.second; availableNonBsqBalanceTextField.setVisible(false); availableNonBsqBalanceTextField.setManaged(false); return gridRow; }
Example #16
Source File: DemoBrowser.java From FxDock with Apache License 2.0 | 5 votes |
public DemoBrowser() { super(DemoGenerator.BROWSER); setTitle("Browser / " + CSystem.getJavaVersion()); addressField = new TextField(); addressField.addEventHandler(KeyEvent.KEY_PRESSED, (ev) -> handleKeyTyped(ev)); LocalSettings.get(this).add("URL", addressField); view = new WebView(); view.getEngine().setOnError((ev) -> handleError(ev)); view.getEngine().setOnStatusChanged((ev) -> handleStatusChange(ev)); Worker<Void> w = view.getEngine().getLoadWorker(); w.stateProperty().addListener(new ChangeListener<Worker.State>() { public void changed(ObservableValue v, Worker.State old, Worker.State cur) { log.debug(cur); if(w.getException() != null && cur == State.FAILED) { log.error(w.getException()); } } }); statusField = new Label(); CPane p = new CPane(); p.setGaps(10, 5); p.setCenter(view); p.setBottom(statusField); setContent(p); FX.later(() -> reload()); }
Example #17
Source File: MakeProposalView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Override public void initialize() { gridRow = phasesView.addGroup(root, gridRow); proposalTitledGroup = addTitledGroupBg(root, ++gridRow, 2, proposalGroupTitle.get(), Layout.GROUP_DISTANCE); proposalTitledGroup.getStyleClass().add("last"); final Tuple3<Label, TextField, VBox> nextProposalPhaseTuple = addTopLabelReadOnlyTextField(root, gridRow, Res.get("dao.cycle.proposal.next"), Layout.FIRST_ROW_AND_GROUP_DISTANCE); nextProposalBox = nextProposalPhaseTuple.third; nextProposalTextField = nextProposalPhaseTuple.second; proposalTypeComboBox = addComboBox(root, gridRow, Res.get("dao.proposal.create.proposalType"), Layout.FIRST_ROW_AND_GROUP_DISTANCE); proposalTypeComboBox.setMaxWidth(300); proposalTypeComboBox.setConverter(new StringConverter<>() { @Override public String toString(ProposalType proposalType) { return proposalType.getDisplayName(); } @Override public ProposalType fromString(String string) { return null; } }); proposalTypeChangeListener = (observable, oldValue, newValue) -> { selectedProposalType = newValue; removeProposalDisplay(); addProposalDisplay(); }; alwaysVisibleGridRowIndex = gridRow + 1; List<ProposalType> proposalTypes = Arrays.stream(ProposalType.values()) .filter(e -> e != ProposalType.UNDEFINED) .collect(Collectors.toList()); proposalTypeComboBox.setItems(FXCollections.observableArrayList(proposalTypes)); }
Example #18
Source File: JavaFxSelectionComponentFactory.java From triplea with GNU General Public License v3.0 | 5 votes |
FileSelector( final ClientSetting<Path> clientSetting, final BiFunction<Window, /* @Nullable */ Path, /* @Nullable */ Path> chooseFile) { this.clientSetting = clientSetting; final @Nullable Path initialValue = clientSetting.getValue().orElse(null); final HBox wrapper = new HBox(); textField = new TextField(SelectionComponentUiUtils.toString(clientSetting.getValue())); textField .prefColumnCountProperty() .bind(Bindings.add(1, Bindings.length(textField.textProperty()))); textField.setMaxWidth(Double.MAX_VALUE); textField.setMinWidth(100); textField.setDisable(true); final Button chooseFileButton = new Button("..."); selectedPath = initialValue; chooseFileButton.setOnAction( e -> { final @Nullable Path path = chooseFile.apply(chooseFileButton.getScene().getWindow(), selectedPath); if (path != null) { selectedPath = path; textField.setText(path.toString()); } }); wrapper.getChildren().addAll(textField, chooseFileButton); getChildren().add(wrapper); }
Example #19
Source File: IntegerComponent.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Input verifier used when minimum or maximum bounds are defined. */ /* * private class MinMaxVerifier extends InputVerifier { * * @Override public boolean shouldYieldFocus(final JComponent input) { * * final boolean yield = super.shouldYieldFocus(input); if (!yield) { * * // Beep and highlight. Toolkit.getDefaultToolkit().beep(); ((JTextComponent) * input).selectAll(); } * * return yield; } * * @Override public boolean verify(final JComponent input) { * * boolean verified = false; try { * * verified = checkBounds(Integer.parseInt(((JTextComponent) input).getText())); } catch (final * NumberFormatException e) { * * // not a number. } * * return verified; } } */ public TextField getTextField() { return textField; }
Example #20
Source File: CheckListFormNode.java From marathonv5 with Apache License 2.0 | 5 votes |
private VBox createNameField() { VBox nameFieldBox = new VBox(); TextField nameField = new TextField(); nameField.textProperty().addListener((observable, oldValue, newValue) -> { fireContentChanged(); checkList.setName(nameField.getText()); }); nameField.setEditable(mode.isSelectable()); nameFieldBox.getChildren().addAll(new Label("Name"), nameField); HBox.setHgrow(nameField, Priority.ALWAYS); VBox.setMargin(nameFieldBox, new Insets(5, 10, 0, 5)); nameField.setText(checkList.getName()); HBox.setHgrow(nameFieldBox, Priority.ALWAYS); return nameFieldBox; }
Example #21
Source File: WebViewSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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 #22
Source File: TableAttributeKeyValueTemplateEditingCell.java From Vert.X-generator with MIT License | 5 votes |
private void createTextField() { textField = new TextField(getString()); textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2); textField.focusedProperty().addListener((ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) -> { if (!arg2) { commitEdit(textField.getText()); } }); }
Example #23
Source File: SettingsView.java From Schillsaver with MIT License | 5 votes |
private Pane createControlRow(final @NonNull Button button, final @NonNull TextField field) { final HBox hBox = new HBox(button, field); VBox.setVgrow(hBox, Priority.ALWAYS); HBox.setHgrow(button, Priority.NEVER); HBox.setHgrow(field, Priority.ALWAYS); button.setMinWidth(256); return hBox; }
Example #24
Source File: CategoryFragment.java From Notebook with Apache License 2.0 | 5 votes |
private void createDialog(Category listItem) { List<Category> categories = CategoryDao.getInstance().findAll(); AlertDialog.Builder builder = new AlertDialog.Builder(); builder.title("���༭"); builder.view("dialog_category_edit") .build(); alertDialog = builder.build(); Button btn_confirm = alertDialog.findView("#btn_confirm", Button.class); Button btn_cancel = alertDialog.findView("#btn_cancel", Button.class); TextField et_title = alertDialog.findView("#et_title", TextField.class); if(listItem.getName() != null) et_title.setText(listItem.getName()); btn_confirm.setOnAction(ee ->{ String name = et_title.getText(); if(name.equals("")){ DialogHelper.alert("Error", "���ݲ���Ϊ�գ�"); return; } // update ListView items & database listItem.setName(name); CategoryDao.getInstance().saveOrUpdate(listItem); // �Զ�ˢ�� loadData(); alertDialog.close(); }); btn_cancel.setOnAction(eee->{ alertDialog.close(); }); alertDialog.show(); }
Example #25
Source File: TablePane.java From Intro-to-Java-Programming with MIT License | 5 votes |
/** Return a table */ private VBox getTable(TextField x, TextField y, TextField width, TextField height, int n) { VBox vBox = new VBox(2); vBox.setStyle("-fx-border-color: Black"); vBox.getChildren().addAll(new Label("Enter rectangle " + n + " info:"), getGrid(x, y, width, height)); return vBox; }
Example #26
Source File: Mask.java From DashboardFx with GNU General Public License v3.0 | 5 votes |
public static void maxField(TextField field, int length) { field.textProperty().addListener((observableValue, oldValue, newValue) -> { if (newValue == null || newValue.length() > length) { field.setText(oldValue); } }); }
Example #27
Source File: CreateSceneAppStateDialog.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@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); }
Example #28
Source File: IntegerListener.java From metastone with GNU General Public License v2.0 | 5 votes |
@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 #29
Source File: JavaFXTextFieldElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@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 #30
Source File: Exercise_18_36.java From Intro-to-Java-Programming with MIT License | 5 votes |
@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()); }