Per cambiare l'uso di opacità:
.text-input:disabled {
-fx-opacity: 1.0;
}
nel file css.
Per modificare il TextColor utilizzato (dopo che ho letto la domanda correttamente So che questo non è stato chiesto.)
Dal foglio di stile modena.css:
.root {
/* Used for the inside of text boxes, password boxes, lists, trees, and
* tables. See also -fx-text-inner-color, which should be used as the
* -fx-text-fill value for text painted on top of backgrounds colored
* with -fx-control-inner-background.
*/
-fx-control-inner-background: derive(-fx-base,80%);
/* Version of -fx-control-inner-background for alternative rows */
-fx-control-inner-background-alt: derive(-fx-control-inner-background,-2%);
/* One of these colors will be chosen based upon a ladder calculation
* that uses the brightness of a background color. Instead of using these
* colors directly as -fx-text-fill values, the sections in this file should
* use a derived color to match the background in use. See also:
*
* -fx-text-base-color for text on top of -fx-base, -fx-color, and -fx-body-color
* -fx-text-background-color for text on top of -fx-background
* -fx-text-inner-color for text on top of -fx-control-inner-color
* -fx-selection-bar-text for text on top of -fx-selection-bar
*/
}
.root {
-fx-text-inner-color: #FF01F3;
}
Ad esempio:
@Override
public void start(Stage primaryStage) {
VBox root = new VBox();
root.setAlignment(Pos.CENTER);
Button btn = new Button();
TextField text= new TextField();
btn.setText("Press me!");
btn.setOnAction((ActionEvent event) -> {
text.setText("Goodbye World");
});
root.getChildren().addAll(btn, text);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().addAll(getClass().getResource("css.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}
E il colore del testo nel campo di testo sarà rosa? Viola?
Questo non è un modo per cambiare il colore per ogni campo di testo singolarmente, se lo si cambia per la radice, allora tutti i campi di testo useranno questo colore al posto del solito nero. Non so come cambiare il colore di un campo di testo in blu e di un altro nella stessa applicazione in rosso.
Non fa differenza ....... – hsc
Come lo hai aggiunto? – ItachiUchiha
Poco dettaglio stavo cercando e ho dimenticato di usare il testo corretto: tfAdUsername.setPromptText (userName); modificato in tfAdUsername.setText (userName); – hsc