Michael Berry
Michael Berry

Reputation: 72379

Remove text from colour picker

The JavaFX colour picker is rather neat, but it always seems to display the text representation of the colour, as well as the colour itself:

JavaFX colour dialog with text

I'd like it without the text, just with the colour square, but can't seem to find a method to style it this way. The only thing that's come close I've tried so far is to restrict the width of the control so the text can't be shown:

picker.setMaxWidth(30);

...but that seems incredibly hacky, and still produces a "..." to the side of the button where the text has been trimmed off:

enter image description here

Any ideas?

Upvotes: 7

Views: 2374

Answers (1)

James_D
James_D

Reputation: 209684

Try this code

colorpicker.setStyle("-fx-color-label-visible: false ;");

Upvotes: 13

Related Questions