我正在尝试在 Java 中传递一个变量,我需要帮助让它工作,我在下面包含了所有相关代码,我正在使用三个 .java 文件。 以下是所有设置的方式以及我需要它的工作方式;
属性.java
public enum Property {
BACKGROUND_COLOR("LIME");
}
FxUtils.java
public Scene createScene(Text lowerKey) {
Rectangle2D bounds = getScreenBounds();
Scene scene = new Scene(createRoot(lowerKey), bounds.getWidth(), bounds.getHeight());
scene.setFill(Color.LIME); //WANT TO CHANGE THIS TO A VARIABLE IN PROPERTY
return scene;
}
主.java
Scene scene = fxUtils.createScene(lowerKey);
最佳答案
public Scene createScene(Text lowerKey, Color backgroundColor) {
Rectangle2D bounds = getScreenBounds();
Scene scene = new Scene(createRoot(lowerKey), bounds.getWidth(), bounds.getHeight());
scene.setFill(backgroundColor);
return scene;
}
...
createScene(text, Color.RED);
关于java - 将 setFill 与变量一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48493439/