|
Description
|
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)
======================================================================
|
|
Comments
|
Submitted On 22-AUG-2001
sjacky
I think this is important problem.. I hope it'll fix as
soon as possible.
Submitted On 09-OCT-2001
glaesert
I have the same problems with a similar coding. It works
fine with JDK 1.2.2 but not with versions > 1.3.x.
I hope it will be fixed very soon, because I didn't find a
workaround.
Submitted On 04-NOV-2001
mconnick
Unfortunately, this bug is preventing us from migrating to
Java 2 as the spacing between lines of text seems to have
increased between betwen JDK 1.1.x and JDK 1.3.x and greater.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|