public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Claude Marinier <claudem223@gmail.com>
To: Sudarshan S Chawathe <chaw@eip10.org>
Cc: kawa@sourceware.org
Subject: Re: documentation for Swing - Java data
Date: Wed, 21 Dec 2016 02:30:00 -0000	[thread overview]
Message-ID: <CAPg6usD3DD4-PYYNL0khdH6XFiRhAudF_tX+O2KQ1NAjNr1X9Q@mail.gmail.com> (raw)
In-Reply-To: <9984.1481924769@vereq.eip10.org>

Allô,

That is a very useful hint. I was able to use this pattern for the
JComboBox and other things.

Thank you.

-- 
Claude Marinier


On 16 December 2016 at 16:46, Sudarshan S Chawathe <chaw@eip10.org> wrote:
>> From: Claude Marinier <claudem223@gmail.com>
>> Date: Fri, 16 Dec 2016 16:15:22 -0500
>
>> I am experimenting with Kawa and Swing. I need to provide choices to
>> a JComboBox and have not found documentation on how to pass data to
>> Java/Swing.
>>
>> Where can I find this?
>
> I'm not sure if I understand the question fully, but in general it is
> easy to call Java constructors and methods from Kawa, and similarly to
> pass Scheme data to Java via implicit or explicit conversion.  The
> chapter titled "Object, Classes and Modules" in the Kawa manual has many
> useful details in this regard.  (The "lambda as shorthand for an
> anonymous class"/SAM-conversion is one of my favorite features,
> especially when using Swing.)
>
> A bit more specific to your question perhaps, the code fragment in the
> JComboBox tutorial at
>
>   https://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html
>
> i.e.:
>
>   String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
>
>   //Create the combo box, select item at index 4.
>   //Indices start at 0, so 4 specifies the pig.
>   JComboBox petList = new JComboBox(petStrings);
>   petList.setSelectedIndex(4);
>   petList.addActionListener(this);
>
> may be written in Kawa along the following lines:
>
>   (let* ((pet-strings (String[] "Bird" "Cat" "Dog" "Rabbit" "Pig"))
>          (pet-list (javax.swing.JComboBox pet-strings)))
>     (pet-list:setSelectedIndex 4)
>     (pet-list:addActionListener (this)))
>
> assuming it occurs in the the scope of a define-simple-class or
> equivalent so that the (this) makes sense.
>
> Regards,
>
> -chaw
>
>
>



-- 
Claude Marinier

  reply	other threads:[~2016-12-21  2:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 21:15 Claude Marinier
2016-12-16 21:46 ` Sudarshan S Chawathe
2016-12-21  2:30   ` Claude Marinier [this message]
2016-12-21  6:56     ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPg6usD3DD4-PYYNL0khdH6XFiRhAudF_tX+O2KQ1NAjNr1X9Q@mail.gmail.com \
    --to=claudem223@gmail.com \
    --cc=chaw@eip10.org \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).