Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.5, 1.8-beta-2
-
Fix Version/s: 1.7.6, 1.8-beta-3
-
Component/s: Swing
-
Labels:None
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
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() }
}
}
}
}
}
}
}
Activity
Roshan Dawrani
made changes -
| Field | Original Value | New Value |
|---|---|---|
| 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() } } } } } } } } |
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: {code} 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() } } } } } } } } {code} |
blackdrag blackdrag
made changes -
| Assignee | Hamlet D'Arcy [ hamletdrc ] |
Alexander Klein
made changes -
| Attachment | ColumnModel_Column_CellRenderer_CellEditor_edited.patch [ 51642 ] |
Hamlet D'Arcy
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Added code tags.