[英]javafx graphics without a window
這可能是一個很棘手的問題,但是可以使用javafx在沒有窗口的情況下繪制某種圖形嗎?
為了澄清,我想在屏幕的左下角寫一個圓圈,其中除了圓圈之外的所有東西都是基礎窗口。 因此,僅刪除標題欄還遠遠不夠
您是否正在尋找透明的舞台-這會在主顯示器的左下方顯示一個紅色圓圈。 這可能會幫助您朝着想要的方向前進。
public class TransparentStage extends Application {
@Override
public void start(Stage stage) throws Exception {
stage.initStyle(StageStyle.TRANSPARENT);
Circle c = new Circle(30);
c.setFill(Color.RED);
VBox box = new VBox();
box.getChildren().add(c);
final Scene scene = new Scene(box,300, 250);
scene.setFill(null);
stage.setScene(scene);
stage.setX(20);
stage.setY(Screen.getPrimary().getBounds().getHeight() - 100);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
像下面這樣的透明窗口
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.