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

Tab to a hidden JInternalFrame does not bring frame to front

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta2
    • generic
    • generic
    • Not verified



      Name: boT120536 Date: 05/20/2001


      java version "1.3.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
      Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)


      Tabbing from a toolbar component to a JInternalFrame either is giving focus to
      wrong frame or failing to bring the correct frame to the front. This is very
      bad as keyboard navigation is a high priority test criteria for our testors and
      analysts. There is no keyboard navigation to fix this and no focus event to
      trap on JInternalFrame or JDesktopPane. The focus event can be trapped by
      subclassing and overriding the isFocusTraversable(), but this has the
      undesirable effect of creating a tab-stop with no visible clue to the user. To
      make it work right the focus listner must perform either transferFocus() or
      moveToFront(). Either way, the JInternalFrame does not receive an 'Activated'
      event. Note: this is a bug resubmitted at your request with sample code.


      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class TestFrame extends JFrame {
      JTextField jtf = new JTextField(5);
      JDesktopPane desktop = new JDesktopPane();
      JLabel lblFocus = new JLabel("tab to give wrong frame focus");
      public static void main (String[] args) { new TestFrame(); }

      public TestFrame() {
      Box pretendtoolbar = Box.createHorizontalBox();
      pretendtoolbar.add(new JLabel("prompt"));
      pretendtoolbar.add(jtf);
      pretendtoolbar.add(lblFocus);
            pretendtoolbar.add(Box.createHorizontalGlue());
      JPanel pnlMain = new JPanel(new BorderLayout());
      pnlMain.add(pretendtoolbar, BorderLayout.NORTH);
      pnlMain.add(desktop, BorderLayout.CENTER);
      getContentPane().add(pnlMain);
      pack();
      setSize(400, 300);
      show();
      makeframe(1);
      makeframe(2);
      jtf.requestFocus();
            addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
                  System.exit(0);
               }});
      }

      void makeframe (int titleno) {
            String title = "" + titleno;
      JInternalFrame jif = new JInternalFrame("" + title);
      JPanel pnlMain = new JPanel();
      JTextField jtf = new JTextField(10);
      jtf.putClientProperty("TITLE", title);
      pnlMain.add(jtf);
      jtf.addFocusListener(new FocusAdapter() {
      public void focusGained (FocusEvent e) {
      JComponent jc = (JComponent)e.getSource();
      lblFocus.setText("Frame " +
      jc.getClientProperty("TITLE") + " has focus");
      }});

      jif.getContentPane().add(pnlMain);
      desktop.add(jif);
            jif.pack();
            if (titleno == 2)
               jif.setLocation(10, 10);
            jif.setVisible(true);

      }
      }
      (Review ID: 124307)
      ======================================================================

            joutwatesunw Joshua Outwater (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: