Hi problem with Barcode4J val barcodeGenerator = C...
# getting-started
n
Hi problem with Barcode4J val barcodeGenerator = Code128Bean() barcodeGenerator.fontSize(0.5) got kotlin Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: kotlin version 1.8.10
..followed by this (intimidating indeed): public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
Barcode4j is a java library, version 2.1 fontSize is a property with usual get/set
a
are you sure there’s a
fontSize()
function? What happens if you try
setFontSize(0.5)
instead?
n
Copy code
/**
 * Returns the font size of the human-readable part.
 * @return the font size
 */
public double getFontSize() {
    return this.fontSize;
}

/**
 * Sets the font size of the human-readable part.
 * @param size the font size
 */
public void setFontSize(double size) {
    this.fontSize = size;
}
with setFontSize it works!
i didn't tried because Intellij marked in red but after a while it cleared it up ...
anyway ...
thanks a lot 👍
a
no problem! if there’s a
getFontSize()
and
setFontSize()
in Java (given some conditions…) then Kotlin will magically create a
fontSize
variable property, so this should also work:
Copy code
val barcodeGenerator = Code128Bean()
barcodeGenerator.fontSize = 0.5
https://kotlinlang.org/docs/java-interop.html#getters-and-setters
n
ah my fault!
i was using fontSize(argument)
yes it works in the assignment form .. thanks again 😅
🐕 1