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

Navigation problem when using Ctrl-TAB with JSplitPane, JDesktopPane and JInternalFrame together

    Details

      Description

      Hardware: Pentium IV
      OS: Windows XP SP2
      Java version:
        java version "1.5.0_06"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
        Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
      Problem description:
        The scenario is that a JDesktopPane contains two JInternalFrame(s) which contains a JTextField and a JTextArea. Then put the JDesktopPane into a JSplitPane. When using Ctrl-TAB, the navigation behavior is very strange. Please follow the steps below to re-produce the problem.

      Steps:
      1. Compile the following code to get MDFrameDemo.class. Please don't mind the warnings of calling to the deprecated functions.
      2. Run MDFrameDemo.class by entering "java MDFrameDemo". You will get two demo frames, Demo1 and Demo2. Demo1 is the one using JSplitPane, while Demo2 is everything the same as Demo1 but not using JSplitPane.
      3. Use mouse to focus on the text area in Frame1 of Demo1, the one at the top of the frame1.
      4. Press Ctrl-TAB. The focus is moved to the text field, the one at the bottom of the frame1 of Demo1.
      5. Press Ctrl-TAB again. The focus is moved to the text area in Frame0 of Demo1.
      6. Press Ctrl-TAB again. The focus is moved to the text field in Frame0 of Demo1.
      7. Press Ctrl-TAB again. The focus is moved back to the text field in Frame1 of Demo1. Should the focus be moved to the text area in Frame1 of Demo1???
      8. Press Ctrl-TAB again. The focus is moved again to the text field in Frame0 of Demo1. Why it bounces to Frame0 instead???
      9. Keep pressing Ctrl-TAB, the focus will toggle only between the text fields in two different frames (frame1 and Frame0). It's very different to the behavior showed in the step 4 through step 6. Shift-Ctrl-TAB deos not work in this case.

      If compared with Demo2, which is the same as Demo1 but not using JSplitSpane, Ctrl-TAB only toggles the focus between the text area and text field in the same frame (Frame1) of Demo2. Never bother Frame0 of Demo2. Shift-Ctrl-TAB works also. The behavior is also different from the above sample. Altogether, the behavior is strange.

      The above can be reproduced always.

      Another problem is that when moving focus to the next input item within the same frame using Ctrl-TAB, the first letter sometimes was lost.It could occur in both Demo1 and Demo2, especially in Demo2.

      ============================ Sample Code Begin: MDFrameDemo.java ==========================
      import javax.swing.*;
      import java.awt.*;

      public class MDFrameDemo extends JFrame
      {
        private JDesktopPane desktop = new JDesktopPane();
        private JSplitPane splitPane = new JSplitPane();
        
        public MDFrameDemo(String title)
        {
          super(title);
        }
        
        private void initDemo1()
        {
          splitPane.add(desktop, JSplitPane.RIGHT);
          this.getContentPane().add(splitPane, BorderLayout.CENTER);

          for (int i = 0; i < 2; i++)
          {
            InputFrame frm = new InputFrame("Frame" + i);
            frm.setBounds(25 * i, 25 * i, 400, 300);
            desktop.add(frm);
            frm.show();
          }
          setSize(600, 400);
          this.setLocation(30, 30);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          show();
        }
        
        private void initDemo2()
        {
          this.getContentPane().add(desktop, BorderLayout.CENTER);
          
          for (int i = 0; i < 2; i++)
          {
            InputFrame frm = new InputFrame("Frame" + i);
            frm.setBounds(25 * i, 25 * i, 400, 300);
            desktop.add(frm);
            frm.show();
          }
          setSize(600, 400);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          show();
        }

        public static void main(String[] args)
        {
          new MDFrameDemo("Demo2").initDemo2();
          new MDFrameDemo("Demo1").initDemo1();
        }
      }
        
      class InputFrame extends JInternalFrame
      {
        public InputFrame(String tl)
        {
          super(tl, true, true, true, true);
          this.getContentPane().add(new JScrollPane(area), BorderLayout.CENTER);
          this.getContentPane().add(fld, BorderLayout.SOUTH);
        }
        private JTextArea area = new JTextArea();
        private JTextField fld = new JTextField();
      }
      ============================ Sample Code End: MDFrameDemo.java ===========================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                lingyul Ling-Yun Li (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: