org.fxmisc.richtext.demo.Editor4JavaAsync Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of richtextfx Show documentation
Show all versions of richtextfx Show documentation
FX-Text-Area for formatted text and other special effects.
package org.fxmisc.richtext.demo;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.fxmisc.richtext.CodeArea;
/**
* Name: Editor4JavaAsync
* Description: .
*
* Comment: ...
*
* Copyright: Copyright (c) 2016-2019, 2021
* Company: >StA-Soft<
* @author StA
* @version 1.0
*/
public class Editor4JavaAsync extends Application
{
/**
* Beispiel-Text.
*/
private static final String SAMPLE_CODE = String.join("\n", new String[]{
"package com.example;",
"",
"import java.util.*;",
"",
"public class Foo extends Bar implements Baz {",
"",
" /*",
" * multi-line comment",
" */",
" public static void main(String[] args) {",
" // single-line comment",
" for(String arg: args) {",
" if(arg.length() != 0)",
" MLogger.inf(arg);",
" else",
" MLogger.wrn(\"Warning: empty string as argument\");",
" }",
" }",
"",
"}"
});
/**
* Main-Methode.
* @param args Kommandozeilenparameter
*/
public static void main(String[] args)
{
launch(args);
}
@Override
public void stop()
{
ExecutorHelper.stopExecutor();
}
/**
* Rand hinzuf?gen.
* @param node Node
* @return StackPane mit Node und Rand
*/
private Node addBorder(Node node)
{
StackPane sp = new StackPane(node);
sp.setPadding(new Insets(10));
return sp;
}
@Override
public void start(Stage primaryStage)
{
TextAreaBase codeArea0 = new TextArea4Java(true);
codeArea0.replaceText(SAMPLE_CODE);
CodeArea codeArea1 = new TextArea4Java(false);
CodeArea codeArea2 = new TextArea4Java(false);
SplitPane sp = new SplitPane();
sp.getItems().add(addBorder(TextAreaBase.addScrollPane(codeArea0)));
sp.getItems().add(addBorder(TextAreaBase.addScrollPane(codeArea1)));
sp.getItems().add(addBorder(TextAreaBase.addScrollPane(codeArea2)));
Scene scene = new Scene(new StackPane(sp), 600, 400);
// scene.getStylesheets().add(getClass().getResource("editors.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("Java Editor Async Demo");
primaryStage.show();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy