Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.5, 1.8-beta-2
-
None
-
Patch
Description
Features in this patch:
- Definition of a columnModel in a table (important when using custom tableModel or glazedLists)
- Value of a column is used as identifier
- property width does not set the width, but minWidth, preferredWidth and maxWidth
if with is a Number:
set all three to this width to define it as fixed width
if with is a Collection with ...:
... 3 values: set min, preferred, max
... 2 values: set min, preferred
... 1 value : set preferred - columns may contain a cellRenderer, a headerRenderer and a cellEditor element
- cellRenderer, headerRenderer and cellEditor deliver the Component created by the default behaviour as rendercomponent if not specified
- cellRenderer and cellEditor now work for JTree aswell
Example:
new SwingBuilder.edt { frame(id: 'test', title: 'Frame', size: [300, 300], show: true) { borderLayout() def data = [ ['Chang', 'Peng', 30], ['John', 'Doe', 17], ['Hans', 'Meyer', 25]] as Object[][] scrollPane { table(new JTable(data, ['name', 'prename', 'age'] as Object[])) { columnModel { column('name', modelIndex: 0, headerValue: 'Lastname', width: [100, 150, 250]) { headerRenderer { onRender { children[0].text = value.toUpperCase() } } } column('prename', modelIndex: 1, headerValue: 'Prename', width: [100, 150]) { cellRenderer { label(foreground: java.awt.Color.RED) onRender { children[0].text = value } } } column('age', modelIndex: 2, headerValue: 'Age', width: 70) { cellEditor { prepareEditor { children[0].text = value*2 } getEditorValue { children[0].text.toInteger() } } } } } } } }