From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129877 invoked by alias); 21 Dec 2016 02:30:39 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 129817 invoked by uid 89); 21 Dec 2016 02:30:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_20,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Java, Bird, swing, combo X-HELO: mail-it0-f53.google.com Received: from mail-it0-f53.google.com (HELO mail-it0-f53.google.com) (209.85.214.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Dec 2016 02:30:16 +0000 Received: by mail-it0-f53.google.com with SMTP id o141so19249183itc.0 for ; Tue, 20 Dec 2016 18:30:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SHSjsXyDc5agTgQzQYuKtGINr6u8jMRlwab6la0rDug=; b=cMq4elzk7C2lIt+QBNNh2v3X9OSq6JP9/iMcVy4IoFK0SjyEqWyGlLwCfRm+FdmWIo AUFGRWxPbVgAzZwJezwyVkWgbKa5QgLJh1V/f6mZy6tIQwY6lmCyP/hDbPZ6rBfk2cQ4 bX94ko/LDuTmYmg+ZwQ5/JLXTjOpEiOgEtUT3T0be66aA9xIJY4UMgp9TDY6iKVX7/nR XqfBg3Dlqb43WsfJQ89XjSHRpUkTUws2wqh/pvbhed6fjQLP52xq98jCBdLlLutItuH2 9iXUOt6FF6zSFAgFOEorxpj3HKiOUmvuR4Zh8x8I4Pi5Daf344qNhHl6roZZZ2p4tiD3 qIhQ== X-Gm-Message-State: AIkVDXIsCVHOZg+J3pO07R6iA0QTZQo417RUZEo/Otf2F1xqpa/6EE1t9R6Hf3U2j6isfJnUm4e8fu2OFqIGXw== X-Received: by 10.36.204.9 with SMTP id x9mr5729173itf.123.1482287411165; Tue, 20 Dec 2016 18:30:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.33.6 with HTTP; Tue, 20 Dec 2016 18:30:10 -0800 (PST) In-Reply-To: <9984.1481924769@vereq.eip10.org> References: <9984.1481924769@vereq.eip10.org> From: Claude Marinier Date: Wed, 21 Dec 2016 02:30:00 -0000 Message-ID: Subject: Re: documentation for Swing - Java data To: Sudarshan S Chawathe Cc: kawa@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-q4/txt/msg00083.txt.bz2 All=C3=B4, That is a very useful hint. I was able to use this pattern for the JComboBox and other things. Thank you. --=20 Claude Marinier On 16 December 2016 at 16:46, Sudarshan S Chawathe wrote: >> From: Claude Marinier >> 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 =3D { "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 =3D 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 > > > --=20 Claude Marinier