This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: documentation for Swing - Java data


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]