Facing problem in using JEditorPane as renderer for JList
I am trying to use JEditorPane as renderer for a list. But I am facing some problems. First problem is the output in the editorpane is not shown properly. I want to show a html file, but only portion of the first line that is viewable in the editorpane is shown. I, of course, need to show the total content of the file. Again sometimes the editorpane looks blank. If I click on the list then some text are shown in the editor pane. Please help me to overcome these problems.
Here goes the code for the renderer.
list.setCellRenderer(new ListCellRenderer(){
private JEditorPane editor =new JEditorPane();
public Component getListCellRendererComponent(JList mList, Object value,int index,
boolean isSelected,boolean hasFocus){
try{
editor.setPage("file://localhost/C:/networks/network1/description.html");
editor.setBackground(isSelected ? mList.getSelectionBackground() : mList.getBackground());
editor.setForeground(isSelected ? mList.getSelectionForeground() : mList.getForeground());
editor.setBorder(BorderFactory.createRaisedBevelBorder());
editor.setOpaque(true);
}catch(Exception e){
e.printStackTrace();
}
return editor;
}
});

