-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
1.4.2_11, 5.0_06 and 6.0_78
ADDITIONAL OS VERSION INFORMATION :
WinXP service pack 2
A DESCRIPTION OF THE PROBLEM :
Insert the text "[Customer}" to a DefaultStyledDocument and set the paragraph to TextAttribute.RUN_DIRECTION_RTL.
The text is displayed as "}Customer[" while "{Customer]" is expected. The '{' and ']' should be reversed in RTL.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached source codes
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JTextPane should display the "[Customer}" as "{Customer]" in RTL
ACTUAL -
The text is displayed as "}Customer["
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class RTLTest extends JFrame
{
JTextPane textPane;
StyledDocument styledDoc;
public RTLTest ()
{
// some initial setup
super ("TextComponentDemo");
// Create the document for the text area.
styledDoc = new DefaultStyledDocument ();
// Create the text pane and configure it.
textPane = new JTextPane (styledDoc); // All right! No 60's jokes.
textPane.setMargin (new Insets (5, 5, 5, 5));
JScrollPane scrollPane = new JScrollPane (textPane);
textPane.setDragEnabled (true);
scrollPane.setPreferredSize (new Dimension (200, 200));
// Create the text area for the status log and configure it.
setContentPane (textPane);
// Put the initial text into the text pane.
initDocument ();
}
protected void initDocument ()
{
try
{
SimpleAttributeSet paragraphAttributes = new SimpleAttributeSet ();
SimpleAttributeSet characterAttributes = new SimpleAttributeSet ();
StyleConstants.setFontFamily (characterAttributes, "SansSerif");
StyleConstants.setFontSize (characterAttributes, 16);
paragraphAttributes.addAttribute (TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
int index = styledDoc.getLength ();
styledDoc.insertString (index, "\n[\u062a\u0641\u0627\u062d}", characterAttributes);
index = styledDoc.getLength ();
styledDoc.insertString (index, "\n[Customer}", characterAttributes);
paragraphAttributes.addAttribute (TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
styledDoc.setParagraphAttributes (index, styledDoc.getLength () + 1, paragraphAttributes, false);
}
catch (BadLocationException e)
{
System.err.println ("Couldn't insert initial text.");
}
}
/**
* TODO Create Javadoc.
*
* @param args
*/
public static void main (String[] args)
{
final RTLTest frame = new RTLTest ();
frame.addWindowListener (new WindowAdapter ()
{
public void windowClosing (WindowEvent e)
{
System.exit (0);
}
public void windowActivated (WindowEvent e)
{
frame.textPane.requestFocus ();
}
});
frame.pack ();
frame.setVisible (true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround
1.4.2_11, 5.0_06 and 6.0_78
ADDITIONAL OS VERSION INFORMATION :
WinXP service pack 2
A DESCRIPTION OF THE PROBLEM :
Insert the text "[Customer}" to a DefaultStyledDocument and set the paragraph to TextAttribute.RUN_DIRECTION_RTL.
The text is displayed as "}Customer[" while "{Customer]" is expected. The '{' and ']' should be reversed in RTL.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached source codes
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JTextPane should display the "[Customer}" as "{Customer]" in RTL
ACTUAL -
The text is displayed as "}Customer["
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class RTLTest extends JFrame
{
JTextPane textPane;
StyledDocument styledDoc;
public RTLTest ()
{
// some initial setup
super ("TextComponentDemo");
// Create the document for the text area.
styledDoc = new DefaultStyledDocument ();
// Create the text pane and configure it.
textPane = new JTextPane (styledDoc); // All right! No 60's jokes.
textPane.setMargin (new Insets (5, 5, 5, 5));
JScrollPane scrollPane = new JScrollPane (textPane);
textPane.setDragEnabled (true);
scrollPane.setPreferredSize (new Dimension (200, 200));
// Create the text area for the status log and configure it.
setContentPane (textPane);
// Put the initial text into the text pane.
initDocument ();
}
protected void initDocument ()
{
try
{
SimpleAttributeSet paragraphAttributes = new SimpleAttributeSet ();
SimpleAttributeSet characterAttributes = new SimpleAttributeSet ();
StyleConstants.setFontFamily (characterAttributes, "SansSerif");
StyleConstants.setFontSize (characterAttributes, 16);
paragraphAttributes.addAttribute (TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
int index = styledDoc.getLength ();
styledDoc.insertString (index, "\n[\u062a\u0641\u0627\u062d}", characterAttributes);
index = styledDoc.getLength ();
styledDoc.insertString (index, "\n[Customer}", characterAttributes);
paragraphAttributes.addAttribute (TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
styledDoc.setParagraphAttributes (index, styledDoc.getLength () + 1, paragraphAttributes, false);
}
catch (BadLocationException e)
{
System.err.println ("Couldn't insert initial text.");
}
}
/**
* TODO Create Javadoc.
*
* @param args
*/
public static void main (String[] args)
{
final RTLTest frame = new RTLTest ();
frame.addWindowListener (new WindowAdapter ()
{
public void windowClosing (WindowEvent e)
{
System.exit (0);
}
public void windowActivated (WindowEvent e)
{
frame.textPane.requestFocus ();
}
});
frame.pack ();
frame.setVisible (true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround