5 Widget Builders

This chapter covers each WidgetBuilder in detail. For an explanation of how WidgetBuilders fit into the overall architecture of Metawidget, see Chapter 2, Architecture

Throughout this chapter when we refer to, say, 'fields with a maximum value' this is a shorthand way of saying 'fields for which the inspectors returned a maximum-value attribute'. Quite which inspector returned the value, and based on what, is covered in Chapter 4, Inspectors: it could be based on a Hibernate Validator @Max annotation, or an intRange block in a Commons Validator XML file, or some other source.

5.1 Desktop Widget Builders

5.1.1 Swing Widget Builders

5.1.1.1 SwingWidgetBuilder

SwingWidgetBuilder is the default WidgetBuilder for SwingMetawidget. It instantiates the following widgets for the following types of fields:

Widget Type of field
javax.swing
JButton Actions (except read-only actions)
JCheckBox Primitive booleans and required Booleans
JComboBox Fields with lookups
JLabel Read-only fields (except Collections and masked fields)
JPanel Read-only masked fields
JPasswordField Masked fields (except when read-only)
JSlider Primitives (except boolean and char) that have both a minimum and a maximum value
JSpinner Primitives (except boolean and char) that have only one, or neither, of minimum/maximum value. For floats and doubles, the step size is governed by maximum-fractional-digits
JTextArea Large String fields. The JTextArea is automatically wrapped in a JScrollPane
JTextField Primitives (except booleans), Characters, Dates, Strings, and fields of unknown type
org.metawidget.swing
Stub Hidden fields, read-only actions and Collections

5.1.1.2 SwingXWidgetBuilder

SwingXWidgetBuilder is a pluggable WidgetBuilder for the SwingX library. It is intended to be used in conjunction with the default SwingWidgetBuilder. It instantiates the following widgets for the following types of fields:

Widget Type of field
org.jdesktop.swingx
JXDatePicker Dates