in src/main/groovy/groovy/swing/SwingDemo.groovy [36:99]
void run() {
def frame = swing.frame(
title:'This is a Frame',
location:[100,100],
size:[800,400],
defaultCloseOperation:javax.swing.WindowConstants.EXIT_ON_CLOSE) {
menuBar {
menu(text:'File') {
menuItem() {
action(name:'New', closure:{ println("clicked on the new menu item!") })
}
menuItem() {
action(name:'Open', closure:{ println("clicked on the open menu item!") })
}
separator()
menuItem() {
action(name:'Save', enabled:false, closure:{ println("clicked on the Save menu item!") })
}
}
menu(text:'Demos') {
menuItem() {
action(name:'Simple TableModel Demo', closure:{ showGroovyTableDemo() })
}
menuItem() {
action(name:'MVC Demo', closure:{ showMVCDemo() })
}
menuItem() {
action(name:'TableLayout Demo', closure:{ showTableLayoutDemo() })
}
}
menu(text:'Help') {
menuItem() {
action(name:'About', closure:{ showAbout() })
}
}
}
splitPane {
panel(border:BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), 'titled border')) {
borderLayout()
vbox(constraints:NORTH) {
panel {
borderLayout()
label(text:'Name', constraints:WEST, toolTipText:'This is the name field')
textField(text:'James', constraints:CENTER, toolTipText:'Enter the name into this field')
}
panel {
borderLayout()
label(text:'Location', constraints:WEST, toolTipText:'This is the location field')
comboBox(items:['Atlanta', 'London', 'New York'], constraints:CENTER, toolTipText:'Choose the location into this field')
}
button(text:'Click Me', actionPerformed:{event -> println("closure fired with event: " + event) })
}
scrollPane(constraints:CENTER, border:BorderFactory.createRaisedBevelBorder()) {
textArea(text:'Some text goes here', toolTipText:'This is a large text area to type in text')
}
}
scrollPane {
table(model:new MyTableModel())
}
}
}
frame.show()
}