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

Set noneditable on HTML JEditorPane, and getPreferredSize will give wrong answer

XMLWordPrintable

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



      Name: skT45625 Date: 08/23/2000


      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)

      Compile and run this program (jedsize.Demo):


      package jedsize;
      import java.awt.*;
      import javax.swing.*;

      public class Demo
      {
        public static void main (String[] args)
        {
          makeFrame (true);
          makeFrame (false);
        }

        public static void makeFrame (boolean editable)
        {
          JFrame frame = new JFrame();
          Container cont = frame.getContentPane();

          JEditorPane edit = new JEditorPane ("text/html", "some text");
          edit.setEditable (editable);
          System.out.println ("editable: "+editable);
          System.out.println ("prefsize: "+edit.getPreferredSize());

          cont.add (edit);
          frame.pack();
          frame.show();
        }
      }

      It makes two JFrames, each with a JEditorPane viewing HTML text, one
      editable, one not, and prints each preferred size to System.out. The
      non-editable one gets a height of 6.

      I would guess this has something to do with JEditorPane's special
      preferred size rules when inside a viewport, combined with the fact
      that this particular JEditorPane was put in a plain old JPanel.
      (There's a reason I can't use this inside a JScrollPane for the
      purpose I have in mind.) I couldn't tell for sure, though, from
      looking at the source code.
      (Review ID: 108849)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: