Created
November 20, 2013 04:01
-
-
Save shemnon/7557504 to your computer and use it in GitHub Desktop.
Color text backgrounds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.layout.FlowPane; | |
import javafx.scene.layout.VBox; | |
import javafx.scene.text.Text; | |
import javafx.stage.Stage; | |
/** | |
* Created by shemnon on 19 Nov 2013. | |
*/ | |
public class ColoredTextRow extends Application{ | |
@Override | |
public void start(Stage stage) throws Exception { | |
VBox box = new VBox(); | |
for (int i = 0; i < 10; i++) { | |
FlowPane fp = new FlowPane(); | |
Text text = new Text("Row " + (i+1)); | |
fp.getChildren().add(text); | |
if (i % 3 == 2) { | |
fp.setStyle("-fx-background-color:red"); | |
} | |
box.getChildren().add(fp); | |
} | |
Scene scene = new Scene(box); | |
stage.setScene(scene); | |
stage.show(); | |
} | |
public static void main(String... args) { | |
Application.launch(ColoredTextRow.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment