Pasting to JTextPane
Hi all....
I am trying to copy formatted/plain text from
1. OpenOffice2.0 word processor to JTextPane, but nothing is getting pasted in JTextPane.
2. Any of website and on pasting in JTextPane, some junk characters(box like character) are also getting pasted along with the copied text.
The code which i used is as below :-
publicclass TextPaneExmplextends JFrame{
JTextPane editor =null;
/** The reference object for HTMLEditorKit. */
publicstatic HTMLEditorKit editorKit =null;
/** The reference object for HTMLDocument. */
public HTMLDocument document =null;
JTextArea txtArea =null;
public TextPaneExmpl(){
editor =new JTextPane();
editor.setContentType("text/html");
editor.setEditable(true);
editorKit =new HTMLEditorKit();
document = (HTMLDocument) editorKit.createDefaultDocument();
editor.setEditorKit(editorKit);
editor.setDocument(document);
getContentPane().add(editor, BorderLayout.CENTER);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(800, 600);
setVisible(true);
}
publicstaticvoid main(String[] args){
new TextPaneExmpl();
}
}
Can any one tell me whats the reason for thisOR is there any work around?
Sarjay

