SwingBuilder中使用Jtable,例2

import groovy.swing.SwingBuilder
def data =[
	[nick: 'MrG', full: 'Guillaume Laforge'],
	[nick: 'jez', full: 'Jeremy Rayner'],
	[nick: 'fraz', full: 'Franck Rasolo'],
	[nick: 'sormuras', full: 'Christian Stein'],
	[nick: 'blackdrag', full: 'Jochen Theodorou'],
	[nick: 'Mittie', full: 'Dierk Koenig']
]
def swing = new SwingBuilder()
def frame = swing.frame(title: 'Table Demo') {
	scrollPane {
		tab=table {
			model=tableModel(list: data) {
				propertyColumn(header: 'Nickname', propertyName: 'nick');
				propertyColumn(header: 'Full Name', propertyName: 'full');
			}
		}
	}
}
frame.pack()
frame.show()

//model.getRows().add([nick:'李',full:'李某某']);
model.rows.add([nick:'李',full:'李某某']);
tab.updateUI();
 

你可能感兴趣的:(swing,groovy)