On Thu, Feb 19, 2009 at 9:09 AM, Eric Thorsen <eric.thor...@gmail.com> wrote: > > In some cases, the Java classes give you an interface where you have > to do all kinds of shenanigans to handle various cases (like the cell > renderer) where a call to a multi-method would be so much cleaner > (IMO). I really just wanted to create a stub class for this 1x. The > above was not bad since it was just 1 function. > Anyone else doing similar things?
I've done such shenanigans with JTable cells and proxy, though a multimethod was a poor fit in my case: (.setDefaultRenderer table Object (proxy [DefaultTableCellRenderer] [] (getTableCellRendererComponent [tbl obj isSelected hasFocus r c] (let [{:keys [level]} (nth rows r)] (doto this (.setForeground (condp > level 0 Color/white 10 Color/blue 20 Color/red 30 Color/magenta Color/black)) (.setText (str obj))))))) If you need access to a super class method, you can use proxy-super. This, for example, is a really wordy way to do essentially nothing: (.setDefaultRenderer table Object (proxy [DefaultTableCellRenderer] [] (getTableCellRendererComponent [tbl obj isSelected hasFocus r c] (proxy-super getTableCellRendererComponent tbl obj isSelected hasFocus r c)))) --Chouser --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---