Java Code Examples for javafx.scene.control.TextArea#setPrefRowCount()
The following examples show how to use
javafx.scene.control.TextArea#setPrefRowCount() .
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: CheckListFormNode.java From marathonv5 with Apache License 2.0 | 8 votes |
private VBox createDescriptionField() { VBox descriptionFieldBox = new VBox(); TextArea descriptionArea = new TextArea(); descriptionArea.setPrefRowCount(4); descriptionArea.textProperty().addListener((observable, oldValue, newValue) -> { fireContentChanged(); checkList.setDescription(descriptionArea.getText()); }); descriptionArea.setEditable(mode.isSelectable()); descriptionFieldBox.getChildren().addAll(new Label("Description"), descriptionArea); HBox.setHgrow(descriptionArea, Priority.ALWAYS); VBox.setMargin(descriptionFieldBox, new Insets(5, 10, 5, 5)); descriptionArea.setText(checkList.getDescription()); HBox.setHgrow(descriptionArea, Priority.ALWAYS); HBox.setHgrow(descriptionFieldBox, Priority.ALWAYS); return descriptionFieldBox; }
Example 2
Source File: CommentBoxVBoxer.java From marathonv5 with Apache License 2.0 | 6 votes |
private Node createTextArea(boolean selectable, boolean editable) { textArea = new TextArea(); textArea.setPrefRowCount(4); textArea.setEditable(editable); textArea.textProperty().addListener((observable, oldValue, newValue) -> { item.setText(textArea.getText()); }); textArea.setText(item.getText()); ScrollPane scrollPane = new ScrollPane(textArea); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER); scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS); HBox.setHgrow(scrollPane, Priority.ALWAYS); return scrollPane; }
Example 3
Source File: TomlEntryEditor.java From Lipi with MIT License | 6 votes |
private void initValueTextControl(String value) { if (value.length() > 30) { TextArea valueTextArea = new TextArea(value); valueTextArea.setPrefColumnCount(16); int cols = value.length() / 30; valueTextArea.setPrefRowCount(cols); // valueTextArea.prefHeight(20); valueTextArea.setWrapText(true); valueTextControl = valueTextArea; } else { TextField valueTextField = new TextField(value); valueTextField.setPrefColumnCount(18); valueTextControl = valueTextField; } }
Example 4
Source File: FileNamesComponent.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public FileNamesComponent(List<ExtensionFilter> filters) { this.filters = ImmutableList.copyOf(filters); // setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0)); txtFilename = new TextArea(); txtFilename.setPrefColumnCount(40); txtFilename.setPrefRowCount(6); txtFilename.setFont(smallFont); Button btnFileBrowser = new Button("..."); btnFileBrowser.setOnAction(e -> { // Create chooser. FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select files"); fileChooser.getExtensionFilters().addAll(this.filters); String currentPaths[] = txtFilename.getText().split("\n"); if (currentPaths.length > 0) { File currentFile = new File(currentPaths[0].trim()); File currentDir = currentFile.getParentFile(); if (currentDir != null && currentDir.exists()) fileChooser.setInitialDirectory(currentDir); } // Open chooser. List<File> selectedFiles = fileChooser.showOpenMultipleDialog(null); if (selectedFiles == null) return; setValue(selectedFiles.toArray(new File[0])); }); getChildren().addAll(txtFilename, btnFileBrowser); }
Example 5
Source File: BrowserTab.java From marathonv5 with Apache License 2.0 | 5 votes |
public void addArguments() { arguments = new TextArea(); arguments.setPrefRowCount(3); arguments.setText(BrowserConfig.instance().getValue(getBrowserName(), "browser-arguments", "")); Label prompt = new Label("One argument per line."); basicPane.addFormField("Browser Arguments:", prompt, 2, 3); basicPane.addFormField("", arguments); }
Example 6
Source File: BrowserTab.java From marathonv5 with Apache License 2.0 | 5 votes |
public void addWdArguments() { wdArguments = new TextArea(); wdArguments.setPrefRowCount(3); wdArguments.setText(BrowserConfig.instance().getValue(getBrowserName(), "webdriver-arguments", "")); Label prompt = new Label("One argument per line."); basicPane.addFormField("WebDriver Arguments:", prompt, 2, 3); basicPane.addFormField("", wdArguments); }
Example 7
Source File: BrowserTab.java From marathonv5 with Apache License 2.0 | 5 votes |
public void addEnvironment() { environment = new TextArea(); environment.setText(BrowserConfig.instance().getValue(getBrowserName(), "browser-environment", "")); environment.setPrefRowCount(3); Label prompt = new Label("One variable per line. Eg:\nTMP=/temp-browser\n"); advancedPane.addFormField("Environment Variables:", prompt, 2, 1); advancedPane.addFormField("", environment); }
Example 8
Source File: ImagePanel.java From marathonv5 with Apache License 2.0 | 4 votes |
private static TextArea createTextArea(TableCell<Annotation, String> cell) { TextArea textArea = new TextArea(cell.getItem() == null ? "" : cell.getItem()); textArea.setPrefRowCount(1); textArea.setWrapText(true); textArea.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) { if (!textArea.isFocused() && cell.getItem() != null && cell.isEditing()) { cell.commitEdit(textArea.getText()); } cell.getTableView().getItems().get(cell.getIndex()).setText(textArea.getText()); } }); textArea.addEventFilter(MouseEvent.MOUSE_CLICKED, (event) -> { if (event.getClickCount() > 1) { cell.getTableView().edit(cell.getTableRow().getIndex(), cell.getTableColumn()); } else { TableViewSelectionModel<Annotation> selectionModel = cell.getTableView().getSelectionModel(); if (event.isControlDown()) { if (selectionModel.isSelected(cell.getIndex())) { selectionModel.clearSelection(cell.getIndex()); } else { selectionModel.select(cell.getIndex()); } } else { selectionModel.clearAndSelect(cell.getIndex()); } } }); textArea.addEventFilter(KeyEvent.KEY_PRESSED, (event) -> { if (event.getCode() == KeyCode.ENTER && event.isShiftDown() && cell.isEditing()) { cell.commitEdit(textArea.getText()); cell.getTableView().getItems().get(cell.getIndex()).setText(textArea.getText()); event.consume(); } if (event.getCode() == KeyCode.F2) { cell.getTableView().edit(cell.getTableRow().getIndex(), cell.getTableColumn()); } }); return textArea; }
Example 9
Source File: PropertySheet.java From JetUML with GNU General Public License v3.0 | 4 votes |
private Control createExtendedStringEditor(Property pProperty) { final int rows = 5; final int columns = 30; final TextArea textArea = new TextArea(); textArea.setPrefRowCount(rows); textArea.setPrefColumnCount(columns); textArea.addEventFilter(KeyEvent.KEY_PRESSED, pKeyEvent -> { final String aFocusEventText = "TAB_TO_FOCUS_EVENT"; if (!KeyCode.TAB.equals(pKeyEvent.getCode())) { return; } if (pKeyEvent.isAltDown() || pKeyEvent.isMetaDown() || pKeyEvent.isShiftDown() || !(pKeyEvent.getSource() instanceof TextArea)) { return; } final TextArea textAreaSource = (TextArea) pKeyEvent.getSource(); if (pKeyEvent.isControlDown()) { if (!aFocusEventText.equalsIgnoreCase(pKeyEvent.getText())) { pKeyEvent.consume(); textAreaSource.replaceSelection("\t"); } } else { pKeyEvent.consume(); final KeyEvent tabControlEvent = new KeyEvent(pKeyEvent.getSource(), pKeyEvent.getTarget(), pKeyEvent.getEventType(), pKeyEvent.getCharacter(), aFocusEventText, pKeyEvent.getCode(), pKeyEvent.isShiftDown(), true, pKeyEvent.isAltDown(), pKeyEvent.isMetaDown()); textAreaSource.fireEvent(tabControlEvent); } }); textArea.setText((String) pProperty.get()); textArea.textProperty().addListener((pObservable, pOldValue, pNewValue) -> { pProperty.set(textArea.getText()); aListener.propertyChanged(); }); return new ScrollPane(textArea); }
Example 10
Source File: ShortcutEditingPanelSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 4 votes |
/** * Updates the shortcutProperties of the shortcut in the given {@link GridPane propertiesGrid} * * @param propertiesGrid The shortcutProperties grid */ private void updateProperties(final GridPane propertiesGrid) { propertiesGrid.getChildren().clear(); // add miniature final Label miniatureLabel = new Label(tr("Miniature:")); miniatureLabel.getStyleClass().add("captionTitle"); GridPane.setValignment(miniatureLabel, VPos.TOP); final TextField miniaturePathField = new TextField(Optional.ofNullable(getControl().getShortcut()) .map(ShortcutDTO::getMiniature).map(URI::getPath).orElse("")); HBox.setHgrow(miniaturePathField, Priority.ALWAYS); final Button openBrowser = new Button(tr("Browse...")); openBrowser.setOnAction(event -> { final URI miniatureURI = Optional.ofNullable(getControl().getShortcut()).map(ShortcutDTO::getMiniature) .orElseThrow(() -> new IllegalStateException("The shortcut is null")); final FileChooser chooser = new FileChooser(); chooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(tr("Images"), "*.miniature, *.png")); final File defaultFile = new File(miniatureURI); chooser.setInitialDirectory(defaultFile.getParentFile()); Optional.ofNullable(chooser.showOpenDialog(getControl().getScene().getWindow())).ifPresent(newMiniature -> { miniaturePathField.setText(newMiniature.toString()); getControl().setShortcut(new ShortcutDTO.Builder(getControl().getShortcut()) .withMiniature(newMiniature.toURI()).build()); }); }); final HBox miniatureContainer = new HBox(miniaturePathField, openBrowser); propertiesGrid.addRow(0, miniatureLabel, miniatureContainer); for (Map.Entry<String, Object> entry : shortcutProperties.entrySet()) { final int row = propertiesGrid.getRowCount(); if (!"environment".equals(entry.getKey())) { final Label keyLabel = new Label(tr(decamelize(entry.getKey())) + ":"); keyLabel.getStyleClass().add("captionTitle"); GridPane.setValignment(keyLabel, VPos.TOP); final TextArea valueLabel = new TextArea(entry.getValue().toString()); valueLabel.setWrapText(true); valueLabel.setPrefRowCount(entry.getValue().toString().length() / 25); valueLabel.focusedProperty().addListener((observable, oldValue, newValue) -> { // update shortcut if TextArea looses focus (doesn't save yet) if (!newValue) { shortcutProperties.replace(entry.getKey(), valueLabel.getText()); try { final ShortcutDTO shortcut = getControl().getShortcut(); final String json = new ObjectMapper().writeValueAsString(shortcutProperties); getControl().setShortcut(new ShortcutDTO.Builder(shortcut) .withScript(json).build()); } catch (JsonProcessingException e) { LOGGER.error("Creating new shortcut String failed.", e); } } }); propertiesGrid.addRow(row, keyLabel, valueLabel); } } // set the environment this.environmentAttributes.clear(); if (shortcutProperties.containsKey("environment")) { final Map<String, String> environment = (Map<String, String>) shortcutProperties.get("environment"); this.environmentAttributes.putAll(environment); } }