Javafx 2 我是否可以创建一个透明的根元素?
我想创建一个透明的边框窗格。我尝试将背景色设置为透明,但它显示为白色。如果有办法,请告诉我 我试过的代码Javafx 2 我是否可以创建一个透明的根元素?,javafx-2,Javafx 2,我想创建一个透明的边框窗格。我尝试将背景色设置为透明,但它显示为白色。如果有办法,请告诉我 我试过的代码 BorderPane root=new BorderPane(); root.setStyle("-fx-background-color:transparent"); Scene scene=new Scene(root); stage.setScene(scene); stage.show(); 谢谢…尝试将舞台设置为透明: import javafx.application
BorderPane root=new BorderPane();
root.setStyle("-fx-background-color:transparent");
Scene scene=new Scene(root);
stage.setScene(scene);
stage.show();
谢谢…尝试将舞台设置为透明:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class TransparentStage extends Application {
@Override
public void start(Stage stage) {
// important line
stage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text("Transparent!");
text.setFont(new Font(40));
VBox box = new VBox();
box.getChildren().add(text);
final Scene scene = new Scene(box,300, 250);
scene.setFill(null);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
你确定你的窗口背景不是白色的吗?谢谢。。我要找的语句是scene.setFill(null);