https://kotlinlang.org logo
#getting-started
Title
# getting-started
n

Nicola

03/29/2023, 10:11 AM
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

Adam S

03/29/2023, 10:23 AM
are you sure there’s a
fontSize()
function? What happens if you try
setFontSize(0.5)
instead?
n

Nicola

03/29/2023, 10:24 AM
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

Adam S

03/29/2023, 10:26 AM
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

Nicola

03/29/2023, 10:27 AM
ah my fault!
i was using fontSize(argument)
yes it works in the assignment form .. thanks again 😅
🐕 1
15 Views