-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
hopper
-
generic, x86
-
generic, solaris_2.5, windows_98
-
Verified
Name: skT45625 Date: 05/09/2000
java version "1.3.0rc3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc3-Z)
Java HotSpot(TM) Client VM (build 1.3.0rc3-Z, mixed mode)
Here is code that will illustrate the problem:
import java.awt.*;
import javax.swing.*;
public class FLBUG extends JFrame {
public static void main(String args[]) {
FLBUG1 f = new FLBUG1();
f.setSize(300,300);
f.show();
}
}
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
public class FLBUG1 extends JFrame {
JTextPane JP;
JScrollPane JSP;
public FLBUG1() {
String FontFamily = "Times New Roman";
FLBUGPP PPx = new FLBUGPP();
getContentPane().setLayout (new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(2,2,2,2);
JP = new JTextPane();
JP.setEditable(false);
JP.setBackground(Color.white);
JP.setMinimumSize(new Dimension(100,200));
JScrollPane JSP = new JScrollPane(JP,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
c.gridx = c.gridy = 0;
c.gridwidth=1; c.gridheight = 1;
c.weightx = c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
getContentPane().add(JSP, c);
PPx.getDocument(JP, 12, "Times New Roman");
pack();
}
}
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class FLBUGPP {
SimpleAttributeSet Attribute[] = new SimpleAttributeSet[10];
DefaultStyledDocument doc;
SimpleAttributeSet Roman = new SimpleAttributeSet();
SimpleAttributeSet NewLemma = new SimpleAttributeSet();
SimpleAttributeSet NewLine = new SimpleAttributeSet();
SimpleAttributeSet NewPar = new SimpleAttributeSet();
public FLBUGPP () {
}
public void getDocument(JTextPane p, int FontSize, String Family) {
String ett = new String(
"This is the first string to be written. It is supposed " +
"to have a negative first line indent, that is the first " +
"line shall begin 15 something to the left of the others " +
" in this 'paragraph'.\nThe 'Left Indent' works but the " +
"'First Line Indent' does not work!\n\n\n");
String two = new String(
"This is the second string to be written. It is supposed " +
"to have a positive first line indent, that is the first " +
"line shall begin 15 something to the right of the others " +
" in this 'paragraph'.\nThe 'Left Indent' works but the " +
"'First Line Indent' does not work!\n\n\n");
String tre = new String(
"This is the third string to be written. It is supposed " +
"to have no first line indentation at all, that is the first " +
"line shall begin at the same position as all the others " +
" in this 'paragraph'.\nThe 'Left Indent' works and the " +
"'First Line Indent' does work (for obvious reason)!\n\n\n");
StyleConstants.setFontFamily(Roman, Family);
StyleConstants.setItalic(Roman, false);
StyleConstants.setBold(Roman, false);
StyleConstants.setFontSize(Roman, FontSize);
doc = (DefaultStyledDocument)p.getDocument();
p.setEditable(false);
float ind = 15.0f;
StyleConstants.setLeftIndent(NewLemma, ind);
StyleConstants.setFirstLineIndent(NewLemma, -ind);
StyleConstants.setLeftIndent(NewPar, ind);
StyleConstants.setFirstLineIndent(NewPar, ind);
StyleConstants.setLeftIndent(NewLine, ind);
StyleConstants.setFirstLineIndent(NewLine, 0.0f);
setP(NewLemma);
insertString(ett, Roman);
setP(NewPar);
insertString(two, Roman);
setP(NewLine);
insertString(tre, Roman);
} // END getDocument
private void setP(SimpleAttributeSet A) {
doc.setParagraphAttributes(doc.getLength(), 0, A, true);
}
private void insertString(String S, SimpleAttributeSet A) {
try { doc.insertString(doc.getLength(), S, A); }
catch (BadLocationException ex) { ex.printStackTrace(); }
}
}
I can not get the FirstLineIndent to work as indented, sorry intended, in
JDK1.3 but in JDK1.2.2 it works just fine.
xxxxx@xxxxxxx 2000-05-09
Additional information (transferred from #104613)
java version "1.3.0rc3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc3-Z)
Java HotSpot(TM) Client VM (build 1.3.0rc3-Z, mixed mode)
This is just an addition to my previous report 'Internal review ID 104344'
about not-functioning first line indentation. I just found out that if I write
out the document as an RTF file an open it in MS Word all the indentations show
up correctly. This indicates - it seems to me - that the problem probably has
to do with screen painting, rather than incorrect indentation values.
The best!
Christian Sj?green
(Review ID: 104344)
======================================================================
Name: rmT116609 Date: 11/21/2000
>java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Compile the attached program and run it.
Everything will be clear after you've done this.
I checked the same source with the JDK delivered with
Visual Age 3.0 (Early Access Adaptor for Java2) and
it worked as expected.
Not so with JDK1.3.
After a short look in the sources of javax.swing.text
I would affirm "firstLineIdention" is used nowhere and
so the (wrong) behavior is not surprising.
Here's the source:
import java.awt.event.*;
import javax.swing.text.*;
import java.awt.*;
import javax.swing.*;
public class ParagraphBug {
public static void main(java.lang.String[] args) throws BadLocationException {
JFrame f = new JFrame("Paragraph Bug");
JTextPane t = new JTextPane();
JScrollPane s = new JScrollPane(t);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.getContentPane().add(s, BorderLayout.CENTER);
StyledDocument doc = t.getStyledDocument();
MutableAttributeSet attribs = t.getInputAttributes();
StyleConstants.setSpaceAbove(attribs, 0.0f);
StyleConstants.setSpaceBelow(attribs, 6.0f);
StyleConstants.setFirstLineIndent(attribs, 11.0f);
doc.setParagraphAttributes(0, doc.getLength(), attribs, false);
doc.insertString(0,"This a paragraph test.\n" + "As you will simply see, the first line is not indented. This is clear because the following lines of this paragraph are indented with the same
value.",
null
);
f.setBounds(50, 50, 300, 200);
f.validate();
f.setVisible(true);
}
}
(Review ID: 112381)
======================================================================
- duplicates
-
JDK-4306206 ParagraphView does not use FirstLineIndent attribute
-
- Closed
-