List of usage examples for javafx.scene.control TextArea textProperty
public final StringProperty textProperty()
From source file:sudoku.controller.ViewController.java
public void attachTextEventHandlers(ArrayList<TextArea> textAreas) { for (TextArea textArea : textAreas) { textArea.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { String parentID = textArea.getParent().getId(); //get the row and column of the cell int row = parentID.charAt(0) - 48; int column = parentID.charAt(1) - 48; System.out.println("Parent: " + textArea.getParent().getId()); //if it's an empty cell if (newValue.equals("")) GameController.userBoard[row][column] = 0; // if the length is greater than 1, it's an invalid input if (newValue.length() > 1) textArea.setText(oldValue); //make sure that the user is actually providing a +ve number greater than 0 as an input if (newValue.length() > 0) { int value = newValue.charAt(0) - 48; if (!Character.isDigit(newValue.charAt(0)) || newValue.charAt(0) == 48) { textArea.setText(""); GameController.userBoard[row][column] = 0; } else { //for an illegal move, set the cell's text to a red color if (!solver.isLegal(GameController.userBoard, row, column, value)) { textArea.setStyle("-fx-text-fill: red;"); } else { textArea.setStyle("-fx-text-fill: black;"); }//from w w w . j a va 2s.c o m GameController.userBoard[row][column] = value; } } }); } }
From source file:de.chaosfisch.uploader.gui.renderer.TagTextArea.java
private void initTextArea() { final TextArea textArea = new TextArea(); textArea.setWrapText(true);// w w w . ja va 2 s . com textArea.textProperty().bindBidirectional(tags); getChildren().add(textArea); }
From source file:Main.java
Parent getContent() { TextArea textArea = TextAreaBuilder.create().wrapText(true).build(); nextButton.setDisable(true);//from ww w. ja v a 2 s . co m textArea.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observableValue, String oldValue, String newValue) { nextButton.setDisable(newValue.isEmpty()); } }); SurveyData.instance.complaints.bind(textArea.textProperty()); return VBoxBuilder.create().spacing(5).children(new Label("Please enter your complaints."), textArea) .build(); }
From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java
protected void createTextAreaInput(final int numLines, final ConfigFrame cf, final String propertyName, final String initialValue, final Consumer<String> applyValue) { final TextArea inputField = new TextArea(initialValue); inputField.setPrefRowCount(numLines); inputField.setWrapText(true);/*from w ww. jav a 2 s. c o m*/ inputField.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { applyValue.accept(newValue); this.getGraph().handleChange(); }); cf.addOption(propertyName, inputField); }
From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java
@Override public Node getConfigFrame() { // TODO: Remove code redundancies; element creating methods have been created in class AutomatonEdge and should be centralized! final ConfigFrame cf = new ConfigFrame("State properties"); final int nameInputLines = 1; final TextArea nameInput = new TextArea(this.name); nameInput.setPrefRowCount(nameInputLines); nameInput.setWrapText(true);//w ww .java 2s. co m nameInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { this.setName(newValue); this.getGraph().handleChange(); }); cf.addOption("Name", nameInput); final int descriptionInputLines = 3; this.createTextAreaInput(descriptionInputLines, cf, "Description", this.getDescription(), newValue -> this.setDescription(newValue)); final VBox typeAttributes = new VBox(); final ToggleGroup flagToggleGroup = new ToggleGroup(); typeAttributes.getChildren() .add(this.createRadioButtonForType(null, "None (intermediate node)", flagToggleGroup)); typeAttributes.getChildren().add(this.createRadioButtonForType(Type.INITIAL, "Initial", flagToggleGroup)); final RadioButton successOption = this.createRadioButtonForType(Type.SUCCESS, "Success", flagToggleGroup); typeAttributes.getChildren().add(successOption); typeAttributes.getChildren().add(this.createRadioButtonForType(Type.FAILURE, "Failure", flagToggleGroup)); cf.addOption("Type", typeAttributes); final CheckBox waitCheckBox = new CheckBox("Active"); waitCheckBox.setSelected(this.wait); waitCheckBox.setOnAction(event -> { this.setWait(waitCheckBox.isSelected()); this.getGraph().handleChange(); }); cf.addOption("Wait", waitCheckBox); final int expressionInputLines = 1; final TextArea successCheckExpInput = new TextArea(this.successCheckExp); successCheckExpInput.setStyle("-fx-font-family: monospace"); successCheckExpInput.setPrefRowCount(expressionInputLines); successCheckExpInput.setWrapText(false); successCheckExpInput.textProperty() .addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { this.setSuccessCheckExp(newValue); this.getGraph().handleChange(); }); successCheckExpInput.disableProperty().bind(successOption.selectedProperty().not()); cf.addOption("Script expression to verify if node is successful", successCheckExpInput); this.createEnterAndLeaveScriptConfig(cf); return cf; }
From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java
public void createEnterAndLeaveScriptConfig(final ConfigFrame cf) { final int scriptInputLines = 3; final TextArea onEnterScriptInput = new TextArea(this.onEnter); onEnterScriptInput.setStyle("-fx-font-family: monospace"); onEnterScriptInput.setPrefRowCount(scriptInputLines); onEnterScriptInput.setWrapText(false); onEnterScriptInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { this.setOnEnter(newValue); this.getGraph().handleChange(); });/*from w ww . j a va 2s.c om*/ cf.addOption("When entering state, run script", onEnterScriptInput); final TextArea onLeaveScriptInput = new TextArea(this.onLeave); onLeaveScriptInput.setStyle("-fx-font-family: monospace"); onLeaveScriptInput.setPrefRowCount(scriptInputLines); onLeaveScriptInput.setWrapText(false); onLeaveScriptInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { this.setOnLeave(newValue); this.getGraph().handleChange(); }); cf.addOption("When leaving state, run script", onLeaveScriptInput); }
From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java
public void createLogFileSourceInputItems(final List<Triple<String, Node, String>> formItems) { final TextField logFilePath = new TextField(); this.logFilePathProperty.bind(logFilePath.textProperty()); HBox.setHgrow(logFilePath, Priority.ALWAYS); final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(logFilePath, LogReaderEditor.LOG_FILE_ICON_NAME, "Select log file", null, null); final HBox fileInputConfig = new HBox(logFilePath, selectLogFileButton); final VBox lines = new VBox(); final double spacingOfLines = 5d; lines.setSpacing(spacingOfLines);/*w ww. jav a 2 s . c o m*/ final HBox inputTypeLine = new HBox(); final double hSpacingOfInputTypeChoices = 30d; inputTypeLine.setSpacing(hSpacingOfInputTypeChoices); final ToggleGroup group = new ToggleGroup(); final RadioButton inputTypeText = new RadioButton("Paste/Enter log"); inputTypeText.setToggleGroup(group); this.loadLogFromEnteredTextProperty.bind(inputTypeText.selectedProperty()); final RadioButton inputTypeFile = new RadioButton("Read log file"); inputTypeFile.setToggleGroup(group); this.loadLogFromFileProperty.bind(inputTypeFile.selectedProperty()); inputTypeFile.setSelected(true); inputTypeLine.getChildren().add(inputTypeText); inputTypeLine.getChildren().add(inputTypeFile); fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty()); fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty()); final TextArea logInputText = new TextArea(); HBox.setHgrow(logInputText, Priority.ALWAYS); final int numLinesForEnteringLogInputManually = 10; logInputText.setPrefRowCount(numLinesForEnteringLogInputManually); logInputText.setStyle("-fx-font-family: monospace"); this.enteredLogTextProperty.bind(logInputText.textProperty()); final HBox enterTextConfig = new HBox(); enterTextConfig.getChildren().add(logInputText); enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty()); enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty()); lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig); formItems.add(Triple.of("Trace Log", lines, null)); }
From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java
protected void createTextAreaInput(final int numLines, final ConfigFrame cf, final String propertyName, final String initialValue, final Consumer<String> applyValue, final Monospace monospace) { final TextArea inputField = new TextArea(initialValue); this.setMonospaceIfDesired(monospace, inputField); inputField.setPrefRowCount(numLines); inputField.setWrapText(true);//from ww w . jav a 2s. com inputField.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { applyValue.accept(newValue); this.getGraph().handleChange(); }); cf.addOption(propertyName, inputField); }
From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java
private List<Triple<String, Node, String>> createConfigurationForm() { final List<Triple<String, Node, String>> formItems = new ArrayList<>(); // Automaton file final TextField automatonFilePath = new TextField(); this.automatonFilePathProperty.bind(automatonFilePath.textProperty()); HBox.setHgrow(automatonFilePath, Priority.ALWAYS); final Button selectAutomatonFilePathButton = SelectFileButton.createButtonWithFileSelection( automatonFilePath, Editor.Type.AUTOMATON.getIconName(), "Select " + Editor.Type.AUTOMATON.getName(), Editor.Type.AUTOMATON.getFileMask(), Editor.Type.AUTOMATON.getFileDescription()); final HBox automatonFilePathConfig = new HBox(automatonFilePath, selectAutomatonFilePathButton); formItems.add(Triple.of("Automaton", automatonFilePathConfig, null)); // Automaton parameters final TextArea parametersInputText = new TextArea(); parametersInputText.setStyle("-fx-font-family: monospace"); HBox.setHgrow(parametersInputText, Priority.ALWAYS); final int parametersInputLinesSize = 4; parametersInputText.setPrefRowCount(parametersInputLinesSize); this.parametersProperty.bind(parametersInputText.textProperty()); formItems.add(Triple.of("Parameters", parametersInputText, "Set parameters for the execution. Each line can contain a parameter as follows: ${PARAMETER}=value, e.g. ${TIMEOUT}=10.")); // Log file/* ww w. j a v a 2 s .com*/ this.createLogFileSourceInputItems(formItems); // Log reader configuration file final TextField logReaderConfigurationFilePath = new TextField(); this.logReaderConfigurationFilePathProperty.bind(logReaderConfigurationFilePath.textProperty()); HBox.setHgrow(logReaderConfigurationFilePath, Priority.ALWAYS); final Button selectLogReaderConfigurationFilePathButton = SelectFileButton.createButtonWithFileSelection( logReaderConfigurationFilePath, Editor.Type.LOG_READER_CONFIG.getIconName(), "Select " + Editor.Type.LOG_READER_CONFIG.getName(), Editor.Type.LOG_READER_CONFIG.getFileMask(), Editor.Type.LOG_READER_CONFIG.getFileDescription()); final HBox logReaderConfigurationFilePathConfig = new HBox(logReaderConfigurationFilePath, selectLogReaderConfigurationFilePathButton); formItems.add(Triple.of("Log Reader Configuration", logReaderConfigurationFilePathConfig, null)); // Debug output final CheckBox cb = new CheckBox(); this.showDebugOutputProperty.bind(cb.selectedProperty()); formItems.add(Triple.of("Show Debug Output", cb, "Show verbose debug output. Might generate lots of text and slows down the" + " evaluation, but is very helpful for debugging automatons while developing them.")); return formItems; }
From source file:io.bitsquare.gui.components.paymentmethods.CashDepositForm.java
@Override public void addFormForAddAccount() { gridRowFrom = gridRow + 1;/*w w w. j av a 2 s . c o m*/ Tuple3<Label, ComboBox, ComboBox> tuple3 = addLabelComboBoxComboBox(gridPane, ++gridRow, "Country:"); ComboBox<Region> regionComboBox = tuple3.second; regionComboBox.setPromptText("Select region"); regionComboBox.setConverter(new StringConverter<Region>() { @Override public String toString(Region region) { return region.name; } @Override public Region fromString(String s) { return null; } }); regionComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllRegions())); ComboBox<Country> countryComboBox = tuple3.third; countryComboBox.setVisibleRowCount(15); countryComboBox.setDisable(true); countryComboBox.setPromptText("Select country"); countryComboBox.setConverter(new StringConverter<Country>() { @Override public String toString(Country country) { return country.name + " (" + country.code + ")"; } @Override public Country fromString(String s) { return null; } }); countryComboBox.setOnAction(e -> { Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem(); if (selectedItem != null) { getCountryBasedPaymentAccount().setCountry(selectedItem); String countryCode = selectedItem.code; TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode); paymentAccount.setSingleTradeCurrency(currency); currencyComboBox.setDisable(false); currencyComboBox.getSelectionModel().select(currency); bankIdLabel.setText(BankUtil.getBankIdLabel(countryCode)); branchIdLabel.setText(BankUtil.getBranchIdLabel(countryCode)); accountNrLabel.setText(BankUtil.getAccountNrLabel(countryCode)); accountTypeLabel.setText(BankUtil.getAccountTypeLabel(countryCode)); bankNameInputTextField.setText(""); bankIdInputTextField.setText(""); branchIdInputTextField.setText(""); accountNrInputTextField.setText(""); accountTypeComboBox.getSelectionModel().clearSelection(); accountTypeComboBox .setItems(FXCollections.observableArrayList(BankUtil.getAccountTypeValues(countryCode))); if (BankUtil.useValidation(countryCode) && !validatorsApplied) { validatorsApplied = true; if (useHolderID) holderIdInputTextField.setValidator(inputValidator); bankNameInputTextField.setValidator(inputValidator); bankIdInputTextField.setValidator(new BankIdValidator(countryCode)); branchIdInputTextField.setValidator(new BranchIdValidator(countryCode)); accountNrInputTextField.setValidator(new AccountNrValidator(countryCode)); } else { validatorsApplied = false; if (useHolderID) holderIdInputTextField.setValidator(null); bankNameInputTextField.setValidator(null); bankIdInputTextField.setValidator(null); branchIdInputTextField.setValidator(null); accountNrInputTextField.setValidator(null); } holderNameInputTextField.resetValidation(); holderEmailInputTextField.resetValidation(); bankNameInputTextField.resetValidation(); bankIdInputTextField.resetValidation(); branchIdInputTextField.resetValidation(); accountNrInputTextField.resetValidation(); boolean requiresHolderId = BankUtil.isHolderIdRequired(countryCode); if (requiresHolderId) { holderNameInputTextField.minWidthProperty().unbind(); holderNameInputTextField.setMinWidth(300); } else { holderNameInputTextField.minWidthProperty().bind(currencyComboBox.widthProperty()); } if (useHolderID) { if (!requiresHolderId) holderIdInputTextField.setText(""); holderIdInputTextField.resetValidation(); holderIdInputTextField.setVisible(requiresHolderId); holderIdInputTextField.setManaged(requiresHolderId); holderIdLabel.setText(BankUtil.getHolderIdLabel(countryCode)); holderIdLabel.setVisible(requiresHolderId); holderIdLabel.setManaged(requiresHolderId); } boolean bankNameRequired = BankUtil.isBankNameRequired(countryCode); bankNameTuple.first.setVisible(bankNameRequired); bankNameTuple.first.setManaged(bankNameRequired); bankNameInputTextField.setVisible(bankNameRequired); bankNameInputTextField.setManaged(bankNameRequired); boolean bankIdRequired = BankUtil.isBankIdRequired(countryCode); bankIdTuple.first.setVisible(bankIdRequired); bankIdTuple.first.setManaged(bankIdRequired); bankIdInputTextField.setVisible(bankIdRequired); bankIdInputTextField.setManaged(bankIdRequired); boolean branchIdRequired = BankUtil.isBranchIdRequired(countryCode); branchIdTuple.first.setVisible(branchIdRequired); branchIdTuple.first.setManaged(branchIdRequired); branchIdInputTextField.setVisible(branchIdRequired); branchIdInputTextField.setManaged(branchIdRequired); boolean accountNrRequired = BankUtil.isAccountNrRequired(countryCode); accountNrTuple.first.setVisible(accountNrRequired); accountNrTuple.first.setManaged(accountNrRequired); accountNrInputTextField.setVisible(accountNrRequired); accountNrInputTextField.setManaged(accountNrRequired); boolean accountTypeRequired = BankUtil.isAccountTypeRequired(countryCode); accountTypeTuple.first.setVisible(accountTypeRequired); accountTypeTuple.first.setManaged(accountTypeRequired); accountTypeTuple.second.setVisible(accountTypeRequired); accountTypeTuple.second.setManaged(accountTypeRequired); updateFromInputs(); onCountryChanged(); } }); regionComboBox.setOnAction(e -> { Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem(); if (selectedItem != null) { countryComboBox.setDisable(false); countryComboBox.setItems( FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem))); } }); currencyComboBox = addLabelComboBox(gridPane, ++gridRow, "Currency:").second; currencyComboBox.setPromptText("Select currency"); currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies())); currencyComboBox.setOnAction(e -> { TradeCurrency selectedItem = currencyComboBox.getSelectionModel().getSelectedItem(); FiatCurrency defaultCurrency = CurrencyUtil .getCurrencyByCountryCode(countryComboBox.getSelectionModel().getSelectedItem().code); if (!defaultCurrency.equals(selectedItem)) { new Popup<>().warning( "Are you sure you want to choose a currency other than the country's default currency?") .actionButtonText("Yes").onAction(() -> { paymentAccount.setSingleTradeCurrency(selectedItem); autoFillNameTextField(); }).closeButtonText("No, restore default currency") .onClose(() -> currencyComboBox.getSelectionModel().select(defaultCurrency)).show(); } else { paymentAccount.setSingleTradeCurrency(selectedItem); autoFillNameTextField(); } }); currencyComboBox.setConverter(new StringConverter<TradeCurrency>() { @Override public String toString(TradeCurrency currency) { return currency.getNameAndCode(); } @Override public TradeCurrency fromString(String string) { return null; } }); currencyComboBox.setDisable(true); addAcceptedBanksForAddAccount(); addHolderNameAndId(); bankNameTuple = addLabelInputTextField(gridPane, ++gridRow, "Bank name:"); bankNameInputTextField = bankNameTuple.second; bankNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setBankName(newValue); updateFromInputs(); }); bankIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBankIdLabel("")); bankIdLabel = bankIdTuple.first; bankIdInputTextField = bankIdTuple.second; bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setBankId(newValue); updateFromInputs(); }); branchIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchIdLabel("")); branchIdLabel = branchIdTuple.first; branchIdInputTextField = branchIdTuple.second; branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setBranchId(newValue); updateFromInputs(); }); accountNrTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel("")); accountNrLabel = accountNrTuple.first; accountNrInputTextField = accountNrTuple.second; accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setAccountNr(newValue); updateFromInputs(); }); accountTypeTuple = addLabelComboBox(gridPane, ++gridRow, ""); accountTypeLabel = accountTypeTuple.first; accountTypeComboBox = accountTypeTuple.second; accountTypeComboBox.setPromptText("Select account type"); accountTypeComboBox.setOnAction(e -> { if (BankUtil.isAccountTypeRequired(cashDepositAccountContractData.getCountryCode())) { cashDepositAccountContractData .setAccountType(accountTypeComboBox.getSelectionModel().getSelectedItem()); updateFromInputs(); } }); TextArea requirementsTextArea = addLabelTextArea(gridPane, ++gridRow, "Extra requirements:", "").second; requirementsTextArea.setMinHeight(30); requirementsTextArea.setMaxHeight(30); requirementsTextArea.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setRequirements(newValue); updateFromInputs(); }); addAllowedPeriod(); addAccountNameTextFieldWithAutoFillCheckBox(); updateFromInputs(); }