Setting bean properties to Object values

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

Setting bean properties to Object values

Postby mimmoz81 » Wed Jul 21, 2010 5:55 am

Hello,

I have a problem using non-visual components in WindowBuilder 7.6 (2010-07-21 update).

I have a class named TextFieldContainer which has a JTextField property plus an int field both with respective getter and setter:

Code: Select all
public class TextFieldContainer {
   private JTextField field;
   private int fieldId;

   public void setField(JTextField field) {
      this.field = field;
   }
   public JTextField getField() {
      return field;
   }
   public void setFieldId(int fieldId) {
      this.fieldId = fieldId;
   }
   public int getFieldId() {
      return fieldId;
   }
   
}


I would like to use this non-visual component with WindowBuilder in order to set its property "field" to a visual JTextField from within the gui editor.
I was expecting to see TextFieldContainer.field property in WindowBuilder property view just like I see the int property fieldId, but actually this does not happens.
If the property would be visible maybe I could just select from a dropdown list the JTextField I want to assign to this property (from the ones present in current form), and this would dramatically increase my productivity..

My final intent is to extend visual components specifying an interface they implements and set a non-visual bean property to the visual components themselves, just because they implements that interface, e.g.:

Code: Select all
public class InterfaceContainer {
   private ISomeInterface field; // this was JTextField and not an interface..

   public void setField(ISomeInterface field) {
      this.field = field;
   }
   public ISomeInterface getField() {
      return field;
   }
   
}


and
Code: Select all
public class MyTextField extends JTextField implements ISomeInterface { .. }


and
Code: Select all
public class MyCheckBox extends JCheckBox implements ISomeInterface { .. }



Thank you for your excellent support
Luca
Attachments
screen01.JPG
screen01.JPG (64.92 KiB) Viewed 146 times
mimmoz81
 
Posts: 12
Joined: Tue Jun 08, 2010 10:45 pm

Re: Setting bean properties to Object values

Postby Eric Clayberg » Fri Jul 23, 2010 4:46 am

By default, object properties are created as "advanced" properties, so you should use the Show advanced properties button on property table to reveal it.

Image

You can also use a *.wbp-component.xml file to make the property "preferred". See the New Components Tutorial.

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.instantiations.com/D2/WBPComponent">
    <properties-preferred names="field"/>
</component>
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