Basically I'm trying to achieve what I wrote in the title
I have a JFrame, and a Dialog, but I want to connect them.
So for example, minimizing the JFrame also minimizes the dialog, moving etc.
I managed to get it to work using addComponentListener using the anonymous inner class and inside the implemented methods I wrote dialog.setLocationRelativeTo(frame).
this one worked, moving the frame moves the dialog.
But the ComponentListener interface doesn't have any methods for minimizing. so it just works for moving.
Now I need to get it to work for minimizing
I found this answer online
Toolkit.getDefaultToolkit().getSystemEventQueue().
postEvent(new WindowEvent(dialog, WindowEvent.WINDOW_STATE_CHANGED));
I tried inside an anonymous WindowListener class for different values of WindowEvent.CONSTANT but it didn't work