Gibt es eine Möglichkeit, dem Popup einer bestimmten ComboBox eine Stilklasse hinzuzufügen?Java

Java-Forum
Guest
 Gibt es eine Möglichkeit, dem Popup einer bestimmten ComboBox eine Stilklasse hinzuzufügen?

Post by Guest »

Ich möchte eine spezielle Stilklasse für eine ComboBox haben, die ich wiederverwenden kann. Ich möchte beispielsweise eine Klasse „Yellowed“ erstellen, die einen gelben Hintergrund bereitstellt. Das ist mein Code:

Code: Select all

JAVA:
public class NewMain extends Application {

@Override
public void start(Stage primaryStage) {
ComboBox comboBox = new ComboBox();
comboBox.getItems().addAll("Option 1", "Option 2", "Option 3");
comboBox.getStyleClass().add("yellowed");

VBox vbox = new VBox(comboBox);
Scene scene = new Scene(vbox, 400, 300);
scene.getStylesheets().add(NewMain.class.getResource("test.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}
}

CSS:
.combo-box.yellowed {
-fx-background-color: yellow;
}

.combo-box-popup.yellowed > .list-view > .virtual-flow > .clipped-container > .sheet > .list-cell {
-fx-background-color: yellow;
}
Das Problem besteht darin, dass das Popup (meiner ComboBox mit vergilbter-Stilklasse), das angezeigt wird, keine vergilbte-Klasse hat.
Könnte jemand sagen, ob es eine Möglichkeit gibt, dem Popup einer bestimmten ComboBox eine Stilklasse hinzuzufügen?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post