Question

im essayant de changer l'arrière-plan et de texte-la couleur d'un TextArea dans javafx-2.

    myComponent = new TextArea();
    myComponent.setStyle("-fx-text-fill: white;");
    myComponent.setStyle("-fx-background-color: black;");
    myComponent.setStyle("-fx-font: " + GUIConstants.SysResponseFont.getName());
    myComponent.setStyle("-fx-font-family: " + GUIConstants.SysResponseFont.getFamily());
    myComponent.setStyle("-fx-font-size: " + GUIConstants.SysResponseFont.getSize());
    myComponent.setStyle("-fx-font-weight: " + GUIConstants.SysResponseFont.getStyle());

Ni les couleurs, ni la police est dans ce TextArea.Dois-je utiliser une approche différente?

Était-ce utile?

La solution

Votre dernier setStyle() remplace les précédentes.Prochain code de définir plusieurs styles:

    myComponent.setStyle("-fx-text-fill: white;"+
    "-fx-background-color: black;"+
    "-fx-font: Courier New;"+
    "-fx-font-family: Courier New;"+
    "-fx-font-weight: bold;"+
    "-fx-font-size: 30;");

Je suppose que pour votre extrait de code serait:

myComponent = new TextArea();
myComponent.setStyle(
    "-fx-text-fill: white;"+
    "-fx-background-color: black;"+
    "-fx-font: " + GUIConstants.SysResponseFont.getName()+ ";" +
    "-fx-font-family: " + GUIConstants.SysResponseFont.getFamily()+ ";" +
    "-fx-font-size: " + GUIConstants.SysResponseFont.getSize()+ ";" +
    "-fx-font-weight: " + GUIConstants.SysResponseFont.getStyle());        

Remarque l' ; des signes à la fin des lignes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top