5

Is there an existing library that automatically creates a Java Swing form from a Properties (or Properties-like) object? i.e. shows 2 columns, as many rows as there are properties, properly justified Property names on the left, JTextFields for the values on the right.

I do not have access to the property names (or expected types) at compile time.

In addition, the solution must allow some value fields to be set read-only after construction.

A great solution would :

  • allow some property values to be specified as sensitive, requiring a JPasswordField
  • provide input format checking, e.g. against an object type (such as URL, Double, etc)

or by type-sensitive so that appropriate widgets (or buttons to bring up appropriate widgets) are used instead of JTextField for standard object types. e.g. JFileChooser for properties expected to be of a File type, SwingX Colour/Date selection, numerical format checking)

Getting into type-specific properties starts to sound like JavaBeans. I'd rather not go down the JavaBeans route unless there is a really easy - not a big framework - solution for this for an object that is a Javabean.

(I already know how to manually do this and could write a simple implementation myself that ignores sensitivity/type information - anyone answering along those lines will be shot down! I only want to know if such a beast already exists, preferably in a well maintained library)

UPDATE: related to Java Beans - creating an inspector window

Community
  • 1
  • 1
fommil
  • 5,757
  • 8
  • 41
  • 81

2 Answers2

0

No such thing exists. However, I wrote a rudimentary feature (and released it OSS) for https://github.com/fommil/zibaldone

fommil
  • 5,757
  • 8
  • 41
  • 81
-1

We use JIDE, which not open-source. If you don't mind that, take their Property Grid for a spin - it seem to match all your requirements.

enter image description here

Asaf
  • 2,480
  • 4
  • 25
  • 33
  • Thanks. I am looking for open source, but JIDE does look interesting. – fommil May 31 '12 at 20:29
  • never used it, but netbeans has something similar: http://platform.netbeans.org/tutorials/nbm-property-editors.html#creating-custom-editor – Asaf May 31 '12 at 20:32
  • I'd seen that but it seems to be part of the Netbeans Framework - not something that is readily accessible to a normal application. The documentation is woeful, but they do seem to be building on the [PropertyEditor](http://docs.oracle.com/javase/6/docs/api/java/beans/PropertyEditor.html) that comes with J2RE.In theory, a Swing form builder on top of that idea would probably help a lot, but in practice the documentation is dreadful. It also doesn't help that "property" is used in a countless number of different ways. – fommil May 31 '12 at 20:47
  • agree. from my perspective the real issue is the data binding for the various data types. If you have a small set of those types, and your data is well organized (i.e. you know it type easily), got ahead implement a `JTable` with custom renderers. – Asaf May 31 '12 at 20:54
  • In theory, a Swing form builder that takes in an arbitrary object and implements [java.beans.Customizer](http://docs.oracle.com/javase/6/docs/api/java/beans/Customizer.html) would help a lot: but everything is a bloody interface and there are no readily available implementations. Which would make an answer to http://stackoverflow.com/questions/1767008/java-beans-creating-an-inspector-window appropriate – fommil May 31 '12 at 20:58