有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

没有窗口的javafx图形

这可能是一个非常复杂的问题,但是否可以在没有使用javafx窗口的情况下绘制某种图形

为了澄清这一点,我想在屏幕左下角画一个圆圈,除了圆圈以外的所有东西都是底层窗口。所以仅仅删除标题栏是不够的


共 (1) 个答案

  1. # 1 楼答案

    像下面这样的透明窗口

    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 Main extends Application {
    
        @Override
        public void start(Stage stage) {
            stage.initStyle(StageStyle.TRANSPARENT);
            Text text = new Text("!");
            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);
        }
    }
    

    资料来源:http://www.java2s.com/Code/Java/JavaFX/TRANSPARENTwindow.htm