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

WindowAdapter JavaDoc for windowOpened is not in agreement with implementation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 6u17
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      java version "1.6.0_17"
      Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
      Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

      Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
      Yes

      Operating System Configuration Information (be specific):
      Client: Microsoft Windows XP [Version 5.1.2600]

      Bug Description:
      WindowAdapter JavaDoc for windowOpened is not in agreement with implementation

      The JavaDoc of WindowAdapter for windowOpened says: 'Invoked when a window has been opened.'
      However if you run the code, click on open, close the Test Frame, click on open again then you will see that windowOpened is only called the first time the window is opened.
      I think the implementation should be fixed to fire windowOpened events every time the window is opened (like what the JavaDoc in WindowAdapter says).

      import static java.lang.System.*;
      import static javax.swing.JFrame.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class Test {
        private static JFrame testFrame;

        public static void main(String[] args) {
          testFrame = new JFrame("Test Frame");
          testFrame.addWindowListener(new WindowListener() {
            @Override
            public void windowOpened(WindowEvent anEvent) {
              out.println(anEvent);
            }

            @Override
            public void windowClosing(WindowEvent anEvent) {
              out.println(anEvent);
            }

            @Override
            public void windowClosed(WindowEvent anEvent) {
              out.println(anEvent);
            }

            @Override
            public void windowIconified(WindowEvent anEvent) {
              out.println(anEvent);
            }

            @Override
            public void windowDeiconified(WindowEvent anEvent) {
              out.println(anEvent);
            }

            @Override
            public void windowActivated(WindowEvent anEvent) {
              out.println(anEvent);
            }

            @Override
            public void windowDeactivated(WindowEvent anEvent) {
              out.println(anEvent);
            }
          });
          testFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
          testFrame.setSize(500, 500);
          JFrame mainFrame = new JFrame("Main Frame");
          mainFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
          mainFrame.add(new JButton(new AbstractAction("Open") {
            @Override
            public void actionPerformed(ActionEvent anEvent) {
              testFrame.setVisible(true);
            }
          }));
          mainFrame.setSize(500, 500);
          mainFrame.setVisible(true);
        }
      }

        Attachments

          Activity

            People

            Assignee:
            anthony Anthony Petrov (Inactive)
            Reporter:
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: