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

REGRESSION: JEditor pane focus problems with HTML components (submit)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs



      Name: gm110360 Date: 12/03/2001


      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

      1. Compile the two files below
      2. Run JFocusDemo
      3. After the HTML Page loads, type something in each of the login/pwd text
      fields.
      4. Mouse click on the submit button.
      5. The submit is not caught.
      6. Now, click the mouse inside the password text box to give it the cursor.
      7. Tab twice so that the submit button now has focus (should show highlight
      rectangle on button).
      8. Mouse click the submit button.
      9. The submit is caught (msg box displayed).

      It appears that the submit will work only when:
      a) the submit button has the current keyboard focus
      b) the submit button is the very first control to get focus (i.e. by clicking on
      it when the window first comes up)

      //----JFocusDemo.java-----
      import javax.swing.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import javax.swing.text.*;
      import javax.swing.text.html.*;

      public class JFocusDemo
      {
          public static void main(String[] args)
          {
      JFrame appFrame = new JFrame("JEditorPane Focus Bug");
      appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           JEditorPane j = new JEditorPane();
           JScrollPane scroller = new JScrollPane(j);
      appFrame.getContentPane().add(scroller);

      j.setEditorKitForContentType("text/html", new ZHTMLEditorKit());
         
      j.setContentType("text/html");
      j.setEditable(false);

      try {
      j.setPage(new
      URL("http://login.yahoo.com/config/login?.src=quote&.intl=us&.done=http://financ
      e.yahoo.com"));
      }
      catch (Exception ex) {}

              appFrame.pack();
      appFrame.setSize(1000,400);
      appFrame.setVisible(true);
          }

      }
      //-----end JFocusDemo.java-----


      //-----ZHTMLEditorKit.java-----
      import javax.swing.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import javax.swing.text.*;
      import javax.swing.text.html.*;
      import java.awt.event.*;

      class ZHTMLEditorKit extends HTMLEditorKit
      {
      private static ViewFactory factory = new ZHTMLFactory();

      public ViewFactory getViewFactory()
      {
      return factory;
      }

      public static class ZHTMLFactory extends HTMLFactory
      {
      public View create(Element e)
      {
      AttributeSet a = e.getAttributes();
      if (a.getAttribute(StyleConstants.NameAttribute) ==
      HTML.Tag.INPUT)
      {
      if
      ("submit".equals(a.getAttribute(HTML.Attribute.TYPE)))
      {
      return new SubmitView(e);
      }
      }
      return super.create(e);
      }
      }
      }


      class SubmitView extends FormView
      {
      public SubmitView(javax.swing.text.Element e)
      {
      super(e);
      }

      public void actionPerformed(ActionEvent e)
      {
      JOptionPane.showMessageDialog(null, "Submit button pressed!");
      }

      }

      //-----end ZHTMLEditorKit.java-----

      Release Regression From : 1.3.1_01a
      The above release value was the last known release where this
      bug was knwon to work. Since then there has been a regression.

      (Review ID: 136575)
      ======================================================================

            idk Igor Kushnirskiy (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: