javafx - Setting background color of each character in textArea -


i'am new javafx. want in following image inside textarea. think can done using label , set background color of it. how?

image

it can done putting label layout container, hbox:

private final random random = new random();  private final color[] colors = {     color.red, color.green, color.blue, color.yellow };   @override public void start( final stage primarystage ) {     hbox hbox = new hbox();     string str = "my-string-val";     ( string s : str.split( "" ) )     {         label l = new label( s );         l.setborder( new border( new borderstroke( color.black, borderstrokestyle.solid, cornerradii.empty, borderwidths.default ) ) );         l.setbackground( new background( new backgroundfill( colors[random.nextint( colors.length )], cornerradii.empty, insets.empty ) ) );         l.setprefwidth( 20 );         l.setalignment( pos.center );         l.setfont( font( "arial", fontweight.bold, 16 ) );         hbox.getchildren().add( l );     }      final scene scene = new scene( hbox, 800, 600 );     primarystage.setscene( scene );     primarystage.show();  } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -