public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) { return; } Object userObject = node.getUserObject(); if (userObject instanceof TopicInfo) { TopicInfo topicInfo = (TopicInfo) userObject; try { if (topicInfo.subtopicCount > 0) { htmlPane.setText( "<div style='font-family:Verdana,Tahoma;font-size:10px;'>Please choose a topic</div>"); return; } URL helpFileUrl = ResourceManager.getHelpFileUrl(topicInfo.id); if (helpFileUrl == null) { throw new RuntimeException(); } String content = CommonUtil.readStringFromUrl(helpFileUrl); content = "<html><body style=\"font-family:Verdana,Tahoma;font-size:10px;\">" + "<h2>" + topicInfo.title + "</h2>" + content + "</body></html>"; ((HTMLDocument) htmlPane.getDocument()).setBase(helpFileUrl); htmlPane.setText(content); htmlPane.setCaretPosition(0); } catch (Exception e1) { htmlPane.setText( "<div style='color:#FF0000;font-family:Verdana,Tahoma;font-size:10px;'>Cannot read help for \"" + topicInfo.title + "\"!</div>"); } } }