How to set a javafx scene to not have a icon? - java

Is there a way for a JavaFX stage to NOT display an icon, for it to have no icon?
For example, default windows dialog messages. They have no icon but still display on the taskbar and still have title.
Sorry if this is a beginner question that is obvious to some, but it seems the ethernet is too small for my basic questions.

Maybe you can use a different StageStyle than the standard StageStyle.DECORATED e. g. like this:
primaryStage.initStyle(StageStyle.UTILITY); // or StageStyle.UNDECORATED
As far as i know there is no support for removing the stage icon on a stage with the decorated style.

Related

JavaFX dialog without icon

I don't know how to create a dialog without any icon in JavaFX. I've tried
((Stage)dialog.getDialogPane().getScene().getWindow()).getIcons().clear();
but it still leaves the ugly default icon (on Windows 10) of dialog. Is there any better way than setting empty PNG as icon? If so give me the hint.
stage.initStyle(StageStyle.UTILITY);
When you want to get rid of icon you may switch window style to make only content visible without closed, minimize, etc, buttons and also without icon.
javadoc Dialog class
dialog.initStyle(StageStyle.UNDECORATED);
Specifies the style for this dialog. This must be done prior to making
the dialog visible. The style is one of: StageStyle.DECORATED,
StageStyle.UNDECORATED, StageStyle.TRANSPARENT, StageStyle.UTILITY, or
StageStyle.UNIFIED.

Resizing the Stage / Scene to fit the Window

I am new in using JavaFX, and I am facing trouble fitting/sizing my application window.The program can be seen in the image shared below.
When I initially run my program, the size is too small and when i maximize it, the whole anchorpane floats to the left of the window as shown in second image.What I actually want to implement is shown in the third window.
I want to start my app initially as it is shown in the 3rd image, and when the window is resized, the scene must also stretch fitting the stage.
I am very new to JavaFx, so please post help with some example so I can get my app working
Make sure you did Clean and Build and then run the file

JavaFx: StageStyle.UTILITY without close button

I need to use StageStyle utility because I need to hide window icon in taskbar. However, I also need to hide and close button. How to do it? Or maybe there is another solution - no window title bar + no icon in task bar?
This answer is more of a general one: The core problem is that JavaFX doesn't allow you to hide the taskbar icon. So I guess you really don't want to use a Utility StageStyle, but rather are forced to.
Swing allows you to hide the taskbar icon. So the hackaround is simple: Use JavaFX inside a Swing JFrame and hide it from the taskbar.
You can take a look at the widget code in the answer here as an example.

Is it possible to have a JavaFX Stage that is both hidden from the taskbar and lacking a border?

I know that Stage.InitStyle(StageStyle.UTILITY) will create a stage that, as long as it has been init to an owner, will not be present in the task bar (or system specific equivalent).
I also know that Stage.InitStyle(StageStyle.TRANSPARENT) will create a stage with no border or buttons for closing/minimizing/maximizing.
Is it possible to have both?
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.

Java Swing JDialog Transparency

I have been having this problem for quite some time and I've been unable to find the solution anywhere on the internet.
I have a JDialog as my main frame and I need to be able to change the transparency of the window. Normally this would not be a problem if I was to call setUndecorated(true) on it, but I do not want to do that. I want the title bar to appear at the top under the system look and feel.
The interesting part is that on my Mac, changing the transparency works just fine with the system look and feel, even though the JDialog is still "decorated".
Here's an image of my JDialog so you know what I'm dealing with:
I need to use the system look and feel, but I also need to be able to change the transparency of the window.
When I try, I get the following exception on windows:
"Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The dialog is decorated"
If I set it to undecorated, I lose the title bar at the top which is not an option. Anybody know a way around this?

Categories