How do I add a method call to populate widget text

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

How do I add a method call to populate widget text

Postby PaulMcKee » Fri Apr 24, 2009 7:36 am

Hi:
I'm a newbie to SWing designer, so this may be obvious to all of you, but I cannot see how to set the code required to set the text for the widget.. Everything that I enter in the text box ends up as a quoted string and I want to know how to enter an expression. I can enter the code myself in Source view - for example,the designer gave me this:
targetDB = new JTextField();
targetDB.setHorizontalAlignment(SwingConstants.LEFT);
targetDB.setText("ParserMainWin.settingsInstance.getTSrv()");
m_contentPanel.add(targetDB, "6, 8, fill, default");
targetDB.setColumns(10);

Whic I then edited to what I want, namely:
targetDB = new JTextField();
targetDB.setHorizontalAlignment(SwingConstants.LEFT);
targetDB.setText(ParserMainWin.settingsInstance.getTSrv());
..
How can I get this without going into source view?

Thanks

Paul McKee
PaulMcKee
 
Posts: 2
Joined: Fri Apr 24, 2009 7:24 am

Re: How do I add a method call to populate widget text

Postby Eric Clayberg » Fri Apr 24, 2009 11:15 am

You would use the Source view for that.
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: How do I add a method call to populate widget text

Postby PaulMcKee » Fri Apr 24, 2009 9:02 pm

Yes, thats how I did it - use the source view, but its not what - want because of the delay in toggling back and forth between source and design views, as when it goes back to design, it realises something has changed and rebuilds.. What I want when I edit a property is a straightforward editor - if I want plain text, then I can put it in quotes. How do I get this?

This question is really about MVC interpretation - I need my view (part of which is a textfield) to be able to read information from my model, through it's get... methods. How can I tell the tool to do this? My model is completely separate from its Human interface - it can be called by other programs, command line and now GUI, so the model can't change as such. Can I achieve this through bindings? I've tried, but I don't have any beans - I just have getter and setter methods.

Help!
PaulMcKee
 
Posts: 2
Joined: Fri Apr 24, 2009 7:24 am

Re: How do I add a method call to populate widget text

Postby Eric Clayberg » Sat Apr 25, 2009 3:43 am

I would use the new JSR 295 data binding support for this.

Image

You shoudl start by looking at the detailed Swing Data Binding example that we provide.
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: Google [Bot] and 1 guest