-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6u3
-
x86
-
windows_xp
The follow bug can be reproduce with Java 5, Java 6 and Java 7.
If you type a enter key in the HTML text of the JTextPane / JTextEditor outside of a paragraph then the resulting HTML with getText() is wrong. On the display it look ok. But if you request the resulting HTML then there is no paragraph "<p>" or a break "<br>". There is a newline that is ignored from any HTML viewer. The same behaviour is inside a list. I want expect a new list item.
I missing also the feature to insert a break with Shift -ENTER.
To reproduce:
1. Run the sample code below
2. Press Enter after the word "paragraph" or at the end of the list
3. Press the Button
4. Observer that the retured HTML string does not include the newline.
---------------------- Sample Code Begins ---------------------------
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.text.Document;
public class TestEnterKey {
public static void main( String[] args ){
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
final JTextPane text = new JTextPane();
JButton parse = new JButton("Parse");
frame.add( parse, BorderLayout.NORTH );
parse.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent ev ) {
String currentText = text.getText();
System.out.println( currentText );
text.setText( currentText );
}
});
frame.add( text );
String anyText = "<html>" +
"<head></head><body>" +
"any text without paragraph <ul><li>any text inside a list</ul>" +
"</body></html>";
text.setContentType( "text/html" );
Document doc = text.getDocument();
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
text.setText( anyText );
frame.setSize( 300, 200 );
frame.show();
}
}
---------------------- Sample Code Ends ---------------------------
If you type a enter key in the HTML text of the JTextPane / JTextEditor outside of a paragraph then the resulting HTML with getText() is wrong. On the display it look ok. But if you request the resulting HTML then there is no paragraph "<p>" or a break "<br>". There is a newline that is ignored from any HTML viewer. The same behaviour is inside a list. I want expect a new list item.
I missing also the feature to insert a break with Shift -ENTER.
To reproduce:
1. Run the sample code below
2. Press Enter after the word "paragraph" or at the end of the list
3. Press the Button
4. Observer that the retured HTML string does not include the newline.
---------------------- Sample Code Begins ---------------------------
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.text.Document;
public class TestEnterKey {
public static void main( String[] args ){
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
final JTextPane text = new JTextPane();
JButton parse = new JButton("Parse");
frame.add( parse, BorderLayout.NORTH );
parse.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent ev ) {
String currentText = text.getText();
System.out.println( currentText );
text.setText( currentText );
}
});
frame.add( text );
String anyText = "<html>" +
"<head></head><body>" +
"any text without paragraph <ul><li>any text inside a list</ul>" +
"</body></html>";
text.setContentType( "text/html" );
Document doc = text.getDocument();
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
text.setText( anyText );
frame.setSize( 300, 200 );
frame.show();
}
}
---------------------- Sample Code Ends ---------------------------