Add support for generic arguments in Window objects

This commit is contained in:
2022-08-26 10:42:30 +02:00
parent a8b2e81c4c
commit f00765ceeb
3 changed files with 4 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ public interface Window extends Widget {
<T extends Component> T reference(String ref, Class<T> type);
default void onOpen(WindowManager manager) {
default void onOpen(WindowManager manager, Object[] args) {
// do nothing
}

View File

@@ -63,7 +63,7 @@ public final class WindowManager extends BaseWidget {
throw new UnsupportedOperationException("Window Manager is hardcoded to be of MATCH_PARENT mode");
}
public void open(Window window) {
public void open(Window window, Object... args) {
requireNonNull(window, "Window cannot be null");
if (windows.isEmpty()) {
@@ -72,7 +72,7 @@ public final class WindowManager extends BaseWidget {
windows.addLast(window);
window.setParent(this);
window.onOpen(this);
window.onOpen(this, args != null ? args : new Object[] {});
}
private void forwardKeyEventToTopWindow(KeyEvent event) {

View File

@@ -92,7 +92,7 @@ public abstract class BaseWindow extends BaseWidget implements Window {
}
@Override
public void onOpen(WindowManager manager) {
public void onOpen(WindowManager manager, Object[] args) {
this.manager = manager;
}