Skip to content

Instantly share code, notes, and snippets.

@shemnon
Created November 20, 2013 04:01
Show Gist options
  • Save shemnon/7557504 to your computer and use it in GitHub Desktop.
Save shemnon/7557504 to your computer and use it in GitHub Desktop.
Color text backgrounds
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