-
Bug
-
Resolution: Unresolved
-
P4
-
6u18, 7, 8
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
We create JTextPane on top of the JScrollPane. We set the editorkit of the JTextPane as 'HTMLEditorKit'.
Then we input some paragraphs to JTextPane and get the text from the 'jtextPane.getText()'. When we compare the output text with the original paragraph, we see additional line breaks were added by the JTextPane. So paragraph text was automatically word wrapped by JTextPane. If we feed the output text back to the JTextPane and get the output text from getText() method again, we can see the text is wrapped again and that results serious formatting issues.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JTextPane on top of the JScrollPane. Place it into a JFrame ( size like 500,500 ).
2. Set the editor kit of JTextPane as 'HTMLEditorKit'.
3. Execute it on 1.6.
4. Select the text pane. Type some paragraphs.
5. Compare the line breaks of output text of the jtextPane.getText() method with the original text.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Text should not get word wrapped by the JTextPane.
ACTUAL -
There are additional line breaks in the output text, which causes formatting issues.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
JFrame frame = new JFrame("Test JTextPane");
Container content = frame.getContentPane();
final JTextPane textPane = new JTextPane();
textPane.setEditorKit( new HTMLEditorKit() );
textPane.setContentType( "text/html" );
textPane.setEditable(true);
JScrollPane scrollPane = new JScrollPane(textPane);
content.add(scrollPane, BorderLayout.CENTER);
JButton button1 = new JButton();
button1.setText("ViewText");
content.add( button1,BorderLayout.SOUTH );
button1.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
System.out.println( textPane.getText() );
}
} );
frame.setSize(500, 500);
frame.setVisible(true);
---------- END SOURCE ----------
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
We create JTextPane on top of the JScrollPane. We set the editorkit of the JTextPane as 'HTMLEditorKit'.
Then we input some paragraphs to JTextPane and get the text from the 'jtextPane.getText()'. When we compare the output text with the original paragraph, we see additional line breaks were added by the JTextPane. So paragraph text was automatically word wrapped by JTextPane. If we feed the output text back to the JTextPane and get the output text from getText() method again, we can see the text is wrapped again and that results serious formatting issues.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JTextPane on top of the JScrollPane. Place it into a JFrame ( size like 500,500 ).
2. Set the editor kit of JTextPane as 'HTMLEditorKit'.
3. Execute it on 1.6.
4. Select the text pane. Type some paragraphs.
5. Compare the line breaks of output text of the jtextPane.getText() method with the original text.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Text should not get word wrapped by the JTextPane.
ACTUAL -
There are additional line breaks in the output text, which causes formatting issues.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
JFrame frame = new JFrame("Test JTextPane");
Container content = frame.getContentPane();
final JTextPane textPane = new JTextPane();
textPane.setEditorKit( new HTMLEditorKit() );
textPane.setContentType( "text/html" );
textPane.setEditable(true);
JScrollPane scrollPane = new JScrollPane(textPane);
content.add(scrollPane, BorderLayout.CENTER);
JButton button1 = new JButton();
button1.setText("ViewText");
content.add( button1,BorderLayout.SOUTH );
button1.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
System.out.println( textPane.getText() );
}
} );
frame.setSize(500, 500);
frame.setVisible(true);
---------- END SOURCE ----------
- duplicates
-
JDK-8194161 Line wrapping of JTextPane incorrect
- Closed