You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "rkeen-siemens (via GitHub)" <gi...@apache.org> on 2023/07/10 13:50:36 UTC
[GitHub] [netbeans] rkeen-siemens commented on a diff in pull request #5989: #5987: Use the currently active dialog as the presenter parent
rkeen-siemens commented on code in PR #5989:
URL: https://github.com/apache/netbeans/pull/5989#discussion_r1258302071
##########
platform/openide.util.ui/src/org/openide/util/Utilities.java:
##########
@@ -1357,17 +1359,51 @@ private static Frame findMainWindow()
*/
// PR4739
public static Component findDialogParent() {
- Component parent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+ return findDialogParent(null, Utilities::findMainWindow);
+ }
+
+ /**
+ * Finds an appropriate component to use for a modal dialog's parent. Similar to {@link #findDialogParent()}
+ * with the ability to specify a suggested parent component and fallback.
+ *
+ * @param suggestedParent
+ * the component to return if non-null and valid
+ * @param fallback
+ * a supplier for the parent if no other suitable candidate exists
+ * @return the suggested parent if there is either no active modal dialog or it is contained
+ * within that dialog, otherwise the active modal dialog or the fallback.
+ * @since 9.30
+ */
+ public static Component findDialogParent(Component suggestedParent, Supplier<Component> fallback) {
Review Comment:
> this new `findDialolgParent` public API seems mis-directed
My primary goal in adding this was to allow for a dialog to be positioned relative to a component within the currently active window (assuming there isn't another modal window open) rather than to the whole window. This is similar to the way the parent component is used in `JOptionPane` (see `JOptionPane.initDialog(JDialog, int, Component)`).
If it is more palatable, I can remove the `Supplier` argument and just have it default to the main window which would connect it more closely to the platform rather than being a totally generic method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists