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

Moving an undecorated JFrame does not generate corresponding events

    XMLWordPrintable

Details

    • sparc
    • solaris_2.6

    Description


      Moving an Undecorated JFrame using Alt-F7 key sequence does not generate
      corresponding moved event. Problem appears when using jdk 1.4 beta on
      Solaris 2.6 & 2.7, and using all latest patches related to X/Motif.

      The following sample test case below exhibits the problem. Commenting the
      setUndecorated() line out, recompiling, and running shows that (decorated)
      JFrame works fine.

      Also using Alt-F9 key sequence on the undecorated JFrame does not iconify
      undecorated JFrame. This however works fine with (decorated) JFrame.

      Undecorated JFrame is used in this production application for various reasons.
      This application (like a CDE front panel), acts as a control center, launching
      other applications. This application needs to appear as being part of the
      screen, as something that controls the entire desktop. This application needs
      to be visible and at a set location at all times (and cannot give the appearance
      that it can be moved, iconified, maximized, etc). Unfortunately, users still can
      use dtwm modifiers (Alt-F7, Alt-F9, etc) to move, iconify, etc undecorated JFrame
      based GUI. There is a need to negate these users' behavior, but unfortunately
      this bug prevents doing that.


      SAMPLE TEST CASE:
      import java.awt.Point;
      import java.awt.event.ComponentAdapter;
      import java.awt.event.ComponentEvent;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import javax.swing.JFrame;

      // The purpose of this code is to create a JFrame that cannot be moved
      // and cannot be iconified. The code adds listeners to determine when
      // it is moved and when it is iconified. Inside the listener code,
      // it is moved back to 0, 0 or deiconified, as appropriate.

      // When the JFrame is moved:
      // - the code works fine when using a regular JFrame.
      // - the code does not work when using an undecorated JFrame
      // (the componentMoved() method never gets called)

      // ALSO Alt-F9 key sequence on the undecorated JFrame does not iconify
      // JFrame and does not call windowIconified()


      public class TestIconifyMoveFrame extends JFrame
      {
          public static void main(String[] args)
          {
      final Point p = new Point(0, 0);

      final JFrame f = new JFrame("Test Frame");

      f.addComponentListener(new ComponentAdapter()
      {
      public void componentMoved(ComponentEvent e)
      {
      System.out.println("Component moved to " +
      f.getLocation());

      System.out.println("Moving component to " +
      p);

      f.setLocation(p);

      System.out.println("Component now located at " +
      f.getLocation());

      } // end componentMoved()

      } // end inner class
      );

      f.addWindowListener(new WindowAdapter()
      {
      public void windowClosing(WindowEvent e)
      {
      System.exit(1);

      } // end windowClosing()

      public void windowIconified(WindowEvent e)
      {
      System.out.println("Window iconified. Attempting to deiconify.");

      f.setState(JFrame.NORMAL);

      System.out.println("Window deiconified.");

      } // end windowIconified()

      } // end inner class
      );

      // Moving the undecorated JFrame using the Alt-F7 key sequence
              // does NOT generate an event.
              // componentMoved() should get called, but doesn't.
              
              // ALSO Alt-F9 key sequence on the undecorated JFrame does not iconify
              // JFrame and does not call windowIconified()


      f.setUndecorated(true);

      f.setSize(50, 50);

      f.show();

      System.out.println("Init: moving component to " +
      p);

      f.setLocation(p);

      System.out.println("Init: component now located at " +
      f.getLocation());

          } // end main()

      } // end TestIconifyMoveFrame

      Attachments

        Issue Links

          Activity

            People

              vbaranovsunw Vyacheslav Baranov (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Imported:
                Indexed: