return;
}
+ // Check that one is not adding a sub-window to application
+ if (window.getParent() != null) {
+ throw new IllegalArgumentException(
+ "Window was already added inside another window"
+ + " - it can not be added to application also.");
+ }
+
// Gets the naming proposal from window
String name = window.getName();
public void addWindow(Window window) throws IllegalArgumentException,
NullPointerException {
- if (getParent() != null) {
+ if (window == null) {
+ throw new NullPointerException("Argument must not be null");
+ }
+
+ if (application.getWindows().contains(window)) {
throw new IllegalArgumentException(
- "You can only add windows inside application-level windows");
+ "Window was already added to application"
+ + " - it can not be added to another window also.");
}
- if (window == null) {
- throw new NullPointerException("Argument must not be null");
+ if (getParent() != null) {
+ throw new IllegalArgumentException(
+ "You can only add windows inside application-level windows");
}
subwindows.add(window);