All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fxmisc.richtext.demo.Editor4JavaSync Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version

package org.fxmisc.richtext.demo;

import javafx.application.Application;
import javafx.css.PseudoClass;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.CodeArea;

/**
 * 

Name: Editor4JavaSync

*

Description: . *

*

Comment: ... *

*

Copyright: Copyright (c) 2016-2019

*

Company: >StA-Soft<

* @author StA * @version 1.0 */ public class Editor4JavaSync 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 start(Stage primaryStage) { CodeArea codeArea = new TextArea4Java(true); codeArea.replaceText(SAMPLE_CODE); VirtualizedScrollPane vpane = new VirtualizedScrollPane<>(codeArea); final PseudoClass FOCUSED = PseudoClass.getPseudoClass("focused"); codeArea.focusedProperty().addListener((obs, oldVal, newVal) -> { vpane.pseudoClassStateChanged(FOCUSED, newVal); }); StackPane sp = new StackPane(vpane); sp.setPadding(new Insets(10)); Scene scene = new Scene(sp, 600, 400); scene.getStylesheets().add(getClass().getResource("editors.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.setTitle("Java Editor Demo"); primaryStage.show(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy