Mercurial > lasercutter
view src/clojure/java/browse_ui.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line source
1 ; Copyright (c) Rich Hickey. All rights reserved.2 ; The use and distribution terms for this software are covered by the3 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)4 ; which can be found in the file epl-v10.html at the root of this distribution.5 ; By using this software in any fashion, you are agreeing to be bound by6 ; the terms of this license.7 ; You must not remove this notice, or any other, from this software.9 (ns10 ^{:author "Christophe Grand",11 :doc "Helper namespace for clojure.java.browse.12 Prevents console apps from becoming GUI unnecessarily."}13 clojure.java.browse-ui)15 (defn- open-url-in-swing16 [url]17 (let [htmlpane (javax.swing.JEditorPane. url)]18 (.setEditable htmlpane false)19 (.addHyperlinkListener htmlpane20 (proxy [javax.swing.event.HyperlinkListener] []21 (hyperlinkUpdate [#^javax.swing.event.HyperlinkEvent e]22 (when (= (.getEventType e) (. javax.swing.event.HyperlinkEvent$EventType ACTIVATED))23 (if (instance? javax.swing.text.html.HTMLFrameHyperlinkEvent e)24 (-> htmlpane .getDocument (.processHTMLFrameHyperlinkEvent e))25 (.setPage htmlpane (.getURL e)))))))26 (doto (javax.swing.JFrame.)27 (.setContentPane (javax.swing.JScrollPane. htmlpane))28 (.setBounds 32 32 700 900)29 (.show))))