JTextPane: Workaround for invisible text with hanging indents?
- From: Adam Warner <lists@xxxxxxxxxxxxxxxxx>
- Date: Sat, 27 Aug 2005 13:43:16 +1200
Hi all,
I have a hanging indent requirement for paragraph formatting:
<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/StyleConstants.html#FirstLineIndent>
"The amount of space to indent the first line of the paragraph. This value
may be negative to offset in the reverse direction. The type is Float and
specifies the size of the space in points."
A search of Sun's bug database for [set]FirstLineIndent indicates that Sun
has fixed a number of bugs related to rendering negative first line
indents. Does the code I've written below demonstrate another rendering
bug? I'm typing invisible text on multiple platforms with the latest
stable JDK and Mustang beta:
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class InvisibleText extends JFrame {
public InvisibleText() {
JTextPane tp=new JTextPane();
SimpleAttributeSet attrs=new SimpleAttributeSet();
StyleConstants.setFirstLineIndent(attrs, -150.0f);
StyleConstants.setLeftIndent(attrs, 150.0f);
tp.setParagraphAttributes(attrs, true);
JScrollPane sp=new JScrollPane(tp);
sp.setPreferredSize(new Dimension(300, 200));
getContentPane().add(sp);
}
public static void main(String[] args) {
InvisibleText frame=new InvisibleText();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
While typing text finally appears at the left indent position of
subsequent lines.
Assuming my code correctly invokes this API, can anyone come up with a
workaround to make the text appear while it is typed?
Many thanks,
Adam
.
- Follow-Ups:
- Re: JTextPane: Workaround for invisible text with hanging indents?
- From: Christian Kaufhold
- Re: JTextPane: Workaround for invisible text with hanging indents?
- Prev by Date: Re: Timer event appears to move window
- Next by Date: GUI Prototype erstellen
- Previous by thread: Custom JPanel that clips children?
- Next by thread: Re: JTextPane: Workaround for invisible text with hanging indents?
- Index(es):
Relevant Pages
|
|