2013-08-23 3 views
2

TableView 예제 다음에 몇 가지 JavaFX 작업을 수행하고 있습니다. 원래 자바에서는 저자 @Override이 직접적으로 도출 한 TableCell 클래스 메소드 중 몇 가지가 있지만 @OverrideupdateItem 메소드는 클래스 계층에서 2 레벨 위로 올라가고 Cell 클래스에 속합니다.Clojure의 자바 수퍼 클래스 메소드 오버라이드

Clojure에서 이것을 쉽게 수행 할 수있는 방법이 있습니까? 현재 나는 단지 proxy을하고 있지만 필요한 경우 :gen-class을 사용하여 괜찮습니다. Clojure에서 직접적인 기본 클래스를 재정의 (override) 할 수있는 어딘가를 읽었다 고 생각했습니다.

(defn make-editing-cell [] 
    (let [textField (atom nil)] 
    (proxy [TableCell] [] 
     (startEdit [] 
     (proxy-super startEdit) 
     (println "start editing")) 

     (cancelEdit [] 
     (proxy-super cancelEdit) 
     (println "cancel editing")) 

     (updateItem [item empty] 
     ;(proxy-super updateItem ) ;; This causes runtime error No Matching Field Found 
     (if empty 
      (do (println "empty!") 
       (doto this 
       (.setText nil) 
       (.setGraphic nil))) 
      (do (println "not empty!") 
       (if (.isEditing this) 
       (do (println "editing") 
        (if (not @textField) 
         (.setText @textField (.toString (.getItem this)))) 
        (doto this 
         (.setGraphic @textField) 
         (.setContentDisplay ContentDisplay/GRAPHIC_ONLY))) 
       (do (println "not editing") 
        (println this) 
        (println (.getItem this)) 
        (comment 
         (doto this 
         (.setText (.toString (.getItem this))) 
         (.setContentDisplay ContentDisplay/GRAPHIC_ONLY))))))) 
     (println "updating item" item empty))))) 

답변

1

나는 그래서 ... proxy-super 통화에 인수 itemempty을 통과 (proxy-super updateItem item empty)

필요
관련 문제