rlm@10: ;;; browse_ui.clj -- starts a swing web browser :-( rlm@10: rlm@10: ; Copyright (c) Christophe Grand, December 2008. All rights reserved. rlm@10: ; The use and distribution terms for this software are covered by the rlm@10: ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) rlm@10: ; which can be found in the file epl-v10.html at the root of this rlm@10: ; distribution. rlm@10: ; By using this software in any fashion, you are agreeing to be bound by rlm@10: ; the terms of this license. rlm@10: ; You must not remove this notice, or any other, from this software. rlm@10: rlm@10: (ns ^{:deprecated "1.2"} rlm@10: clojure.contrib.javadoc.browse-ui) rlm@10: rlm@10: (defn open-url-in-swing rlm@10: "Opens url (a string) in a Swing window." rlm@10: [url] rlm@10: (let [htmlpane (javax.swing.JEditorPane. url)] rlm@10: (.setEditable htmlpane false) rlm@10: (.addHyperlinkListener htmlpane rlm@10: (proxy [javax.swing.event.HyperlinkListener] [] rlm@10: (hyperlinkUpdate [^javax.swing.event.HyperlinkEvent e] rlm@10: (when (= (.getEventType e) (. javax.swing.event.HyperlinkEvent$EventType ACTIVATED)) rlm@10: (if (instance? javax.swing.text.html.HTMLFrameHyperlinkEvent e) rlm@10: (-> htmlpane .getDocument (.processHTMLFrameHyperlinkEvent e)) rlm@10: (.setPage htmlpane (.getURL e))))))) rlm@10: (doto (javax.swing.JFrame.) rlm@10: (.setContentPane (javax.swing.JScrollPane. htmlpane)) rlm@10: (.setBounds 32 32 700 900) rlm@10: (.show)))) rlm@10: