Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Different behaviour of JTextField and other components  () 1 Vote
Different behaviour of JTextField and other components [message #1561680] Tue, 13 January 2015 08:27 Go to next message
mac deLonghi is currently offline mac deLonghiFriend
Messages: 3
Registered: January 2015
Location: Stuttgart
Junior Member
Hello,

when using WindowBuilder for creating a window with Labels, Textfields and Buttons, I'm struggling to understand, why:

Creating a new JTextField in Design-mode adds
private JTextField tfArtikelnr
to the attributes (right below class declaration)

while

creating any other component (e.g. label) adds
JLabel lblOne = new JLabel("One:");
inside the constructor of the class and not the attributes.

This behaviour is problematic when trying to modify the label in the button-Action.
Error: Cannot refer to a non-final variable ... inside an inner class...

Re: Different behaviour of JTextField and other components [message #1564535 is a reply to message #1561680] Wed, 14 January 2015 21:20 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
I would strongly suggest reading through the WindowBuilder docs as this is, in fact, explained there. If you think about it for a moment it makes perfect sense. Text fields typically need to be programmatically accessed so it makes sense to generate them as fields by default. Static text labels typically are not programmatically accessed, so they are generated as locals by default. All of this is configurable on a widget-by-widget basis (see the docs) or a type-by-type base (see the docs). WindowBuilder's code generation flexibility is one of its standout features. I highly recommend reviewing the docs so that you can take full advantage of them.
Re: Different behaviour of JTextField and other components [message #1587218 is a reply to message #1564535] Tue, 27 January 2015 07:55 Go to previous messageGo to next message
mac deLonghi is currently offline mac deLonghiFriend
Messages: 3
Registered: January 2015
Location: Stuttgart
Junior Member
Thanks a lot!
I agree on the different roles of labels and textfields, even though in our project it is necessary to access and change both.

I didn't know that it is possible to configure this behaviour. That would do for me.
I have read through the WindowBuilder Docs (if eclipse.org/windowbuilder/documentation.php is what you mean), but I couldn't find any hints on configuration.

Could you tell me, what to look for?

Thanks.
Re: Different behaviour of JTextField and other components [message #1588054 is a reply to message #1587218] Tue, 27 January 2015 18:29 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
Look at the docs on the Code Generation preferences.
Re: Different behaviour of JTextField and other components [message #1591085 is a reply to message #1588054] Thu, 29 January 2015 10:02 Go to previous message
mac deLonghi is currently offline mac deLonghiFriend
Messages: 3
Registered: January 2015
Location: Stuttgart
Junior Member
Yes! There it is. Works perfect.
Thanks for the help. Surprised
Previous Topic:IndexOutOfBoundsException?
Next Topic:Is CSS support in WB XWT planned?
Goto Forum:
  


Current Time: Fri Sep 21 02:43:32 GMT 2018

Powered by FUDForum. Page generated in 0.02028 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top