Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Clojure language reference <a href="http://clojure.org/java_interop" rel="nofollow">here</a> gives the java interoperability rules pretty well. Here are the main points:</p> <ol> <li><p>Static methods are called just like plain functions using class name as namespace:</p> <pre><code>(System/getProperty "java.class.path") </code></pre> <p>This will be resolved to java call <code>System.getProperty("java.class.path")</code></p></li> <li><p>Regular methods are called on specific objects of the class, so their calling syntax is slightly different:</p> <pre><code>(.setText label "Some text") </code></pre> <p>This will be resolved to java call <code>label.setText("Some text")</code>. That is, the regular method calls take this form:</p> <pre><code>(.methodName object arg1 arg2 arg3 ...) </code></pre></li> <li><p>Object are constructed using special form <code>new</code>:</p> <pre><code>(new JLabel "Initial text") </code></pre> <p>There is a shorthand for it using dot reader macro:</p> <pre><code>(JLabel. "Initial text") </code></pre> <p>These last two forms are completely equivalent. So, as you can see, construction takes this form:</p> <pre><code>(new Classname arg1 arg2 ...) ; or (Classname. arg1 arg2 ...) </code></pre></li> </ol> <p>Of course, to use regular methods you have to bind newly created object to some symbol, e.g. like this:</p> <pre><code>(let [label (JLabel. "Initial text")] ...) </code></pre> <p>Inside <code>let</code> body you now can use <code>label</code> as an object:</p> <pre><code>(let [label (JLabel. "Initial text")] (.setText label "New text") (.setIconTextGap label 10)) </code></pre> <p>As follows from your code in the commentary to Kugathasan Abimaran's answer, you are trying to use the same JPanel in several places. You are doing it incorrectly, since (see #3 above) <code>(JPanel. ...)</code> is a construction form, it returns new object every time you use it. You have to bind the new object to some variable, then call methods on it and then put it into container/whatever you need.</p> <p>UPDATE: Your code is fine, you should do like Kugathasan Abimaran suggested. Add his code just before your <code>(doto frame ...</code> line, replacing <code>(JPanel.)</code> there with your <code>panel_0</code>. It will work as required.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload