<div style="font-family: 'verdana'; font-size: 12px; color: #000;"><span style="background-color: #ffffff;">I like this idea. Especially since there is not much control right now.</span></div>
<div style="font-family: 'verdana'; font-size: 12px; color: #000;"><span style="background-color: #ffffff;">For reference, what I normally do to make sure that a Dialog can not exceed the bounds is:</span></div>
<div style="font-family: 'verdana'; font-size: 12px; color: #000;"><span style="background-color: #ffffff;"> </span></div>
<div style="font-family: 'verdana'; font-size: 12px; color: #000;"><span style="background-color: #ffffff;">dialog.setOnShown(_ -> Platform.runLater(() -> resizeRelocateDialogIfBoundsExceedsScreen(dialog)));</span></div>
<div style="font-family: 'verdana'; font-size: 12px; color: #000;"><span style="background-color: #ffffff;"> </span></div>
<div style="font-family: 'verdana'; font-size: 12px; color: #000;"><span style="background-color: #ffffff;">Which is a bit hacky, and I need to do the calculation by myself. Example of a part of that method:</span></div>
<div style="font-family: 'verdana'; font-size: 12px; color: #000;"><span style="background-color: #ffffff;"> </span></div>
<div style="font-family: 'verdana'; font-size: 12px; color: #000;">
<div> private static void relocateDialog(Dialog<?> dialog, Rectangle2D screenBounds) {<br> // If the dialog exceeds the screen to the right<br> if (dialog.getX() + dialog.getWidth() > screenBounds.getMaxX()) {<br> dialog.setX(screenBounds.getMaxX() - dialog.getWidth() - SCREEN_EDGE_SPACING);<br> }<br> if (dialog.getY() + dialog.getHeight() > screenBounds.getMaxY()) {<br> dialog.setY(screenBounds.getMaxY() - dialog.getHeight() - SCREEN_EDGE_SPACING);<br> }</div>
<div> // If the dialog exceeds the screen to the left<br> if (dialog.getX() < screenBounds.getMinX()) {<br> dialog.setX(screenBounds.getMinX() + SCREEN_EDGE_SPACING);<br> }<br> if (dialog.getY() < screenBounds.getMinY()) {<br> dialog.setY(screenBounds.getMinY() + SCREEN_EDGE_SPACING);<br> }<br> }</div>
<div style="font-family: verdana; font-size: 12px; color: #000000;"> </div>
<div style="font-family: verdana; font-size: 12px; color: #000000;">Since a Dialog uses a Stage, your Anchor API could also be used there (and in the future, integrated into Dialog, which is delegating to the showAndWait(..) method of the Stage)?<br>That would be helpful, and a usecase I often had.</div>
<div style="font-family: verdana; font-size: 12px; color: #000000;"> </div>
<div style="font-family: verdana; font-size: 12px; color: #000000;">I also wonder if we want to retrofit that into the centerOnScreen() method (in the future?). <br>So that this method will use (set) the underlying Anchor System now instead. So we have only one way to position a Stage.</div>
<div style="font-family: verdana; font-size: 12px; color: #000000;"> </div>
<div style="font-family: verdana; font-size: 12px; color: #000000;">-- Marius</div>
<div style="font-family: verdana; font-size: 12px; color: #000000;"> </div>
</div>
<div id="sub-body-container" style="margin: 10px 5px 5px 10px; padding: 10px 0px 10px 10px; border-left: 2px solid rgb(195, 217, 229);">
<div style="margin: 0px 0px 10px;">
<div><strong>Gesendet: </strong>Dienstag, 25. November 2025 um 20:04</div>
<div><strong>Von: </strong>"Michael Strauß" <michaelstrau2@gmail.com></div>
<div><strong>An: </strong>openjfx-dev <openjfx-dev@openjdk.org></div>
<div><strong>Betreff: </strong>Easier placement of stages with positioning anchor</div>
</div>
I've prepared a small enhancement for Stage that allows applications<br>to show a stage relative to a reference point, similar to how popups<br>work. This is a useful addition for a potential system tray support<br>(where windows are often placed relative to a system tray icon), but<br>also comes in handy for multi-window applications.<br><br>Comments are welcome.<br><br>PR: <a href="https://github.com/openjdk/jfx/pull/1986" target="_blank" rel="noopener noreferrer">https://github.com/openjdk/jfx/pull/1986</a></div>