Java Code Examples for javafx.scene.control.TextArea

The following examples show how to use javafx.scene.control.TextArea. These examples are extracted from open source projects. 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 Project: Library-Assistant   Author: afsalashyana   File: AlertMaker.java    License: Apache License 2.0 6 votes vote down vote up
public static void showErrorMessage(Exception ex, String title, String content) {
    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle("Error occured");
    alert.setHeaderText(title);
    alert.setContentText(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ex.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
}
 
Example #2
Source Project: milkman   Author: warmuuh   File: ImportControl.java    License: MIT License 6 votes vote down vote up
public ImportControl(boolean allowFile) {
	fileChooser = new FileChooser();
	rawContent = new TextArea();
	selectedFile = new TextField();
	
	Button openFileSelectionBtn = new Button("Select...");
	openFileSelectionBtn.setOnAction(e -> {
		File f = fileChooser.showOpenDialog(FxmlUtil.getPrimaryStage());
		if (f != null && f.exists() && f.isFile()) {
			selectedFile.setText(f.getPath());
		}
	});
	
	HBox.setHgrow(selectedFile, Priority.ALWAYS);
	HBox selectionCtrl = new HBox(selectedFile, openFileSelectionBtn);
	selectionCtrl.setPadding(new Insets(10));
	if (allowFile){
		getTabs().add(new Tab("File", selectionCtrl));
	}
	getTabs().add(new Tab("Raw", rawContent));
	VBox.setVgrow(this, Priority.ALWAYS);
}
 
Example #3
Source Project: milkman   Author: warmuuh   File: PostmanCollectionExporter.java    License: MIT License 6 votes vote down vote up
@Override
public Node getRoot(Collection request, Templater templater) {
	PostmanExporterV21 exporter = new PostmanExporterV21();
	String exportedData = exporter.export(request);
	RetentionFileChooser.getInstance().setInitialFileName(request.getName() + ".postman_collection.json");

	textArea = new TextArea(exportedData);
	Button saveBtn = new Button("save as...");
	saveBtn.setOnAction(e -> {
		File f = RetentionFileChooser.showSaveDialog(FxmlUtil.getPrimaryStage());
		if (f != null && !f.isDirectory()) {
			saveExportAsFile(textArea.getText(), f);
		}
	});
	return new VBox(textArea, saveBtn);
}
 
Example #4
Source Project: ReactFX   Author: TomasMikula   File: DeferredHtmlRendering.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    TextArea textArea = new TextArea();
    WebView webView = new WebView();
    WebEngine engine = webView.getEngine();

    EventStreams.valuesOf(textArea.textProperty())
            .successionEnds(Duration.ofMillis(500))
            .subscribe(html -> engine.loadContent(html));

    SplitPane root = new SplitPane();
    root.getItems().addAll(textArea, webView);
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #5
Source Project: helloiot   Author: adrianromero   File: LogView.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node constructContent() {
    StackPane stackpaneroot = new StackPane();
    stackpaneroot.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    
    BorderPane borderpane = new BorderPane();
    
    statusview = new TextArea();
    statusview.setEditable(false);
    statusview.setFocusTraversable(false);
    statusview.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    statusview.setPrefHeight(100.0);
    statusview.getStyleClass().addAll("unitinputview", "unitinputcode");
    BorderPane.setAlignment(statusview, Pos.CENTER);
    
    borderpane.setCenter(statusview);
    
    stackpaneroot.getChildren().add(borderpane);
    
    initialize();
    return stackpaneroot;
}
 
Example #6
Source Project: paintera   Author: saalfeldlab   File: PainteraAlerts.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Deprecated
public static Alert askConvertDeprecatedStates(
		final BooleanProperty rememberChoiceProperty,
		final Class<?> deprecatedStateType,
		final Class<?> convertedStateType,
		final Object datasetDescriptor) {
	final Alert alert = PainteraAlerts.confirmation("_Update", "_Skip", true);
	final TextArea message = new TextArea(String.format("" +
					"Dataset `%s' was opened in a deprecated format (%s). " +
					"Paintera can try to convert and update the dataset into a new format (%s) that supports relative data locations. " +
					"The new format is incompatible with Paintera versions 0.21.0 and older but updating datasets is recommended. " +
					"Backup files are generated for the Paintera files as well as for any dataset attributes that may have been modified " +
					"during the process.",
			datasetDescriptor,
			deprecatedStateType.getSimpleName(),
			convertedStateType.getSimpleName()));
	message.setWrapText(true);
	final CheckBox rememberChoice = new CheckBox("_Remember choice for all datasets in project");
	rememberChoice.selectedProperty().bindBidirectional(rememberChoiceProperty);
	alert.setHeaderText("Update deprecated data set");
	alert.getDialogPane().setContent(new VBox(message, rememberChoice));
	return alert;
}
 
Example #7
Source Project: helloiot   Author: adrianromero   File: EditAreaEvent.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node constructContent() {
    HBox hboxroot = new HBox();
    hboxroot.setSpacing(6.0);
    
    payload = new TextArea();
    payload.getStyleClass().add("unitinputarea");
    payload.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    payload.setPrefHeight(100.0);
    HBox.setHgrow(payload, Priority.SOMETIMES);

    
    fireaction = new Button();
    fireaction.setFocusTraversable(false);
    fireaction.setMnemonicParsing(false);
    fireaction.getStyleClass().add("unitbutton");
    fireaction.setOnAction(this::onSendEvent);
    
    hboxroot.getChildren().addAll(payload, fireaction);
    
    initialize();
    return hboxroot;    
}
 
Example #8
Source Project: bisq   Author: bisq-network   File: FormBuilder.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, TextArea> addConfirmationLabelTextArea(GridPane gridPane,
                                                                   int rowIndex,
                                                                   String title1,
                                                                   String title2,
                                                                   double top) {
    Label label = addLabel(gridPane, rowIndex, title1);
    label.getStyleClass().add("confirmation-label");

    TextArea textArea = addTextArea(gridPane, rowIndex, title2);
    ((JFXTextArea) textArea).setLabelFloat(false);

    GridPane.setColumnIndex(textArea, 1);
    GridPane.setMargin(label, new Insets(top, 0, 0, 0));
    GridPane.setHalignment(label, HPos.LEFT);
    GridPane.setMargin(textArea, new Insets(top, 0, 0, 0));

    return new Tuple2<>(label, textArea);
}
 
Example #9
Source Project: bisq   Author: bisq-network   File: F2FForm.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void addFormForDisplayAccount() {
    gridRowFrom = gridRow;

    addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"),
            paymentAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
            Res.get(paymentAccount.getPaymentMethod().getId()));
    addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.country"),
            getCountryBasedPaymentAccount().getCountry() != null ? getCountryBasedPaymentAccount().getCountry().name : "");
    TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
    String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
    addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
    addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.f2f.contact", f2fAccount.getContact()),
            f2fAccount.getContact());
    addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.f2f.city", f2fAccount.getCity()),
            f2fAccount.getCity());
    TextArea textArea = addCompactTopLabelTextArea(gridPane, ++gridRow, Res.get("payment.f2f.extra"), "").second;
    textArea.setText(f2fAccount.getExtraInfo());
    textArea.setPrefHeight(60);
    textArea.setEditable(false);

    addLimitations(true);
}
 
Example #10
Source Project: bisq   Author: bisq-network   File: ShowWalletDataWindow.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private void addContent() {
    gridPane.getColumnConstraints().get(0).setHalignment(HPos.LEFT);
    gridPane.getColumnConstraints().get(0).setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().get(1).setHgrow(Priority.SOMETIMES);

    Tuple2<Label, TextArea> labelTextAreaTuple2 = addTopLabelTextArea(gridPane, ++rowIndex,
            Res.get("showWalletDataWindow.walletData"), "");
    TextArea textArea = labelTextAreaTuple2.second;
    Label label = labelTextAreaTuple2.first;
    label.setMinWidth(150);
    textArea.setPrefHeight(500);
    textArea.getStyleClass().add("small-text");
    CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex,
            Res.get("showWalletDataWindow.includePrivKeys"));
    isUpdateCheckBox.setSelected(false);

    isUpdateCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
        showWallet(textArea, isUpdateCheckBox);
    });

    showWallet(textArea, isUpdateCheckBox);

    actionButtonText(Res.get("shared.copyToClipboard"));
    onAction(() -> Utilities.copyToClipboard(textArea.getText()));
}
 
Example #11
Source Project: marathonv5   Author: jalian-systems   File: RFXTextAreaTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void getText() {
    final TextArea textArea = (TextArea) getPrimaryStage().getScene().getRoot().lookup(".text-area");
    LoggingRecorder lr = new LoggingRecorder();
    List<Object> text = new ArrayList<>();
    Platform.runLater(() -> {
        RFXComponent rTextField = new RFXTextInputControl(textArea, null, null, lr);
        textArea.setText("Hello World");
        rTextField.focusLost(null);
        text.add(rTextField.getAttribute("text"));
    });
    new Wait("Waiting for text area text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Hello World", text.get(0));
}
 
Example #12
Source Project: marathonv5   Author: jalian-systems   File: RFXTextAreaTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void selectWithSpecialChars() throws InterruptedException {
    final TextArea textArea = (TextArea) getPrimaryStage().getScene().getRoot().lookup(".text-area");
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            textArea.setText("Hello\n World'\"");
        }
    });
    LoggingRecorder lr = new LoggingRecorder();
    RFXComponent rTextField = new RFXTextInputControl(textArea, 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("Hello\n World'\"", select.getParameters()[0]);
}
 
Example #13
Source Project: marathonv5   Author: jalian-systems   File: RFXTextAreaTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void selectWithUtf8Chars() throws InterruptedException {
    final TextArea textArea = (TextArea) getPrimaryStage().getScene().getRoot().lookup(".text-area");
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            textArea.setText("å∫ç∂´ƒ©˙ˆ∆");
        }
    });
    LoggingRecorder lr = new LoggingRecorder();
    RFXComponent rTextField = new RFXTextInputControl(textArea, 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 #14
Source Project: markdown-writer-fx   Author: JFormDesigner   File: StylesheetsOptionsPane.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void initComponents() {
	// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
	Label additionalCSSLabel = new Label();
	additionalCSSField = new TextArea();

	//======== this ========
	setLayout("hidemode 3");
	setCols(
		"[fill]");
	setRows(
		"[]" +
		"[grow,fill]");

	//---- additionalCSSLabel ----
	additionalCSSLabel.setText(Messages.get("StylesheetsOptionsPane.additionalCSSLabel.text"));
	add(additionalCSSLabel, "cell 0 0");
	add(additionalCSSField, "cell 0 1");
	// JFormDesigner - End of component initialization  //GEN-END:initComponents
}
 
Example #15
Source Project: phoebus   Author: ControlSystemStudio   File: MultiLineInputDialog.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/** @param parent Parent node, dialog will be positioned relative to it
 *  @param initial_text Initial text
 *  @param editable Allow editing?
 *  */
public MultiLineInputDialog(final Node parent, final String initial_text, final boolean editable)
{
    text = new TextArea(initial_text);
    text.setEditable(editable);

    getDialogPane().setContent(new BorderPane(text));
    if (editable)
        getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    else
        getDialogPane().getButtonTypes().addAll(ButtonType.OK);
    setResizable(true);

    setResultConverter(button ->
    {
        return button == ButtonType.OK ? text.getText() : null;
    });

    DialogHelper.positionAndSize(this, parent,
                                 PhoebusPreferenceService.userNodeForClass(MultiLineInputDialog.class),
                                 600, 300);
}
 
Example #16
Source Project: jmonkeybuilder   Author: JavaSaBr   File: TextFileEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
public void openFile(@NotNull final Path file) {
    super.openFile(file);

    setOriginalContent(FileUtils.read(file));

    /* TODO added to handle some exceptions
    try {

    } catch (final MalformedInputException e) {
        throw new RuntimeException("This file isn't a text file.", e);
    } */

    final TextArea textArea = getTextArea();
    textArea.setText(getOriginalContent());
}
 
Example #17
Source Project: jmonkeybuilder   Author: JavaSaBr   File: TextFilePreview.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void initialize(@NotNull final TextArea node, @NotNull final StackPane pane) {
    super.initialize(node, pane);

    node.prefWidthProperty().bind(pane.widthProperty().subtract(2));
    node.prefHeightProperty().bind(pane.heightProperty().subtract(2));

    FXUtils.addClassTo(node, CssClasses.TRANSPARENT_TEXT_AREA);
}
 
Example #18
Source Project: mzmine3   Author: mzmine   File: FileNamesComponent.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 #19
Source Project: JavaFX   Author: dmpe   File: Main.java    License: MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws MalformedURLException,
		IOException {

	// icon
	Image icon = new Image("resources/icon.png");
	Parent root = FXMLLoader.load(getClass().getResource("UI.fxml"));

	TextArea textArea1;
	ListView list1;


	Methods cl = new Methods();
	String sit = "http://www.google.com/";
	// int ado = cl.getResponseCode(sit);
	String bobob = cl.getImp(cl.getResponseCode(sit)); // then ado

	Text t = new Text(10, 20, bobob);
	Group ab = new Group(root);

	Scene sc = new Scene(root, 600, 330);

	primaryStage.setScene(sc);
	primaryStage.setTitle("Maly Test");
	primaryStage.getIcons().add(icon);
	primaryStage.setResizable(true);
	primaryStage.centerOnScreen();
	primaryStage.show();

}
 
Example #20
Source Project: milkman   Author: warmuuh   File: VariableHighlighter.java    License: MIT License 5 votes vote down vote up
private JFXPopup showVariablePopup(TextBoundingBox boundingBox, VariableData varData) {
    var vBox = new VboxExt();
    vBox.setSpacing(10);
    vBox.setPadding(new Insets(10));

    String title = varData.isNewVariable() ? "New Variable"
            : varData.isWriteable() ? "Modify Variable"
            : "View Variable";



    vBox.add(label(title)).getStyleClass().add("popup-title");
    vBox.add(hbox(label("Name"), label(varData.getName()))).setSpacing(20);
    if (varData.isWriteable()){
        vBox.add(hbox(label("Environment"), label(varData.getEnvironmentName()))).setSpacing(20);
    }
    vBox.add(label("Value"));

    var replTxt = vBox.add(new TextArea(varData.getValue()));
    replTxt.setMaxHeight(50);
    replTxt.setEditable(varData.isWriteable());

    popup = new JFXPopup(vBox);

    if (varData.isWriteable()){
        String btnText = varData.isNewVariable() ? "Create Variable" : "Modify Variable";
        var btn = vBox.add(new HboxExt().add(submit(() -> {
            varData.writeNewValue(replTxt.getText());
            popup.hide();
        }, btnText)));
        btn.getStyleClass().add("primary-button");
    }



    popup.show(this.parent, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT);
    return popup;
}
 
Example #21
Source Project: milkman   Author: warmuuh   File: ExceptionDialog.java    License: MIT License 5 votes vote down vote up
public ExceptionDialog(Throwable ex) {
	super(AlertType.ERROR);
	setTitle("Exception");
	setHeaderText("Exception during startup of application");
	setContentText(ex.getClass().getName() + ": " + ex.getMessage());


	// Create expandable Exception.
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);
	ex.printStackTrace(pw);
	String exceptionText = sw.toString();

	Label label = new Label("The exception stacktrace was:");

	TextArea textArea = new TextArea(exceptionText);
	textArea.setEditable(false);
	textArea.setWrapText(true);

	textArea.setMaxWidth(Double.MAX_VALUE);
	textArea.setMaxHeight(Double.MAX_VALUE);
	GridPane.setVgrow(textArea, Priority.ALWAYS);
	GridPane.setHgrow(textArea, Priority.ALWAYS);

	GridPane expContent = new GridPane();
	expContent.setMaxWidth(Double.MAX_VALUE);
	expContent.add(label, 0, 0);
	expContent.add(textArea, 0, 1);

	// Set expandable Exception into the dialog pane.
	getDialogPane().setExpandableContent(expContent);
}
 
Example #22
Source Project: milkman   Author: warmuuh   File: NotesAspectEditor.java    License: MIT License 5 votes vote down vote up
@Override
public Tab getRoot(RequestContainer request) {
	NotesAspect notes = request.getAspect(NotesAspect.class).get();
	Tab tab = new Tab("Notes");
	TextArea textArea = new TextArea();
	GenericBinding<NotesAspect, String> binding = GenericBinding.of(
			NotesAspect::getNote, 
			run(NotesAspect::setNote)
				.andThen(() -> notes.setDirty(true)), //mark aspect as dirty propagates to the request itself and shows up in UI
			notes); 
	textArea.textProperty().bindBidirectional(binding);
	textArea.setUserData(binding); //need to add a strong reference to keep the binding from being GC-collected.
	tab.setContent(textArea);
	return tab;
}
 
Example #23
Source Project: game-of-life-java   Author: inoryy   File: PresetHandler.java    License: MIT License 5 votes vote down vote up
private VBox createPresetPage(int pageIndex, FlowPane base) {
    VBox box = new VBox(5);
    for (int i = pageIndex; i < pageIndex + 1; i++) {
        TextArea text = new TextArea(presets[i]);
        text.setWrapText(true);
        currentPreset = Character.toUpperCase(presets[i].charAt(0)) + presets[i].substring(1);
        Label l = new Label(currentPreset);

        HBox nameAndOpen = new HBox(5);
        nameAndOpen.getChildren().addAll(l);
        File f1 = new File("Presets/"+presets[i]+".png");
        if(f1.exists() && !f1.isDirectory()) { 
            Image myPreset = new Image("file:Presets/"+presets[i]+".png");
            ImageView myPresetView = new ImageView();
            myPresetView.setImage(myPreset);
            box.getChildren().add(myPresetView);
        } else {
            File f = new File("Presets/nopreview.png");
            if(f.exists() && !f.isDirectory()) { 
                Image noprevImg = new Image("file:Presets/nopreview.png"); //new Image("Presets/nopreview.png");
                ImageView noprev = new ImageView();
                noprev.setImage(noprevImg);
                box.getChildren().add(noprev);
            } else {
                System.out.println("nopreview.png not found");
            }
        }

        box.getChildren().add(nameAndOpen);
    }
    return box;
}
 
Example #24
Source Project: VocabHunter   Author: VocabHunter   File: ErrorDialogue.java    License: Apache License 2.0 5 votes vote down vote up
public ErrorDialogue(final I18nManager i18nManager, final I18nKey titleKey, final Throwable e, final String... messages) {
    alert = new Alert(AlertType.ERROR);
    alert.setTitle(i18nManager.text(titleKey));
    alert.setHeaderText(headerText(messages));

    TextArea textArea = new TextArea(exceptionText(e));
    VBox expContent = new VBox();
    DialogPane dialoguePane = alert.getDialogPane();

    expContent.getChildren().setAll(new Label(i18nManager.text(ERROR_DETAILS)), textArea);
    dialoguePane.setExpandableContent(expContent);
    dialoguePane.expandedProperty().addListener(p -> Platform.runLater(this::resizeAlert));
    dialoguePane.setId("errorDialogue");
}
 
Example #25
Source Project: standalone-app   Author: helios-decompiler   File: TextView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<byte[]> save(Node node) {
    if (!(node instanceof TextArea)) {
        return CompletableFuture.completedFuture(new byte[0]);
    }
    return CompletableFuture.completedFuture(((TextArea) node).getText().getBytes(StandardCharsets.UTF_8));
}
 
Example #26
Source Project: paintera   Author: saalfeldlab   File: PainteraAlerts.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a {@link LabelBlockLookup} that returns all contained blocks ("OK") or no blocks ("CANCEL")
 * @param source used to determine block sizes for marching cubes
 * @return {@link LabelBlockLookup} that returns all contained blocks ("OK") or no blocks ("CANCEL")
 */
public static LabelBlockLookup getLabelBlockLookupFromN5DataSource(
		final N5Reader reader,
		final String group,
		final DataSource<?, ?> source) {
	final Alert alert = PainteraAlerts.alert(Alert.AlertType.CONFIRMATION);
	alert.setHeaderText("Define label-to-block-lookup for on-the-fly mesh generation");
	final TextArea ta = new TextArea(String.format("Could not deserialize label-to-block-lookup for dataset `%s' in N5 container `%s' " +
			"that is required for on the fly mesh generation. " +
			"If you are not interested in 3D meshes, press cancel. Otherwise, press OK. Generating meshes on the fly will be slow " +
			"as the sparsity of objects can not be utilized.", group, reader));
	ta.setEditable(false);
	ta.setWrapText(true);
	alert.getDialogPane().setContent(ta);
	final Optional<ButtonType> bt = alert.showAndWait();
	if (bt.isPresent() && ButtonType.OK.equals(bt.get())) {
		final CellGrid[] grids = source.getGrids();
		long[][] dims = new long[grids.length][];
		int[][] blockSizes = new int[grids.length][];
		for (int i = 0; i < grids.length; ++i) {
			dims[i] = grids[i].getImgDimensions();
			blockSizes[i] = new int[grids[i].numDimensions()];
			grids[i].cellDimensions(blockSizes[i]);
		}
		LOG.debug("Returning block lookup returning all blocks.");
		return new LabelBlockLookupAllBlocks(dims, blockSizes);
	} else {
		return new LabelBlockLookupNoBlocks();
	}
}
 
Example #27
Source Project: DeskChan   Author: DeskChan   File: App.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
static void showThrowable(String sender, String className, String message, List<StackTraceElement> stacktrace) {
	if (!Main.getProperties().getBoolean("error-alerting", true)) return;

	Alert alert = new Alert(Alert.AlertType.ERROR);
	((Stage) alert.getDialogPane().getScene().getWindow()).getIcons().add(new Image(App.ICON_URL.toString()));

	alert.setTitle(Main.getString("error"));
	alert.initModality(Modality.WINDOW_MODAL);
	alert.setHeaderText(className + " " + Main.getString("caused-by") + " " + sender);
	alert.setContentText(message);
	StringBuilder exceptionText = new StringBuilder ();
	for (Object item : stacktrace)
		exceptionText.append((item != null ? item.toString() : "null") + "\n");

	TextArea textArea = new TextArea(exceptionText.toString());
	textArea.setEditable(false);
	textArea.setWrapText(true);
	textArea.setMaxWidth(Double.MAX_VALUE);
	textArea.setMaxHeight(Double.MAX_VALUE);

	CheckBox checkBox = new CheckBox(Main.getString("enable-error-alert"));
	checkBox.setSelected(Main.getProperties().getBoolean("error-alerting", true));
	checkBox.selectedProperty().addListener((obs, oldValue, newValue) -> {
		Main.getProperties().put("error-alerting", newValue);
	});

	BorderPane pane = new BorderPane();
	pane.setTop(checkBox);
	pane.setCenter(textArea);

	alert.getDialogPane().setExpandableContent(pane);
	alert.show();
}
 
Example #28
Source Project: MyBox   Author: Mararsh   File: ChromaticityDiagramController.java    License: Apache License 2.0 5 votes vote down vote up
public void exportAction(String filename, TextArea textArea) {
    final File file = chooseSaveFile(AppVariables.getUserConfigPath(targetPathKey),
            filename, CommonFxValues.TextExtensionFilter, true);
    if (file == null) {
        return;
    }
    recordFileWritten(file, targetPathKey, VisitHistory.FileType.Text, VisitHistory.FileType.Text);

    synchronized (this) {
        if (task != null) {
            return;
        }
        task = new SingletonTask<Void>() {

            @Override
            protected boolean handle() {
                return FileTools.writeFile(file, textArea.getText()) != null;
            }

            @Override
            protected void whenSucceeded() {
                view(file);
                popSuccessful();
            }

        };
        openHandlingStage(task, Modality.WINDOW_MODAL);
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.start();
    }
}
 
Example #29
Source Project: xframium-java   Author: xframium   File: CommandPane.java    License: GNU General Public License v3.0 5 votes vote down vote up
private Tab getTab (String name, TextArea textArea)
{
  Tab tab = new Tab ();
  tab.setText (name);
  tab.setContent (textArea);
  return tab;
}
 
Example #30
Source Project: xframium-java   Author: xframium   File: CommandPane.java    License: GNU General Public License v3.0 5 votes vote down vote up
private TextArea getTextArea ()
{
  TextArea textArea = new TextArea ();
  textArea.setEditable (false);
  textArea.setFont (Font.font ("Monospaced", 12));
  textArea.setPrefWidth (TEXT_WIDTH);
  return textArea;
}