Basic event handling

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Basic event handling

Postby abdaxz » Fri Feb 18, 2011 7:37 am

Hi,

I am quite new to WindowBuilder, but like it so far.

I have one question, though -- how does event handling work for buttons? I have put a textfield, a button and a label on a JPanel and I'd like to be able to transfer whatever is in the textfield to the label when pressing the button. I have so far created (using WindowBuilder) the addActionListener and its actionPerformed -- but inside it, it will not find the label or the textfield. Why? I just get "label1 cannot be resolved" in the actionPerformed.

I know this must be a simple question, but I can not for the life of me understand from the documentation how it is supposed to be done.

Please help!
abdaxz
 
Posts: 2
Joined: Fri Feb 18, 2011 7:32 am

Re: Basic event handling

Postby Eric Clayberg » Fri Feb 18, 2011 10:58 am

Sounds like you need to assign the label to field rather than a local variable.

See... http://code.google.com/javadevtools/wbp ... _menu.html
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Basic event handling

Postby abdaxz » Sat Feb 19, 2011 1:03 pm

Hi,

That made a world of difference!

Thank you very much!
abdaxz
 
Posts: 2
Joined: Fri Feb 18, 2011 7:32 am

Re: Basic event handling

Postby Eric Clayberg » Sat Feb 19, 2011 1:06 pm

Glad hat helped.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest

cron