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

HTMLEditorKit does not parse TAGs for Cp037 character encoding

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      sparc
    • OS:
      solaris_2.6
    • Verification:
      Verified

      Description



      Name: aaC67449 Date: 02/08/2000



      HTMLEditorKit does not parse TAGs in Cp037 character encoding
      See example which tries to display ./index.html using Cp037
      It displays plain text only

      #> java -Dfile.encoding=Cp037 TestWWW

      #> java TestWWW # this displays correct html

      ------------------------- example ----------------
      import java.util.*;
      import javax.swing.text.html.*;
      import javax.swing.text.*;
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.event.*;
      import java.io.*;

      public class TestWWW {

         public static void main(String argv[]) {
        
            JFrame f=new JFrame();
            try {
                  final JEditorPane ep=new JEditorPane();
                  try {
                      ep.setPage("file:index.html");
                  } catch(FileNotFoundException e) {}
                  ep.addMouseListener(new HTMLEditorKit.LinkController());
                  ep.setEditable(false);


                  ep.addHyperlinkListener(new HyperlinkListener() {
                                       public void hyperlinkUpdate(HyperlinkEvent e){
                                           try {
                                             if(e.getEventType().equals(HyperlinkEvent
                                                    .EventType.ACTIVATED)) {
                                                 System.out.println("URL:"
                                                                 +e.getURL());
                                                 ep.setPage(e.getURL());
                                             }
                                            } catch(Exception ex) {
                                                 ex.printStackTrace();
                                            }
                                       }
                                   });
                final JTextField ur=new JTextField("file:index.html",80);
                
                ur.addActionListener(new ActionListener() {
                                          public void actionPerformed(ActionEvent e) {
                                                try {
                                                    ep.setPage(ur.getText());
                                                } catch(Exception ex) {
                                                     ex.printStackTrace();
                                                }
                                          }
                                     });


                JScrollPane panel=new JScrollPane(ep);
                f.getContentPane().add(ur,"North");
                f.getContentPane().add(panel);
                f.setSize(300,300);
                f.setVisible(true);
                ep.isVisible();
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
      }

      ------------------------- index.html ----------------
      <HTML>
      <HEAD>
      <TITLE>Test</TITLE>
      </HEAD>
      <BODY>

      <H1>H1 test</H1>

      <P>
      <A HREF="index.html">
      HREF test</A>
      </P>
      </BODY>
      </HTML>


      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naasunw Naa Naa (Inactive)
              Reporter:
              alisunw Ali Ali (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: