mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-19 01:44:44 -04:00
fixed getWindowAncestor() issue in ErrorMessage class.
This commit is contained in:
parent
fce6e5c4c5
commit
bb11b5cd59
@ -117,7 +117,7 @@ public class ErrorMessage implements Runnable {
|
||||
private String errorMessage;
|
||||
|
||||
private ErrorDialog(Component parent, String title, String message) {
|
||||
super(parent == null ? null : SwingUtilities.getWindowAncestor(parent), title, ModalityType.APPLICATION_MODAL);
|
||||
super(getParentWindow(parent), title, ModalityType.APPLICATION_MODAL);
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
errorMessage = message;
|
||||
@ -160,4 +160,20 @@ public class ErrorMessage implements Runnable {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent window of the given component.
|
||||
* If the component is a window this window is returned
|
||||
*
|
||||
* @param parent the parent component
|
||||
* @return the window instance
|
||||
*/
|
||||
public static Window getParentWindow(Component parent) {
|
||||
if (parent == null)
|
||||
return null;
|
||||
else if (parent instanceof Window)
|
||||
return (Window) parent;
|
||||
else
|
||||
return SwingUtilities.getWindowAncestor(parent);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user