• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JEditor Pane - HTML Page

 
Akshay Sharma
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the following code to display a HTMLpage.
But the pane is not visible even though its set to true...
No exception is beinmg thrown.
*****************************************************
helpMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
try
{
helpPane = new JEditorPane();
helpPane.setEditable(false);
helpPane.setContentType("text/html");
File htmlFile=new File("test.html");
URL helpUrl=htmlFile.toURL();
helpPane.setPage(helpUrl);
helpPane.setSize(400,400);
helpPane.setVisible(true);
}
catch(Exception e)
{
e.printStackTrace();
}
}
});
*******************************************************************
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JEditorPane is not a top-level window, it's a component that must be added to a window to be shown. So, for instance, you might add

at the end of the try block below. Also note that the setVisible() call on helpPane doesn't do anything and can be removed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic