Complex types in custom controls

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

Complex types in custom controls

Postby waldronk » Mon Feb 14, 2005 9:01 am

I'm trying to create a custom panel that supports a complex type. I've created a bean info for the panel class that supports 2 boolean properties and a property that accepts a javax.swing.ImageIcon. When import the bean the boolean properties show up fine in the designer properties but the icon property does not. This works in another tool I've used. Does Swing Designer only support basic types for custom properties and if so are there any plans to add support for more complex types? Also, is the ocean look and feel (and java 1.5) supported in the designer? Thanks.

Kevin Waldron
waldronk
 
Posts: 1
Joined: Mon Feb 14, 2005 8:48 am
Location: Kent, WA

Postby Guest » Fri Feb 18, 2005 10:20 am

Since I haven't gotten a respone let me clarify my issue, which has changed slightly. I've created my own font class (MyFont) that wraps the the java.awt.font and provides an enumerated list of available fonts: FONT_A, FONT_B, FONT_C, etc.. I tried creating a PropertyEditor (MyFontEditor) so that the GUI designer can pick from a drop down list of our available fonts. I want to add this capability to all my custom widgets. I can get the property to show up in the swing builder 3.0.1 (though I had to specifically set the propertyeditor in the beaninfo) and it will generate the proper code but after i pick from the list it will not display my selection nor will it render the change (which might be related to the fact that the standalone font picker doesn't support the SansSerif font family we are using). Should this work? Below is the code for my editor:

public class MyFontEditor
extends PropertyEditorSupport {

public MyFontEditor() {
}

public MyFontEditor(Object source) {
super(source);
}

public String[] getTags() {
String[] tags = new String[MyFont.class.getFields().length];
Field[] fields = MyFont.class.getFields();

for(int i=0; i< fields.length; i++) {
tags[i] = fields[i].getName();
}
return tags;
}

public void setAsText(String text) throws IllegalArgumentException {
setValue(MyFont.fromString(text));
}

public String getAsText() {
if(getValue() != null) {
return getValue().toString();
} else {
return "";
}
}

public String getJavaInitializationString() {
return "MyFont." + getValue().toString();
}
}

thanks,
Kevin
Guest
 

Re: Complex types in custom controls

Postby Eric Clayberg » Mon Feb 21, 2005 9:45 am

waldronk wrote:I'm trying to create a custom panel that supports a complex type. I've created a bean info for the panel class that supports 2 boolean properties and a property that accepts a javax.swing.ImageIcon. When import the bean the boolean properties show up fine in the designer properties but the icon property does not. This works in another tool I've used. Does Swing Designer only support basic types for custom properties and if so are there any plans to add support for more complex types?

Complex types are supported currently. The Designer build you are using supports custom Icon properties, but not ImageIcon properties. The latest v3.0.1 build will support either.

waldronk wrote:Also, is the ocean look and feel (and java 1.5) supported in the designer?

Theoretically, all Swing look and feels are supported, but I have not tried that one. Add it to the Designer > Swing > Look and Feel page and see if it works.
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

Postby Eric Clayberg » Mon Feb 21, 2005 9:47 am

Anonymous wrote:Since I haven't gotten a respone let me clarify my issue, which has changed slightly. I've created my own font class (MyFont) that wraps the the java.awt.font and provides an enumerated list of available fonts: FONT_A, FONT_B, FONT_C, etc.. I tried creating a PropertyEditor (MyFontEditor) so that the GUI designer can pick from a drop down list of our available fonts. I want to add this capability to all my custom widgets. I can get the property to show up in the swing builder 3.0.1 (though I had to specifically set the propertyeditor in the beaninfo) and it will generate the proper code but after i pick from the list it will not display my selection nor will it render the change (which might be related to the fact that the standalone font picker doesn't support the SansSerif font family we are using). Should this work?

Please send a complete, self-contained test case to wb-support@instantiations.com and we will take a look at it.
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