Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7c9dd7c8feb5f7f6c4d9fa907e9aabb461b481f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package org.eclipse.fx.ui.controls.sample;

import org.eclipse.fx.ui.controls.styledtext.StyleRange;
import org.eclipse.fx.ui.controls.styledtext.StyledTextArea;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class StyledTextSample extends Application {

	@Override
	public void start(Stage primaryStage) throws Exception {
		BorderPane p = new BorderPane();
		StyledTextArea t = new StyledTextArea();
		t.getStylesheets().add(getClass().getResource("test.css").toExternalForm());
		t.getContent().setText("This is a styled text!\nThis is the 2nd line with data\nBlaBla");
		t.setStyleRanges(
				new StyleRange[] {
						new StyleRange("text-highlight",0,30,null,null)
						,
						new StyleRange("text-highlight",34,5,null,null)
//						,
//						new StyleRange("text-highlight",10,12,null,null)
				});
		p.setCenter(t);

		Scene scene = new Scene(p,800,600);

		primaryStage.setScene(scene);
		primaryStage.show();
	}

	public static void main(String[] args) {
		launch(args);
	}
}

Back to the top