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

Scollbar hiding html text




      Name: boT120536 Date: 01/15/2001

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

      There appears to be a problem when working with html tables in JEditorPane. If
      you try to open up a wide table (greater than the length of the frame) at times
      you lose the last few characters in the last cell. Here is some code for
      viewing the html page:

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

      public class SessionDocument implements ActionListener
         private JFrame frame;
         private JEditorPane editorPane;
         private String inputHTMLFilename;
         private int viewWidth;
         private int viewHeight;

         public SessionDocument(String inHTMLFilename)
            frame = new JFrame();
            inputHTMLFilename = inHTMLFilename;
            viewWidth = 600;
            viewHeight = 500;

         public void actionPerformed(ActionEvent e)
            String cmd = e.getActionCommand();
            if (cmd.equals("Close"))


         public void displayFile()
            try {
               String fHeader = new String("file:");
               String sTotal = "";
               sTotal = fHeader.concat(inputHTMLFilename);

               editorPane = new JEditorPane();
               // the next line fixes the error
               //editorPane.setMargin(new Insets(5,5,5,25));

               JScrollPane editorScrollPane = new JScrollPane(editorPane);
               editorScrollPane.setPreferredSize(new Dimension(250, 145));

               frame.getContentPane().add(editorScrollPane, BorderLayout.CENTER);
               frame.setSize(viewWidth, viewHeight);

               JMenuBar menuBar = new JMenuBar();
               JMenu menu = new JMenu("Menu");
               JMenuItem close = new JMenuItem("Close");
               frame.setTitle("Report Viewer");
            catch (IOException e) {
               System.out.println("Error Displaying File!");

         public static void main(String[] args)
            SessionDocument sDocument = new SessionDocument(args[0]);

      Open up this html page into the viewer:

      <BODY bgcolor=white>
      <TABLE align=center>
      <TR><TH align=center colspan="23"><H1>Sample Problem Report</H1></TH>
      <TR><TH height="20"></TH>
      <TR><TH align=center>Xixixi</TH>
      <TH align=center>Xixixixi</TH>
      <TH align=center>Xixix</TH>
      <TH align=center>Xix</TH>
      <TH align=center>Xixi</TH>
      <TH align=center>Xixi</TH>
      <TH align=center>Xix</TH>
      <TH align=center>Xixi</TH>
      <TH align=center>Xixix</TH>
      <TH align=center>Xix</TH>
      <TH align=center>Xixi</TH>
      <TH align=center>Xixix</TH>
      <TH align=center>Xix</TH>
      <TH align=center>Xixi</TH>
      <TH align=center>Xixixi</TH>
      <TH align=center>Xixi</TH>
      <TH align=center>Xixi</TH>
      <TR><TD colspan="23"><HR SIZE="1" noshade></TD></TR>
      <TR><TD align=left>Ssssss/1 </TD>
      <TD align=left>AJKER</TD>
      <TD align=left>BBBB</TD>
      <TD align=right>5</TD>
      <TD align=right>2,300,000</TD>
      <TD align=center>-</TD>
      <TD align=right>0</TD>
      <TD align=right>0</TD>
      <TD align=right></TD>
      <TD align=left>ABC</TD>
      <TD align=right>156</TD>
      <TD align=right>312,000</TD>
      <TD align=center>-</TD>
      <TD align=right>0</TD>
      <TD align=right>0</TD>
      <TD align=right>50</TD>
      <TD align=right>0</TD>
      <TD align=right>2,612,000</TD>
      </TR><TR><TR><TH height="15"> </TH></TR>


      When the frame opens scroll over to the far right. You should see that the
      last 0 is cut off. If you make the frame quite wide you'll see the correct
      value. You might have to resize the frame a couple of times to get the
      incorrect view. Now, if I add the currently commented out line to set the
      margins and change the right margin to 25 I can see all of the text. So my
      guess is that the scrollbar is taking up "space" on the editorPane and not
      being accounted for.

      Through examination I found another oddity. If you changed all of the "i"s in
      the column headers that consist of "Xixi..." to all "x"s you will find that the
      last 0 is not lost. Could this be due to handling font sizes differently?

      One other note. When running the exact same code in jdk1.2.2 everything works

      (Review ID: 115183)




            apikalev Andrey Pikalev
            bonealsunw Bret O'neal (Inactive)
            0 Vote for this issue
            1 Start watching this issue