-
Bug
-
Resolution: Duplicate
-
P5
-
None
-
1.3.1, 1.4.0
-
x86
-
windows_98, windows_2000
Name: bsC130419 Date: 08/20/2001
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
When I modify the line spacing attribute in a MutableAttributeSet using
StyleConstants.setLineSpacing, there is no effect on the text being viewed even
though the paragraph elements now have that attribute. This code demonstrates:
package test;
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class Frame1 extends JFrame
{
JTextPane jEditorPane1 = new JTextPane();
public Frame1()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
Frame1 frame1 = new Frame1();
}
private void jbInit() throws Exception
{
this.setSize(300,300);
StyleContext context = StyleContext.getDefaultStyleContext();
MutableAttributeSet defaultStyle = new SimpleAttributeSet();
StyleConstants.setFontFamily((MutableAttributeSet)
defaultStyle,"Times New Roman");
StyleConstants.setFontSize((MutableAttributeSet)
defaultStyle,12);
StyleConstants.setLineSpacing((MutableAttributeSet)
defaultStyle,2f);
StyleConstants.setSpaceAbove((MutableAttributeSet)
defaultStyle,12f);
DefaultStyledDocument doc = new DefaultStyledDocument(context);
doc.setParagraphAttributes(0,0,defaultStyle,true);
jEditorPane1.setDocument(doc);
this.getContentPane().add(jEditorPane1, BorderLayout.CENTER);
setVisible(true);
}
}
Note that the code sets up a "default style" what is Times New Roman, 12pt, 2f
spacing, and space above is 12 pixels. When this example program executes,
indeed, the text will be 12pt Times New Roman and the space above each
paragraph will be 12 pixels. However, spacing will be single-spaced...
For experimentation purposes, I also tried setting the line-spacing attribute
using setCharacterAttributes (which is I know is the wrong way to do it) and
that didn't work either.
I've seen several people complaining about this and nobody has a solution. I
searched the bug database but found no answers.
As an aside, I tested this in JDK 1.4 beta-b65 and it didn't work there either.
(Review ID: 130254)
======================================================================
- duplicates
-
JDK-4242645 line spacing constraint in ParagraphView
-
- Resolved
-