14 Apr 2004 12:47
Re: swing example
On 14 Apr 2004, at 11:26, steb wrote:
> Thanks again James for your answer, and sorry as I had replaced the
> wrong
> groovy jar. It should have worked fine from the beginning.
> The exception coming from the line
> display = textField(
> preferredSize:[200,30],horizontalAlignment:SwingConstants.CENTER )
> just arises from the fact that there is no preferredSize(int,int)
> defined
> for JComponent
> so display = textField( preferredSize: new
> Dimension(200,30),horizontalAlignment:SwingConstants.CENTER )
> runs without any trouble.
> ---
> Hereafter is a simple Swing code, adapted from the very first example
> of the
> book "Jython essentials" without using groovy.swing.SwingBuilder.
> What's the
> best way to invoke the function buttonPressed as the line (1)
> generates an
> Exception? and so how to refresh the JTextField?
>
> Thanks again for your help.
> Stéphane
>
> import javax.swing.*
> import java.awt.*
>
> def exit(event){
> System.exit(0)
> }
>
> def createButton(name){
> jbtn = new JButton(name)
> //?? doesn't work (generates a
> java.lang.IncompatibleClassChangeError)
> jbtn.actionPerformed = buttonPressed //(1)
Hmmm I'm not sure why that doesn't work. Certainly this will
jbtn.actionPerformed = { buttonPressed(it) }
Would you mind creating a JIRA issue about this bug?
> return jbtn
> }
>
> def buttonPressed(event){
> //*** following line works fine when called from btn1
> println event.source.text
>
> //?? doesn't work at all
> jtxtField.text = event.source.text
> }
does jtxtField exist?
James
-------
http://radio.weblogs.com/0112098/
RSS Feed