Java Code Examples for javafx.scene.control.TextField#getText()
The following examples show how to use
javafx.scene.control.TextField#getText() .
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: Browser.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public void loadPage(TextField textField, //ProgressBar progressBar, WebEngine webEngine, WebView webView) { String route = textField.getText(); if (route !=null) if (!route.substring(0, 7).equals("http://")) { route = "http://" + route; textField.setText(route); } System.out.println("Loading route: " + route); //progressBar.progressProperty().bind(webEngine.getLoadWorker().progressProperty()); webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue<? extends State> value, State oldState, State newState) { if(newState == State.SUCCEEDED){ System.out.println("Location loaded + " + webEngine.getLocation()); } } }); webEngine.load(route); }
Example 2
Source File: Properties.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 6 votes |
default Node createGui(Stage stage, T value, Consumer<T> onAction) { TextField valueField = new TextField(toString(value)); Runnable updateValue = () -> { String newValue = valueField.getText(); if(!newValue.equals(value)) { try { onAction.accept(parse(newValue)); } catch(Exception exc) { exc.printStackTrace(); valueField.setText(toString(value)); } } }; valueField.setOnAction(event -> updateValue.run()); valueField.focusedProperty().addListener((observable, oldValue, newValue) -> { if(!newValue) { updateValue.run(); } }); return valueField; }
Example 3
Source File: AbstractFileCreator.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Gets file to create. * * @return the file to creating. */ @FromAnyThread protected @Nullable Path getFileToCreate() { final TextField fileNameField = getFileNameField(); final String filename = fileNameField.getText(); if (StringUtils.isEmpty(filename)) return null; final String fileExtension = getFileExtension(); final Path selectedFile = getSelectedFile(); final Path directory = Files.isDirectory(selectedFile) ? selectedFile : selectedFile.getParent(); return StringUtils.isEmpty(fileExtension) ? directory.resolve(filename) : directory.resolve(filename + "." + fileExtension); }
Example 4
Source File: SaveAsEditorDialog.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Gets file to create. * * @return the file to creating. */ @FromAnyThread protected @Nullable Path getFileToSave() { final TextField fileNameField = getFileNameField(); final String filename = fileNameField.getText(); if (StringUtils.isEmpty(filename)) return null; final String fileExtension = getExtension(); final Path selectedFile = getSelectedFile(); if (selectedFile == null) return null; final Path directory = Files.isDirectory(selectedFile) ? selectedFile : selectedFile.getParent(); return StringUtils.isEmpty(fileExtension) ? directory.resolve(filename) : directory.resolve(filename + "." + fileExtension); }
Example 5
Source File: StringArrayEditor.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private void handleEnter(final TextField field) { final String text = field.getText(); final List<Node> fields = getChildren(); final int i = fields.indexOf(field); if (i >= values.size()) values.add(text); values.set(i, text); values.removeIf(String::isEmpty); updateFields(); final Node next = fields.get(Math.min(i+1, fields.size()-1)); Platform.runLater(() -> next.requestFocus()); handler.accept(values); }
Example 6
Source File: EmailManager.java From Notebook with Apache License 2.0 | 5 votes |
public void send(boolean batchAll, TextArea taFrom, TextArea taTo, TextArea taContent, TextField txUrl) throws IOException{ String from = taFrom.getText(); String to = taTo.getText(); String html = taContent.getText(); String url = txUrl.getText(); if(from.isEmpty() || to.isEmpty() || html.isEmpty()){ System.out.println("input can't is empty!"); return; } List<String> emails = FileUtils.readLines(new File(Constants.EMAIL_TO), "UTF-8"); Gson gson = new Gson(); EmailFrom emailFrom = gson.fromJson(from, EmailFrom.class); System.err.println(emailFrom); System.err.println(emails); if(emailFrom.getAttachmentName().equals("xx.txt")){ emailFrom.setAttached(false); } else { emailFrom.setAttached(true); } if(batchAll){ sendBatch(emailFrom, emails, url, html); } else { for(String email : emails){ sendSingle(emailFrom, email, url, html); sleep(Constants.EMAIL_SEND_TIMEOUT); } } }
Example 7
Source File: PersonsController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
protected void doFilterTable(TextField tf) { String criteria = tf.getText(); if( logger.isLoggable(Level.FINE) ) { logger.fine( "[FILTER] filtering on=" + criteria ); } if( criteria == null || criteria.isEmpty() ) { tblPersons.setItems( personsActiveRecord ); return; } FilteredList<Person> fl = new FilteredList<>(personsActiveRecord, p -> true); fl.setPredicate(person -> { if (criteria == null || criteria.isEmpty()) { return true; } String lcCriteria = criteria.toLowerCase(); if (person.getFirstName().toLowerCase().contains(lcCriteria)) { return true; // Filter matches first name. } else if (person.getLastName().toLowerCase().contains(lcCriteria)) { return true; // Filter matches last name. } else if (person.getEmail().toLowerCase().contains(lcCriteria)) { return true; // matches email } return false; // Does not match. }); SortedList<Person> sortedData = new SortedList<>(fl); sortedData.comparatorProperty().bind(tblPersons.comparatorProperty()); // ? tblPersons.setItems(sortedData); }
Example 8
Source File: Browser.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private EventHandler<ActionEvent> buttonAction(final TextField textField, //final ProgressBar progressBar, final WebEngine webEngine, final WebView webView) { return new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (textField.getText() != null) { loadPage(textField, //progressBar, webEngine, webView); } } }; }
Example 9
Source File: DritarjaKryesore.java From Automekanik with GNU General Public License v3.0 | 5 votes |
public void filtroFinancat(TextField puna) { try { String sql; if (!puna.getText().isEmpty()) sql = "select * from Punet where lower(lloji) like lower('%" + puna.getText() + "%') or lower(konsumatori) like lower('%" + puna.getText() + "%'" + ") order by data desc"; else sql = "select * from Punet order by data desc"; Connection conn = DriverManager.getConnection(CON_STR, "test", "test"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); ObservableList<TabelaPunet> data = FXCollections.observableArrayList(); Format format = new SimpleDateFormat("dd/MM/yyyy"); while (rs.next()) { String d = format.format(rs.getDate("data")); data.add(new TabelaPunet(rs.getInt("id"), rs.getString("lloji").toUpperCase(), d, rs.getFloat("qmimi"), rs.getString("konsumatori").toUpperCase(), rs.getString("pershkrimi"), rs.getString("kryer"), rs.getString("makina").toUpperCase())); } tblPunet.getItems().clear(); tblPunet.setItems(data); stmt.close(); rs.close(); conn.close(); } catch (Exception ex) { ex.printStackTrace(); } }
Example 10
Source File: HelloWorld.java From Learn-Java-12-Programming with MIT License | 5 votes |
private void action(TextField tfFirstName, TextField tfLastName, TextField tfAge ) { String fn = tfFirstName.getText(); String ln = tfLastName.getText(); String age = tfAge.getText(); int a = 42; try { a = Integer.parseInt(age); } catch (Exception ex){} fn = fn.isBlank() ? "Nick" : fn; ln = ln.isBlank() ? "Samoylov" : ln; System.out.println("\nHello, " + fn + " " + ln + ", age " + a + "!"); Platform.exit(); }
Example 11
Source File: Mask.java From DashboardFx with GNU General Public License v3.0 | 5 votes |
public static void noSymbols(final TextField field, String exceptions) { ChangeListener listener = (ChangeListener<Number>) (observable, oldValue, newValue) -> { if (field.getText() != null) { if (field.getText().length() > 0) { String value = field.getText(); value = value.replaceAll("[^a-zA-Z0-9 " + exceptions + "]", ""); field.setText(value); } } }; field.lengthProperty().addListener(listener); }
Example 12
Source File: Mask.java From DashboardFx with GNU General Public License v3.0 | 5 votes |
public static void noSymbols(final TextField field) { ChangeListener listener = (ChangeListener<Number>) (observable, oldValue, newValue) -> { if (field.getText() != null) { if (field.getText().length() > 0) { String value = field.getText(); value = value.replaceAll("[^a-zA-Z0-9 ]", ""); field.setText(value); } } }; field.lengthProperty().addListener(listener); }
Example 13
Source File: BasicSongPanel.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Get the given key of the song (or as best we can work out if it's not * specified) transposed by the given number of semitones. * <p/> * * @param semitones the number of semitones to transpose the key. * @return the key, transposed. */ private String getKey(int semitones) { TextField keyField = QueleaApp.get().getMainWindow().getSongEntryWindow().getDetailedSongPanel().getKeyField(); String key = keyField.getText(); if (key == null || key.isEmpty()) { for (String line : getLyricsField().getTextArea().getText().split("\n")) { if (new LineTypeChecker(line).getLineType() == LineTypeChecker.Type.CHORDS) { String first; int i = 0; do { first = line.split("\\s+")[i++]; } while (first.isEmpty()); key = new ChordTransposer(first).transpose(semitones, null); if (key.length() > 2) { key = key.substring(0, 2); } if (key.length() == 2) { if (key.charAt(1) == 'B') { key = Character.toString(key.charAt(0)) + "b"; } else if (key.charAt(1) != 'b' && key.charAt(1) != '#') { key = Character.toString(key.charAt(0)); } } break; } } } if (key == null || key.isEmpty()) { key = null; } return key; }
Example 14
Source File: EpochService.java From dev-tools with Apache License 2.0 | 5 votes |
public static int validate(TextField f, int min, int max) { int intVal; try { intVal = Integer.parseInt(f.getText()); if (intVal < min || intVal > max) { throw new InvalidParameterException("Invalid input: " + f.getText()); } } catch (Exception e) { f.setBorder(Elements.alertBorder); throw e; } return intVal; }
Example 15
Source File: TextUtils.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
/** * 检查文本框是否为空 * * @param primaryStage toast 的 stage * @param textField 要检查的文本框 * @return true 为空; false 非空 */ private static boolean checkTextIsEmpty(Stage primaryStage, TextField textField) { String text = textField.getText(); if (StringUtils.isEmpty(text)) { Toast.makeText(primaryStage, textField.getPromptText() + "不能为空", 3000, 500, 500, 15, 5); return true; } else { return false; } }
Example 16
Source File: TemplateListDialog.java From constellation with Apache License 2.0 | 4 votes |
String getName(final Object owner, final File delimIoDir) { final String[] templateLabels = getFileLabels(delimIoDir); final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION); final TextField label = new TextField(); label.setPromptText("Template label"); final ObservableList<String> q = FXCollections.observableArrayList(templateLabels); final ListView<String> nameList = new ListView<>(q); nameList.setEditable(false); nameList.setOnMouseClicked(event -> { label.setText(nameList.getSelectionModel().getSelectedItem()); if (event.getClickCount() > 1) { dialog.setResult(ButtonType.OK); } }); final HBox prompt = new HBox(new Label("Name: "), label); prompt.setPadding(new Insets(10, 0, 0, 0)); final VBox vbox = new VBox(nameList, prompt); dialog.setResizable(false); dialog.setTitle("Import template names"); dialog.setHeaderText(String.format("Select an import template to %s.", isLoading ? "load" : "save")); dialog.getDialogPane().setContent(vbox); final Optional<ButtonType> option = dialog.showAndWait(); if (option.isPresent() && option.get() == ButtonType.OK) { final String name = label.getText(); final File f = new File(delimIoDir, FilenameEncoder.encode(name + ".json")); boolean go = true; if (!isLoading && f.exists()) { final String msg = String.format("'%s' already exists. Do you want to overwrite it?", name); final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setHeaderText("Import template exists"); alert.setContentText(msg); final Optional<ButtonType> confirm = alert.showAndWait(); go = confirm.isPresent() && confirm.get() == ButtonType.OK; } if (go) { return name; } } return null; }
Example 17
Source File: StringParameter.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
@Override public void setValueFromComponent(TextField component) { value = component.getText(); }