Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4073540

Frame doesn't get WindowActivated events

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.1.7
    • 1.1.3, 1.1.4, 1.1.5
    • client-libs
    • b01
    • sparc
    • solaris_2.5.1, solaris_2.6
    • Not verified



        Name: rlT66838 Date: 08/21/97


        Frame implements WindowListener and is registered
        to received all Window events. It gets all but one - WindowActivated.
        It does get however WindowDeactivated.
        Run the code and watch the output while activating/deactivating
        this Frame.
        Note.!! This works on Windows95 i.e. Frame gets WindowActivated
        events while running the same code.


        import java.awt.*;
        import java.awt.event.*;
         
        public class MyFrame extends Frame implements FocusListener,WindowListener
        {
                TextField tf;
         
                public MyFrame() {
                        super();
                        addFocusListener(this);
                        addWindowListener(this);
                        List l = new List(5,false);
                        l.add("item 1");
                        l.add("item 2");
                        add("North",tf = new field(10));
                        add("Center",l);
                }
         
                public void focusGained(FocusEvent e) {
                        System.out.println("Frame:: Focus gained");
                }
         
            public void focusLost(FocusEvent e) {
                        System.out.println("Frame:: Focus lost");
            }
         
                public void windowOpened(WindowEvent e){
                        System.out.println("Frame:: Window opened");
                }
                public void windowClosing(WindowEvent e){
                        System.out.println("Frame:: Window closing");
                }
                public void windowClosed(WindowEvent e){
                        System.out.println("Frame:: Window closed");
                }
                public void windowIconified(WindowEvent e){
                        System.out.println("Frame:: Window iconified");
                }
                public void windowDeiconified(WindowEvent e){
                        System.out.println("Frame:: Window deiconified");
                }
                public void windowActivated(WindowEvent e){
                        System.out.println("Frame:: Window activated");
                }
                public void windowDeactivated(WindowEvent e){
                        System.out.println("Frame:: Window deactivated");
                }
         
                public static void main(String [] args) {
                        MyFrame f = new MyFrame();
                        f.setSize(200,100);
                        f.setVisible(true);
                }
        }

        company - AT&T , email - ###@###.###
        ======================================================================

        This code:
        ----------------

        import java.awt.*;
        import java.awt.event.*;

        public class Sample
        {
            public static void main(String[] argv)
            {
        Frame f = new Frame();
        f.setSize(200,200);
        f.addWindowListener(new myWindowListener());
        f.setVisible(true);
            }
        }

        class myWindowListener extends WindowAdapter
        {
            public void windowActivated(WindowEvent e)
            {
        System.out.println("Window Activated!");
            }

            public void windowDeactivated(WindowEvent e)
            {
        System.out.println("Window DEactivated!");
            }
        }
        ---------------

        Produces:

        Window DEactivated!
        Window DEactivated!
        Window DEactivated!

        and no "Window Activated!"'s when clicking in
        and out of the frame.

        I did not find this in the list of bugs.

        ----------------------------

        I passed out the demo class to some people and they tested it on their
        various systems.

        I was using Solaris and OLWM and I got only Deactivated events, no
        Activated events.

        A user using Linux and TWM got the opposite behaviour I did - no
        Deactivated events, only Activated events.

        A user using Linux and KDE got the correct behaviour, or at least what I
        expect to be correct.

        Someone using FreeBSD and FVWM got a high ratio of Activated events and
        one Deactivated per de- and re-selection... averaging around 3:1...
        apparently due to FVWM's frequent notifications to the window that it is
        active (i.e. when you go between the minimize and maximize boxes on the
        window bar at the top, it sends another "activated" event...")... He did
        have the focus-follows-the-mouse on which might have had something to do
        with it.


              xdengsunw Xianfa Deng (Inactive)
              rlewis Roger Lewis (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: