From: Andreas S. <sch...@ia...> - 2001-11-12 21:55:51
Attachments:
helpBrowser.py
|
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: Robert W. B. <rb...@di...> - 2001-11-13 03:51:14
|
On Mon, 12 Nov 2001, 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. I gave it a try, and it seemed to work. At least it does everything you ask of it. The hyperlinks are not implemented, and there's no means of exiting the jvm on close, but that would be no different in a similar Java implementation. Did you get an error? Did it behave differently than you expected? If it did, how so? Have you implemented the same help browser in Java? -robert > 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: 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 > > |
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 > > |