Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4493953
Votes 3
Synopsis StyleConstants.setLineSpacing does not render
Category java:classes_swing
Reported Against 1.3.1 , merlin-beta
Release Fixed
State 11-Closed, duplicate of 4242645, bug
Priority: 5-Very Low
Related Bugs 4242645
Submit Date 20-AUG-2001
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) 
======================================================================
Work Around
N/A
Evaluation
This is a result of the problem described in 4242645. Closing as a duplicate.
  xxxxx@xxxxx   2001-11-13
Comments
  
  Include a link with my name & email   

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