1

Topic: Question about *.setStyle () in JavaFX, etc. questions about styles.

The question, actually three. But they connected. The first question. We admit at us there is something similar: import javafx.scene.control. *;//... final static String corner_style = "; final static String backgr_color ="; TextField the_txt = new TextField (); Button the_btn = new Button ("Action!" ); CheckBox the_chk = new CheckBox ();//... If to make so: the_txt. setStyle (corner_style); the_btn. setStyle (corner_style); the_chk. setStyle (corner_style);... That corners at a text box and the button become square-topped (that achieved). But here at check-boxing they do not change. The Check-boxing somehow is in another way drawn in JavaFX? ("-fx-border-radius: 0" on it too does not operate). As well as it to make "square-topped", instead of with the rounded corners? The second question. If to make so: the_txt. setStyle (backgr_color);... That "frame" round a text box generally disappears (though the background changes, as well as it is necessary). How it to save the invariable? The third question. How to make so that when TextField receives focus its background color would change on backgr_color (above), and after focus loss - it was recovered on previous on-default (anything else, except modena.css, it is not used and does not change)? Whether it is possible to make it with the help only a method setStyle () without event handlers?

2

Re: Question about *.setStyle () in JavaFX, etc. questions about styles.

M> the First question. M>... That corners at a text box and the button become square-topped (that achieved). But here at check-boxing they do not change. The Check-boxing somehow is in another way drawn in JavaFX? ("-fx-border-radius: 0" on it too does not operate). As well as it to make "square-topped", instead of with the rounded corners? I normally climb in  css to understand as it is implemented. Normally there it is possible to find answers not any such strange things and as it as a result . Style class: check-box M> the Second question. M> if to make so: M> M> the_txt. setStyle (backgr_color); M> M>... That "frame" round a text box generally disappears (though the background changes, as well as it is necessary). How it to save the invariable? The general council, it is not necessary to set styles directly from the code. It is necessary to work with CSS, and to add classes to . There it is possible then to add some classes to one  and then it is possible to add \delete separate styles. And all on becomes much easier. M> the Third question. M> how to make so that when TextField receives focus its background color would change on backgr_color (above), and after focus loss - it was recovered on previous on-default (anything else, except modena.css, it is not used and does not change)? Whether It is possible to make it with the help only a method setStyle () without event handlers? Yes, but again it is necessary to add the CSS a file to a scene, and then to look towards a pseudo-class "focused"