Reputation: 301
Still pretty green on clojure, java, layouts etc. On a miglayout I have this line to insert an icon on Jlabel:
(JLabel. "" "C:\\MyPriject\Pictures\\TCM00.jpg")
I am getting the following error:
#<CompilerException java.lang.IllegalArgumentException: No matching ctor found for class javax.swing.JLabel (NO_SOURCE_FILE:901)>
Any help will be highly appreciated.
Upvotes: 1
Views: 166
Reputation: 14496
JLabel
has no constructor that takes two String arguments.
If you want just an icon (and no text), there is a constructor that takes one Icon
. The class ImageIcon
(which implements Icon
) has a constructor that takes a filename String. So this should work:
(JLabel. (ImageIcon. "C:\\MyPriject\Pictures\\TCM00.jpg"))
See the javadoc:
http://docs.oracle.com/javase/1.5.0/docs/api/javax/swing/JLabel.html
http://docs.oracle.com/javase/1.5.0/docs/api/javax/swing/ImageIcon.html
Upvotes: 2