From: Jeff E. <je...@ad...> - 2001-11-13 15:23:18
|
It seems the problem is with JEditorPane and the particular html used in the jython docs. If I feed the JEditorPane some more generic html, then it generates hyperlink events. I didn't investigate what about the jython doc page html the JEditorPane doesn't like. 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 > > |