Hi all,
I've use a JEditorPane to display some HTML text and get the URL including in that text. Everything working fine. Here is my code.
private JEditorPane editor = new JEditorPane();
public void defineEditorPane(String htmlCode){
editor.setEditorKit(new HTMLEditorKit());
editor.setContentType("text/html");
editor.setText(null); // Try to clear the initial text
editor.setSize(jPanel1.getWidth(), jPanel1.getHeight());
editor.setBorder(new BevelBorder(BevelBorder.LOWERED));
editor.setEditable(false);
editor.setText(htmlCode);
//editor.setBackground(Color.LIGHT_GRAY);
editor.addHyperlinkListener(this);
jPanel1.add(editor);
this.setVisible(true);
setWindowLocation();
}
I'll explain little more what I have done here.
First create a JDialog and top of that I add a JPanel. Then on the JPanel I add the JEditorPane. I used NetBeans and I do the above way, because I can' t find the JEdiotPane in the Swing Containers Pallet.
My question is this. If I call the above method with a html code, it displayed the content nicely. Then I call the function with a html code, it doesn't display correctly. I can't see them. If I drag the mouse(or select) on the dialog I can see the content.
I think it's clear what I said. So why it is happened. Any bad coding in my method.
Thanks a lot for commenting.