Keon Wang
Keon Wang

Reputation: 365

A javaFX Stage could be both StageStyle.UTILITY and StageStyle.TRANSPARENT?

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.

Upvotes: 7

Views: 6051

Answers (5)

Mahe
Mahe

Reputation: 809

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);

Upvotes: 0

sazzy4o
sazzy4o

Reputation: 3343

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.

Upvotes: 1

Perco
Perco

Reputation: 160

something thus?

enter image description here

has an effect on the background

leads code

dialog.initModality(Modality.WINDOW_MODAL);

Upvotes: 1

Keon Wang
Keon Wang

Reputation: 365

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

Upvotes: 4

Perco
Perco

Reputation: 160

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();

Upvotes: 0

Related Questions