From: Jeff E. <je...@ad...> - 2001-11-13 14:37:10
|
The javadoc for JEditorPane says, "EditorKit will generate hyperlink events if the JEditorPane is not editable" You are setting the JEditorPane's editable property to true. See if that helps. Also, you can call JEditorPane.getHyperlinkListeners and verify that your listener is added. The problem is not with your listener, but with forcing the JEditorPane to generate the event. Andreas Schlapbach wrote: > Hi List > > I am looking at scripting languages based on the JVM and I must say I am > impressed of Jython. The feature that really interests me is the dynamic > creation of (JAVA) classes. Implementing interfaces is one application for > this technique. > > So to get to know a language, I allways try to implement this mini > help-browser (see attachment). In order to be able to browse, you have to > implement the HyperlinkListener. I have stared at this now for hours, and I > am allmost convinced it should work. However it does not. > > May be I am just blind, or I miss something. Could somebody take a look this. > > Thanks. > > Andreas > > P.S.: If you remove the <!-- --> comments in the Jython Docs, this could be > the start of a help browser for Jython (JEditorPane seems to allmost > supports HTML 3.2) > > > ------------------------------------------------------------------------ > > from java import awt > from pawt import swing > > class MyHyperlinkListener(swing.event.HyperlinkListener): > def __init__(self): > print "MyHyperlinkListener CStr" > > def hyperlinkUpdate(self,event): > print "Spam and eggs!" > > > def helpBrowser(url): > frame = swing.JFrame("Help Browser") > > panel = swing.JPanel() > > layout = awt.BorderLayout() > panel.setLayout(layout) > > urlField = swing.JTextField(30) > urlField.setText(url) > > toolBar = swing.JToolBar() > toolBar.add(urlField) > > jhtml = swing.JEditorPane() > jhtml.setPage(url) > jhtml.setEditable(1) > jhtml.addHyperlinkListener(MyHyperlinkListener()) > > jhtmlScrollPane = swing.JScrollPane(jhtml) > > statusBar = swing.JTextField() > statusBar.setEditable(1) > > panel.add(toolBar, "North") > panel.add(jhtmlScrollPane, "Center") > panel.add(statusBar, "South") > > frame.getContentPane().add(panel) > frame.pack() > frame.setSize(500,400) > frame.show() > > #adjust > helpBrowser("file:/home/schlpbch/jython/Doc/index.html") > > helpBrowser.py > > Content-Type: > > text/x-java > Content-Encoding: > > base64 > > |