* Need some help with Java - Kawa interop
@ 2018-11-01 13:45 Arie van Wingerden
2018-11-02 5:08 ` Per Bothner
0 siblings, 1 reply; 2+ messages in thread
From: Arie van Wingerden @ 2018-11-01 13:45 UTC (permalink / raw)
To: kawa
Trying to generate a random color for a shape in JavaFX.
This (lines 7-9 are the binding of r, g and b):
> (define (randomColor)
(let (
(rnd (java.lang.Math:random))
(r (java.util.Random:nextInt 255))
(g (java.util.Random:nextInt 255))
(b (java.util.Random:nextInt 255)))
(Color:rgb r g b)))
Generates warnings:
.\test.scm:7:34: warning - type integer is incompatible with required type
java.util.Random
.\test.scm:8:34: warning - type integer is incompatible with required type
java.util.Random
.\test.scm:9:34: warning - type integer is incompatible with required type
java.util.Random
.\test.scm:7:8: warning - cannot convert literal (of type gnu.math.IntNum)
to ClassType java.util.Random
.\test.scm:8:8: warning - cannot convert literal (of type gnu.math.IntNum)
to ClassType java.util.Random
.\test.scm:9:8: warning - cannot convert literal (of type gnu.math.IntNum)
to ClassType java.util.Random
What am I doing wrong?
TIA
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Need some help with Java - Kawa interop
2018-11-01 13:45 Need some help with Java - Kawa interop Arie van Wingerden
@ 2018-11-02 5:08 ` Per Bothner
0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2018-11-02 5:08 UTC (permalink / raw)
To: Arie van Wingerden, kawa
On 11/1/18 6:44 AM, Arie van Wingerden wrote:
> Trying to generate a random color for a shape in JavaFX.
> This (lines 7-9 are the binding of r, g and b):
>
>> (define (randomColor)
> (let (
> (rnd ((java.lang.Math:random))
> (r (java.util.Random:nextInt 255))
> (g (java.util.Random:nextInt 255))
> (b (java.util.Random:nextInt 255)))
> (Color:rgb r g b)))
nextInt is not static method, so you need an instance.
(define (randomColor)
(let* ((rnd (java.util.Random))
(r (rnd:nextInt 255))
(g (rnd:nextInt 255))
(b (rnd:nextInt 255)))
(java.awt.Color r g b)))
--
--Per Bothner
per@bothner.com http://per.bothner.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-02 5:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01 13:45 Need some help with Java - Kawa interop Arie van Wingerden
2018-11-02 5:08 ` Per Bothner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).