0

So I have an application containing transparent windows. Is there a way for me to get the systems close button and use it in a javafx scene? I am looking to achieve something like this. enter image description here

Notice how the tabs and the close button are on the same line? Do I have to do this manually, or is there a built in method

Thanks in advance

Icedude_907
  • 172
  • 3
  • 11
  • If I understand you correctly you want to be able to have components on the Windows bar just like the browsers do? – JKostikiadis Sep 19 '17 at 21:30
  • Yea pretty much – Icedude_907 Sep 19 '17 at 21:30
  • The only thing i can think of is to set the stage StageStyle.UNDECORATED so everything ( buttons , borders ) will be removed and after that you will add all the necessary component to the stage in order to make it look like you want. You will need to make a custom Title bar , add borders add listeners to make it re sizable etc – JKostikiadis Sep 19 '17 at 21:39
  • Here is some posts to check https://stackoverflow.com/questions/42583779/how-to-change-the-color-of-title-bar-in-framework-javafx https://stackoverflow.com/questions/9861178/javafx-primarystage-remove-windows-borders/9864496#9864496 – JKostikiadis Sep 19 '17 at 21:40
  • so your saying I just need to get the os and do the rest manually? – Icedude_907 Sep 19 '17 at 21:43
  • Yeah at least that's where my knowledge ends. If the was a way to get the entire TitleBar for example with 'lookup' , I guess you could do some hacks but i think there is not suck a way cause the OS manage the Window. – JKostikiadis Sep 19 '17 at 21:46

1 Answers1

2

Try StageStyle.UNIFIED. This feature:

Defines a Stage style with platform decorations and eliminates the border between client area and decorations. The client area background is unified with the decorations.

Note that not all systems support it:

This is a conditional feature, to check if it is supported see Platform.isSupported(javafx.application.ConditionalFeature). If the feature is not supported by the platform, this style downgrades to StageStyle.DECORATED.

Also, depending upon the OS, the UNIFIED style implementation and your requirements, the result of a UNIFIED stage within your application may or may not be what you want. It is, however, likely the closest thing natively implemented by the JavaFX framework.


I haven't used UNIFED stages for a while, but from my recollection on the platform I was trying them on, even though they eliminate the visual delineation between the title and body of the window, you couldn't draw in the vertical area where the close and other controls were, only in the window body area below it. So I am not sure a UNIFIED stage would allow you to have tabs in the same vertical region as the window close button, such as you have in your image within the question. Try it though on your target platforms, and see what the functionality actually is and if it provides something useful for you. As the feature is platform dependent, behavior may vary from platform to platform, so your experience may differ from my recollection.


The alternative is to render the close button in JavaFX than via the OS windowing system capabilities. When doing that the style of the button may not exactly match your OS standard, but you will have complete control over rendering and functionality. For further information on this option, see:

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Thats nice and all but it does not help too much. If no other answer comes up I will mark this as correct so just hang tight! – Icedude_907 Sep 20 '17 at 06:51
  • Lol yes, I guess you are right, not much help at all ;-) I just tried a UNIFED window on a Mac (note you need to set the background color of the Scene to Transparent to see the effect), and all it does (at least on a Mac) is blend the color from the title bar with the rest of the content, not allow you to draw within the title region using JavaFX primitives, so not all that helpful. – jewelsea Sep 20 '17 at 09:30