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

Closing a JInternalFrame won't properly give focus to the next JInternalFrame

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.1
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000, windows_xp

      Description



      Name: jk109818 Date: 12/13/2002


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      In a JDesktopPane containing several JInternalFrames, if
      you close an internal frame (with the close(X) button or
      with the convenient keyboard short-cut, the internal frame
      will be closed and the last previously selected internal
      frame will be selected but, after that, the keyboard short-
      cuts don't work (selectNextFrame, selectPreviousFrame,
      close,...).
      You need to click on an unselected internal frame to enable
      again the keyboard short-cuts.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Execute the given source code.
      2. Select one internal frame
      3. Close it with the close button or the keystroke CTRL+F4.
      (Another internal frame is selected automatically)
      4. Using CTRL+F4 won't work on the currently selected
      internal frame.
      You can't use any of the keyboard short-cuts (close,
      selectNextFrame...) until you click on an unselected
      internal frame with the mouse.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      You must be allowed to use keyboard short-cuts after you
      have closed a window.
      It is a problem of focus : after an internal frame is
      closed, another internal frame is well selected but doesn't
      have the focus.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class TestDesktopFrame extends JFrame {
          JDesktopPane desktop;
          public TestDesktopFrame() {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      desktop = new JDesktopPane();
      JInternalFrame frame1 = null;
      for (int i = 0; i<5; i++) {
      frame1 = new JInternalFrame("Fr "+i, true, true, true,
      true);
      frame1.setBounds(i*50, i*50,200,200);
      desktop.add(frame1);
      frame1.setVisible(true);
      }
      getContentPane().add(desktop, BorderLayout.CENTER);
      setSize(600,600);
      setVisible(true);
          }

          public static void main(String[] args) {
              new TestDesktopFrame();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      As workaround, I simply use an InternalFrameListener which
      ask to the selected frame to request the focus when the
      method internalFrameClosed is called.
      [code]
      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;
      import javax.swing.event.*;

      public class WorkAroundDesktopFrame extends JFrame {
          JDesktopPane desktop;
          public WorkAroundDesktopFrame() {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      desktop = new JDesktopPane();
      InternalFrameAdapter adap = new
      InternalFrameAdapter() {
      public void internalFrameClosed
      (InternalFrameEvent e) {
      JInternalFrame itf =
      desktop.getSelectedFrame();
      if (itf != null) {
      itf.requestFocus();

      }
      }
      };
      JInternalFrame frame = null;
      for (int i = 0; i<5; i++) {
      frame = new JInternalFrame("Fr "+i,
      true, true, true, true);
      frame.setBounds(i*50, i*50,200,200);
      frame.addInternalFrameListener
      (adap);
      desktop.add(frame);
      frame.setVisible(true);
      }
      getContentPane().add(desktop,
      BorderLayout.CENTER);
      setSize(600,600);
      setVisible(true);
          }

          public static void main(String[] args) {
              new WorkAroundDesktopFrame();
          }
      }
      [/code]
      (Review ID: 179101)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              joutwatesunw Joshua Outwater (Inactive)
              Reporter:
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: