A javaFX Stage could be both StageStyle.UTILITY an

2019-01-19 23:41发布

问题:

I mean that when using a stage with stageStyle.UTILITY, I don't want to show the "solid white background " but a transparent background.

I need a stage doesn't shown on the windows' task bar below(stageStyle.UTILITY can satisfy), and I need a transparent background(StageStyle.TRANSPARENT can satisfy)so that I can define the close button style of my stage.

But it seems strange that stageStyle.UTILITY or StageStyle.TRANSPARENT only fit one of my request.

Thank you.

回答1:

Already OK! Also invoke dialogStage.initOwner(parentStage) http://docs.oracle.com/javafx/2/api/javafx/stage/Stage.html#initOwner%28javafx.stage.Window%29



回答2:

something thus?

has an effect on the background

leads code

dialog.initModality(Modality.WINDOW_MODAL);


回答3:

It is not yet possible in javafx but javafx is swing compatible so you can use swing to make a swing equivalent to a transparent utility stage. See here for some examples. I hope that this helps.



回答4:

final Stage stage = new Stage(StageStyle.TRANSPARENT);
Group rootGroup = new Group();
Scene scene = new Scene(rootGroup, 339, 319, Color.TRANSPARENT);
stage.setScene(scene);
stage.centerOnScreen();
stage.show();


回答5:

Look here How can I remove my javafx program from the taskbar

just add (to move it out of sight)

primaryStage.setX(Double.MAX_VALUE);
primaryStage.setY(Double.MAX_VALUE);

and replace

mainStage.initStyle(StageStyle.UNDECORATED);

with

mainStage.initStyle(StageStyle.TRANSPARENT);


标签: javafx stage