javafx.scene.control.TextArea Java Examples

The following examples show how to use javafx.scene.control.TextArea. 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: AlertMaker.java    From Library-Assistant with Apache License 2.0 7 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 File: StylesheetsOptionsPane.java    From markdown-writer-fx with 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 #3
Source File: DeferredHtmlRendering.java    From ReactFX with 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 #4
Source File: LogView.java    From helloiot with 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 #5
Source File: ShowWalletDataWindow.java    From bisq with 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 #6
Source File: PostmanCollectionExporter.java    From milkman with 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 #7
Source File: ImportControl.java    From milkman with 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 #8
Source File: FormBuilder.java    From bisq with 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 File: MultiLineInputDialog.java    From phoebus with 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 #10
Source File: EditAreaEvent.java    From helloiot with 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 #11
Source File: RFXTextAreaTest.java    From marathonv5 with 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 #12
Source File: PainteraAlerts.java    From paintera with 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 #13
Source File: TextFileEditor.java    From jmonkeybuilder with 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 #14
Source File: F2FForm.java    From bisq with 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 #15
Source File: RFXTextAreaTest.java    From marathonv5 with 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 #16
Source File: RFXTextAreaTest.java    From marathonv5 with 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 #17
Source File: ExceptionHandler.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
/**
 Returns a TextArea with the Throwable's stack trace printed inside it

 @param thread thread where the Throwable occurred
 @param t throwable
 @return TextArea
 */
@NotNull
public static TextArea getExceptionTextArea(Thread thread, Throwable t) {
	String err = getExceptionString(t);
	TextArea ta = new TextArea();
	ta.setPrefSize(700, 700);
	ta.setText(err + "\nTHREAD:" + thread.getName());
	ta.setEditable(false);
	return ta;
}
 
Example #18
Source File: SimpleWebServer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Simple Web Server");
    BorderPane root = new BorderPane();
    TextArea area = new TextArea();
    root.setCenter(area);
    ToolBar bar = new ToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    openInBrowser.setOnAction((event) -> {
        try {
            Desktop.getDesktop().browse(URI.create(webRoot));
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true);
    changeRoot.setOnAction((event) -> {
        DirectoryChooser chooser = new DirectoryChooser();
        File showDialog = chooser.showDialog(primaryStage);
        if (showDialog != null)
            server.setRoot(showDialog);
    });
    bar.getItems().add(openInBrowser);
    bar.getItems().add(changeRoot);
    root.setTop(bar);
    System.setOut(new PrintStream(new Console(area)));
    System.setErr(new PrintStream(new Console(area)));
    area.setEditable(false);
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnShown((e) -> startServer(getParameters().getRaw()));
    primaryStage.show();
}
 
Example #19
Source File: BreakingNewsDemo.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
private void logActivity(Tweet tweet) {
    List<Tweet> sims = algo.getSimilarityHistory();
    if(sims != null && sims.size() > 0) {
        TextArea similarityArea = view.rightActivityPanelProperty().get();
        similarityArea.appendText("\n");
        similarityArea.appendText("==========================\n");
        similarityArea.appendText("[" + tweet.getRecordNum()+"] Similar Tweets:\n");
        for(Tweet t : sims) {
            String[] dStr = TweetUtilities.getJsonNode(t.getJson()).get("created_at").asText().split("\\s");
            String d = dStr[0].concat(", ").concat(dStr[1]).concat(" ").concat(dStr[2]);
            String ti = dStr[3];

            similarityArea.appendText("        [" + d + ", " + ti +"] " + t.getText() + "\n");
        }
    }

    TextArea activityArea = view.leftActivityPanelProperty().get();
    activityArea.appendText("\n");
    activityArea.appendText("==========================\n");
    activityArea.appendText("[" + tweet.getRecordNum()+"] Anomaly Score: " + tweet.getAnomaly()+"\n");
    Metric metric = algo.getSimilarities();
    if(metric != null) {
        activityArea.appendText("    Overlapping Left Right: " + metric.getOverlappingLeftRight() +"\n");
        activityArea.appendText("    Overlapping Right Left: " + metric.getOverlappingRightLeft() +"\n");
        activityArea.appendText("         Euclidean Distance: " + metric.getEuclideanDistance() +"\n");
    }
}
 
Example #20
Source File: TextFileEditor.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createContent(@NotNull final VBox root) {

    textArea = new TextArea();
    textArea.textProperty().addListener((observable, oldValue, newValue) -> updateDirty(newValue));
    textArea.prefHeightProperty().bind(root.heightProperty());
    textArea.prefWidthProperty().bind(root.widthProperty());

    FXUtils.addToPane(textArea, root);
    FXUtils.addClassesTo(textArea, CssClasses.TRANSPARENT_TEXT_AREA);
}
 
Example #21
Source File: PainteraAlerts.java    From paintera with 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 #22
Source File: UiHexViewDialog.java    From EWItool with GNU General Public License v3.0 5 votes vote down vote up
UiHexViewDialog( byte[] patchBlob ) {
  
  // setId( "hex-view-dialog" );
  
  setTitle( "EWItool - Patch in Hex" );
  initStyle(StageStyle.UTILITY);
  getDialogPane().getButtonTypes().add( ButtonType.OK );
  TextArea hexArea = new TextArea( EWI4000sPatch.toHex( patchBlob, true ) );
  hexArea.setPrefColumnCount( 62 );
  hexArea.setWrapText( true );
  getDialogPane().setContent( hexArea );
}
 
Example #23
Source File: TextFilePreview.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected @NotNull TextArea createGraphicsNode() {
    final TextArea textArea = new TextArea();
    textArea.setEditable(false);
    return textArea;
}
 
Example #24
Source File: BrowserTab.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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 #25
Source File: FoxEatsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
public LabelledRadiusPane getDisplayPane() {
    LabelledRadiusPane left = new LabelledRadiusPane("Input Phrases");
    lArea = new TextArea();
    lArea.setWrapText(true);
    lArea.setFont(Font.font("Helvetica", FontWeight.MEDIUM, 16));
    lArea.layoutYProperty().bind(left.labelHeightProperty().add(10));
    left.layoutBoundsProperty().addListener((v, o, n) -> {
        lArea.setLayoutX(10);
        lArea.setPrefWidth(n.getWidth() - 20);
        lArea.setPrefHeight(n.getHeight() - left.labelHeightProperty().get() - 20);
    });
    lArea.textProperty().addListener((v, o, n) -> {
        lArea.setScrollTop(Double.MAX_VALUE);
        lArea.setScrollLeft(Double.MAX_VALUE);
    });
    left.getChildren().add(lArea);
    
    String smallTabs = "\t\t\t\t\t\t\t";
    String bigTabs = "\t\t\t\t\t\t\t\t";
    demo.getPhraseEntryProperty().addListener((v, o, n) -> {
        Platform.runLater(() -> {
            lArea.appendText("\n" + n[0] + (n[0].length() > 4 ? smallTabs : bigTabs) + n[1] + "\t\t\t\t\t\t\t\t" + n[2]);
        });
    });
    
    demo.getPhraseEndedProperty().addListener((v, o, n) -> {
        Platform.runLater(() -> {
            lArea.appendText("\n\nWhat does a fox eat?");
        });
    });
    
    return left;
}
 
Example #26
Source File: ExceptionAlerter.java    From Lipi with MIT License 5 votes vote down vote up
public static void showException(Exception e) {

        if (e != null) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("Exception Alert!");
            alert.setHeaderText("An Exception was thrown.");
            alert.setContentText(e.getMessage());

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

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

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

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

            GridPane expContent = new GridPane();
            expContent.setMaxWidth(Double.MAX_VALUE);
            expContent.add(stackTraceHeaderLabel, 0, 0);
            expContent.add(stackTraceTextArea, 0, 1);

// Set expandable Exception into the dialog pane.
            alert.getDialogPane().setExpandableContent(expContent);
            alert.getDialogPane().setExpanded(true);

            alert.showAndWait();
        }
    }
 
Example #27
Source File: CommandPane.java    From xframium-java with 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;
}
 
Example #28
Source File: CommandPane.java    From xframium-java with 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 #29
Source File: ChromaticityDiagramController.java    From MyBox with 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 #30
Source File: App.java    From DeskChan with 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();
}