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

JEditorPane("html/text") with HTML FORM INPUT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_2000
    • Verified



      Name: bsC130419 Date: 06/04/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      1.) When entering text in the first html input element, then the cursor
      immediately moves to the next input element.

      2.) The Tab-Key does not work at all.

      3.) Why do I not get a HyperlinkEvent when pressing the submit button?
          With an URL like: menu.html?fname=foo&lname=bar&submit


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

      class Frame extends JFrame {
        Frame() {
          super("Html Test");
          String htmlText = "<html><body>\n"+
                             "<H1>Login:</H1>\n"+
                             "<form action='menu.html' method='post'>\n"+
                               "<p>First name: <input type='text'
      name='fname'></p>\n"+
                               "Last name: <input type='text' name='lname'><br>\n"+
                               "<input type='submit' name='submit'>\n"+
                             "</form>\n"+
                             "</body></html>";

          JEditorPane browser = new JEditorPane("text/html",htmlText);
          browser.setEditable(false);
          getContentPane().add(browser);
          browser.addHyperlinkListener( new HyperlinkListener(){
            public void hyperlinkUpdate(HyperlinkEvent ev) {
              System.out.println(ev.getURL());
            }
          });
        }

        public static void main(String[] args) {
          Frame frame = new Frame();
          frame.setLocation(250,200);
          frame.setSize(360,300);
          frame.setVisible(true);
        }
      }

        Comments to 1.)
      The immediate cursor move to the next element arises only if the element is
      encapsulated within a paragraph tag. When replacing <p> by <br> then the cursor
      remains in the current element.
      This used to work fine in pre jdk1.4 releases.

        Comments to 3.)

      There was never an offical way to retreive the html form intut data from the
      document. I found several request/questions on that topic in the "Java
      Discussion Forums" but no solution for it.
      So please either add a way to collect this data from html forms, or if one
      already exists, then document it so that one can find it easily.
      I think sending a HyperlinkEvent (with an URL that keeps the form data in the
      query part) would be a good and backward compatible solution.
      (Review ID: 125734)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: