Link to home
Start Free TrialLog in
Avatar of spartanac86
spartanac86

asked on

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().setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize());
    getDemoPanel().setLocation(0, 0);
    frame.setDefaultCloseOperation(frame.DISPOSE_ON_CLOSE);
    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 + "?",
                                            ImageMap.GetText(63),
                                            msg.YES_NO_CANCEL_OPTION,
                                            msg.QUESTION_MESSAGE, msg.getIcon());
            if (odg == msg.YES_OPTION) {
              try {
                Drw_pro.con_ref.commit();
              }
              catch (Exception ex) {}
            }
            else if (odg == msg.CANCEL_OPTION) {
              //Drw_pro.spremenjeno = false;
              return;
            }
            else if (odg == msg.NO_OPTION) {
              try {
                Drw_pro.con_ref.rollback();
              }
  etc.............etc.............etc

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dejan Pažin
Dejan Pažin
Flag of Austria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spartanac86
spartanac86

ASKER

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?