-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
x86
-
windows_2000
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)
======================================================================
- duplicates
-
JDK-4318906 Presetting JEditorPane with static text adds extra paragraph (w/HTMLEditorKit)
-
- Resolved
-