* documentation for Swing - Java data @ 2016-12-16 21:15 Claude Marinier 2016-12-16 21:46 ` Sudarshan S Chawathe 0 siblings, 1 reply; 4+ messages in thread From: Claude Marinier @ 2016-12-16 21:15 UTC (permalink / raw) To: kawa Good afternoon, Thank you for all your efforts. Kawa has impressed me so far. 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? Thank you. -- Claude Marinier ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: documentation for Swing - Java data 2016-12-16 21:15 documentation for Swing - Java data Claude Marinier @ 2016-12-16 21:46 ` Sudarshan S Chawathe 2016-12-21 2:30 ` Claude Marinier 0 siblings, 1 reply; 4+ messages in thread From: Sudarshan S Chawathe @ 2016-12-16 21:46 UTC (permalink / raw) To: Claude Marinier; +Cc: kawa > 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: documentation for Swing - Java data 2016-12-16 21:46 ` Sudarshan S Chawathe @ 2016-12-21 2:30 ` Claude Marinier 2016-12-21 6:56 ` Per Bothner 0 siblings, 1 reply; 4+ messages in thread From: Claude Marinier @ 2016-12-21 2:30 UTC (permalink / raw) To: Sudarshan S Chawathe; +Cc: kawa 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: documentation for Swing - Java data 2016-12-21 2:30 ` Claude Marinier @ 2016-12-21 6:56 ` Per Bothner 0 siblings, 0 replies; 4+ messages in thread From: Per Bothner @ 2016-12-21 6:56 UTC (permalink / raw) To: Claude Marinier, Sudarshan S Chawathe; +Cc: kawa On 12/21/2016 03:30 AM, Claude Marinier wrote: > That is a very useful hint. I was able to use this pattern for the > JComboBox and other things. Also check out this link for the more compact keyword-based syntax. It has a number of Swing examples; https://www.gnu.org/software/kawa/Allocating-objects.html -- --Per Bothner per@bothner.com http://per.bothner.com/ ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-21 6:56 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-12-16 21:15 documentation for Swing - Java data Claude Marinier 2016-12-16 21:46 ` Sudarshan S Chawathe 2016-12-21 2:30 ` Claude Marinier 2016-12-21 6:56 ` 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).