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

1.4 REGRESSION: JApplet should have a focus traversal policy.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.4.0, 1.4.1
    • Fix Version/s: 1.4.0_04
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      04
    • CPU:
      x86
    • OS:
      windows_nt, windows_2000

      Backports

        Description

        JApplet is a container and should have a new focus traversal policy and should be a focus cycle root. Without a focus policy, Tab and Shift-Tab will not move to other components when using components added to the content pane of an applet.

        The requestFocus() call seems to work on components since the mnemonic and setLabelFor bindings are still valid.

        This regression was introduced in 1.4 as a result of the new focus manager enhancements. This last worked in 1.3.1.

        Test case:


        >>>>>>>>>>>>>>>>>>>>>>>>>> JAppletTest.java
        import javax.swing.*;
        import java.awt.event.KeyEvent;

        /**
         * Test case for FocusManager regression. JApplet non-focus traversal policy.
         * To reproduce: Use the appletviewer to start the applet. TAB and SHIFT-TAB
         * have no effect on focus traversal.
         *
         * Note: the mnemonic key bindings still work.
         */
        public class JAppletTest extends JApplet {

            // Running the panel in a JApplet doens't allow focus traversal.
            public void init() {
        setContentPane(createPanel());
            }

            private static JPanel createPanel() {
        JTextField tf = new JTextField("text in Text field");
        JLabel label = new JLabel("Label for Text Field");
        label.setDisplayedMnemonic(KeyEvent.VK_L);
        label.setLabelFor(tf);

        JButton button = new JButton("Button");

        // XXX - Hmmmm.... shouldn't there be a setDisplayedMnemonic in JButton?
        // Perhaps there should be a setMnemoic in JLabel?
        button.setMnemonic(KeyEvent.VK_B);

        JPanel panel = new JPanel();
        panel.add(button);
        panel.add(label);
        panel.add(tf);

        return panel;
            }

            // Running the panel in a JFrame allows focus traversal.
            public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setContentPane(createPanel());
        frame.pack();
        frame.setVisible(true);
            }
        }

        <<<<<<<<<<<<<<<<<<< JAppletTest.java

        >>>>>>>>>>>>>>>>>>> JAppletTest.html
        <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
        <html>
          <head>
            <title></title>
          </head>

          <body>
            <h1></h1>
            <applet code="JAppletTest.class" width="400" height="200"></applet>

            <hr>
        <!-- Created: Mon Jun 24 15:37:58 Pacific Daylight Time 2002 -->
        <!-- hhmts start -->
        Last modified: Mon Jun 24 15:38:27 Pacific Daylight Time 2002
        <!-- hhmts end -->
          </body>
        </html>


          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  apikalev Andrey Pikalev
                  Reporter:
                  mdavidsosunw Mark Davidson (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: