JDK-5007686 : EditorPane not resizing properly when font is increased from Zero size
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2004-03-04
  • Updated: 2006-05-23
Related Reports
Relates :  
Description
Steps to reproduce:
1) Run the attached test TestResizingEditorPane
2) Click on "Decrease font size" till you see font size: 0 on console.
3) Now try increasing the font size by clicking "Increase font size"
4) Notice that if you see console, preferred size(width) of EditorPane is 
   also not increasing properly according to font size change(See console), 
   And on screen it is not appearing properly, while it is inside
   FlowLayout who respects components preferred size.

Note:
-Tested on Tiger b40
-Reproducible on all L&F's

###@###.### 2004-03-04

Comments
EVALUATION Name: osR10079 Date: 03/04/2004 The is a bug in the test. It sets font to the editor pane and asks its preferred and actual size just after that. But to give a chance to layout manager to change editor pane's actual size the test should call validate() on the parent of the editor pane after setFont(). After such change test works almost fine. The only possible problem is that editor pane reports different preferred width before font size become 0 and after that (106 and 6 in my case) ###@###.### Mar 4, 2004 ====================================================================== Name: osR10079 Date: 03/04/2004 Here is a small testcase to reproduce problem with different preferred width of editor pane after setting font with size == 0. ------------------ SimpleTest.java --------------- import java.awt.*; import javax.swing.*; public class SimpleTest { public static void main(String[] args) { final JEditorPane editor = new JEditorPane(); editor.setText("This is line1\nThis is line2\nThis is line 3"); JFrame jframe = new JFrame("JFrame"); JPanel panel = new JPanel(); panel.add(editor); jframe.getContentPane().add(panel); // jframe.getContentPane().add(editor); jframe.pack(); System.err.println("Preferred size with peer"); System.err.println("\t" + editor.getPreferredSize()); Font font = editor.getFont(); editor.setFont(new Font(font.getName(), font.getStyle(), 0)); jframe.validate(); System.err.println("\t" + editor.getPreferredSize()); editor.setFont(font); jframe.validate(); System.err.println("\t" + editor.getPreferredSize()); jframe.dispose(); } } ------------------ end of SimpleTest.java --------------- Note that if we add editor pane directly to contain pane all works fine. I'm not sure if thisis a bug or not so reassign this to Swing team. ###@###.### Mar 4, 2004 ====================================================================== Actually, there does appear to be a bug here. I'm not concerned with the issue of setting the font size to 0 since we don't claim to support 0 (or negative size) fonts. What I am concerned about is that this JEditorPane is always returning the same preferred size, even when the font is changed. A change in font should result in a change in preferred size. Perhaps we are caching something and not clearing the cache when the font is changed. ###@###.### 2004-03-09 Name: anR10225 Date: 03/16/2004 This bug is introduced by the fix of 4446522. BasicTextArea.getPreferredSize() initializes the view size once after the fix. ======================================================================
25-09-2004