On Mon, 28 Oct 2024 20:04:06 GMT, Michael Strauß <mstra...@openjdk.org> wrote:
>> This PR is a new take on a highly requested feature: JavaFX controls in the >> header bar (see also #594 for an earlier iteration). >> >> This is a feature with many possible ways to skin the cat, and it has taken >> quite a bit of effort to come up with a good user model. In contrast to the >> previous iteration, the focus has shifted from providing an entirely >> undecorated window to providing a window with a user-configurable header bar. >> >> The customizable header bar is a new layout container: >> `javafx.scene.layout.HeaderBar`. It has three areas that accept child nodes: >> leading, center, and trailing. `HeaderBar` also automatically adjusts for >> the placement of the default window buttons (minimize, maximize, close) on >> the left or right side of the window. >> >> The customizable header bar is combined with a new `EXTENDED` stage style, >> which extends the client area into the header bar area. The new extended >> stage style is supported on Windows, macOS, and Linux. For platforms that >> don't support this stage style, it automatically downgrades to `DECORATED`. >> >> This is how it looks like on each of the three operating systems: >> >>  >> >> The window buttons (minimize, maximize, close) are provided by JavaFX, not >> by the application developer. This makes it easier to get basic window >> functionality without recreating the entirety of the window controls for all >> platforms. >> >> ## Usage >> This is a minimal example that uses a custom header bar with a `TextField` >> in the center area. `HeaderBar` is usually placed in the top area of a >> `BorderPane` root container: >> >> public class MyApp extends Application { >> @Override >> public void start(Stage stage) { >> var headerBar = new HeaderBar(); >> headerBar.setCenter(new TextField()); >> >> var root = new BorderPane(); >> root.setTop(headerBar); >> >> stage.setScene(new Scene(root)); >> stage.initStyle(StageStyle.EXTENDED); >> stage.show(); >> } >> } >> >> To learn more about the details of the API, refer to the documentation of >> `StageStyle.EXTENDED` and `HeaderBar`. >> >> ## Platform integration >> The implementation varies per platform, and ranges from pretty easy to quite >> involved: >> 1. **macOS**: The window buttons are provided by macOS, we just leave an >> empty area where the window buttons will appear. The client area is extended >> to cover the entire window by setting the `NSW... > > Michael Strauß has updated the pull request incrementally with two additional > commits since the last revision: > > - improve title text documentation > - macOS: hide window title I am getting exceptions on win11: at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:400) at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:430) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:616) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:596) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:589) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$11(QuantumToolkit.java:370) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$4(WinApplication.java:185) at java.base/java.lang.Thread.run(Thread.java:1570) *** unexpected PG access java.lang.Exception: Stack trace at java.base/java.lang.Thread.dumpStack(Thread.java:2176) at javafx.graphics/javafx.scene.Node.getPeer(Node.java:2660) at javafx.graphics/javafx.scene.Parent.validatePG(Parent.java:236) at javafx.graphics/javafx.scene.Parent.doUpdatePeer(Parent.java:201) at javafx.graphics/javafx.scene.Parent$1.doUpdatePeer(Parent.java:109) at javafx.graphics/com.sun.javafx.scene.ParentHelper.updatePeerImpl(ParentHelper.java:78) at javafx.graphics/com.sun.javafx.scene.layout.RegionHelper.updatePeerImpl(RegionHelper.java:72) at javafx.graphics/com.sun.javafx.scene.NodeHelper.updatePeer(NodeHelper.java:107) at javafx.graphics/javafx.scene.Node.syncPeer(Node.java:777) at javafx.graphics/javafx.scene.Node$1.syncPeer(Node.java:513) at javafx.graphics/com.sun.javafx.scene.NodeHelper.syncPeer(NodeHelper.java:221) at javafx.graphics/com.sun.javafx.tk.quantum.ViewSceneOverlay.syncPeer(ViewSceneOverlay.java:96) at javafx.graphics/com.sun.javafx.tk.quantum.ViewSceneOverlay.synchronize(ViewSceneOverlay.java:91) at javafx.graphics/com.sun.javafx.tk.quantum.ViewScene.synchronizeOverlay(ViewScene.java:184) at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2646) at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$2(Toolkit.java:401) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:400) at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:430) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:616) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:596) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:589) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$11(QuantumToolkit.java:370) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$4(WinApplication.java:185) at java.base/java.lang.Thread.run(Thread.java:1570) ------------- PR Comment: https://git.openjdk.org/jfx/pull/1605#issuecomment-2442668189