Search code examples
javaswingjinternalframe

Maximizing internal frame


Does internalFrameIconified works only after internalFrameDeiconified?
And when I iconfy it diplayes Minimized..Is it a java bug?
Can we call the maximize method before minimizing it?

    //  add the intrenal window frame event..
        InternalFrameListener internalFrameListener = new InternalFrameListener() {
        InternalFrameEvent e;
        public void internalFrameOpened(InternalFrameEvent e) {
             System.out.println("Opened");
        }

        public void internalFrameClosing(InternalFrameEvent e) {
        }

        public void internalFrameClosed(InternalFrameEvent e) {
            System.out.println("Closed");
        }

        public void internalFrameIconified(InternalFrameEvent e) {
           System.out.print("Maximised");
         }

        public void internalFrameDeiconified(InternalFrameEvent e) {
        System.out.print("Minimised");
       }

        public void internalFrameActivated(InternalFrameEvent e) {
         System.out.println("Activated");
       }

       public void internalFrameDeactivated(InternalFrameEvent e) {
         System.out.println("DeActivated");
        }
     };
    interFrame.addInternalFrameListener(internalFrameListener);

Solution

  • You simply print wrong messages from the right methods.

        public void internalFrameIconified(InternalFrameEvent e) {
            System.out.print("Maximised"); // Should be "Iconified"
        }
    
        public void internalFrameDeiconified(InternalFrameEvent e) {
            System.out.print("Minimised"); // Should be "Deiconified"
        }
    
        //...
    

    and so on...

    I mean, that the printed text doesn't correspond to what happens with the internal frame.
    When the internal frame is deiconified the corresponding method of the InternalFrameListener prints "Mininmised", because you make him to print that wrong message.
    The same thing with other methods of your InternalFrameListener.
    That's why you can't understand what's really going on.

    Here is the correct code of the InternalFrameListener with correct prints:

    InternalFrameListener internalFrameListener = new InternalFrameListener() {
    
        public void internalFrameOpened(InternalFrameEvent e) {
            System.out.print("Opened");
        }
    
        public void internalFrameClosing(InternalFrameEvent e) {
            System.out.print("Closing");
        }
    
        public void internalFrameClosed(InternalFrameEvent e) {
            System.out.print("Closed");
        }
    
        public void internalFrameIconified(InternalFrameEvent e) {
            System.out.print("Iconified");
        }
    
        public void internalFrameDeiconified(InternalFrameEvent e) {
            System.out.print("Deiconified");
        }
    
        public void internalFrameActivated(InternalFrameEvent e) {
            System.out.print("Activated");
        }
    
        public void internalFrameDeactivated(InternalFrameEvent e) {
            System.out.print("Deactivated");
        }
     };
     interFrame.addInternalFrameListener(internalFrameListener);