windowStateChanged(WindowEvent e) function doesn't work!!

i have a problem, windowStateChanged(WindowEvent e) simply doesn't get invoked when i resize my window or click on maximize button!!
all the other functions work fine, like windowOnClose, windowIconified...etc. i can't understand what's wrong so it won't invoke.

public void mainImpl() {
    frame = new JFrame(ImageMap.Promoto_Ver);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(getDemoPanel(), BorderLayout.CENTER);
    getDemoPanel().setLocation(0, 0);
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowStateChanged(WindowEvent e) {
        msg.showMessageDialog(new Frame(), e.getComponent().getClass().getName() + " --- Resized ");    //this never gets invoked no matter what i do with my window!!!! why?        
      public void windowClosing(WindowEvent e) {
        if (Drw_pro.prozessID != 0) {
          if (Drw_pro.spremenjeno) {
            int odg = msg.showConfirmDialog(new Frame(),
                                            ImageMap.GetText(132) + " " +
                                            Drw_pro.pro_name + "?",
                                            msg.QUESTION_MESSAGE, msg.getIcon());
            if (odg == msg.YES_OPTION) {
              try {
              catch (Exception ex) {}
            else if (odg == msg.CANCEL_OPTION) {
              //Drw_pro.spremenjeno = false;
            else if (odg == msg.NO_OPTION) {
              try {

Open in new window

Who is Participating?
Dejan PažinConnect With a Mentor Head of SW DevelopmentCommented:

windowStateChanged does not listen for resize changes. You need ComponentListener for that, here is a tutorial:

And here is tutorial for the state listener:
spartanac86Author Commented:
i should have only changed ...frame.addWindowListener... to ...frame.addWindowStateListener...
and it would have worked fine for minimizing/maximizing, but for resizing i think i'll need to use component listener.
Class Window inherits Component, right?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.