|
Groovy example source code file (ModelNodeExample.groovy)
The Groovy ModelNodeExample.groovy source codeimport groovy.swing.SwingBuilder import static javax.swing.WindowConstants.* import static java.awt.GridBagConstraints.* def bean = new ObservableMap([name:'Alice', phone:'719-555-1212', addr:'42 Other Way']) SwingBuilder.build { frame = frame( pack:true, show:true, defaultCloseOperation:DISPOSE_ON_CLOSE) { beanModel = model(bean, bind:false) gridBagLayout() label('Name:', constraints:gbc(insets:[6,6,3,3])) textField(text:beanModel.name, columns:20, gridwidth:REMAINDER, fill:HORIZONTAL, weightx:1, insets:[6,3,3,6]) label('Phone:', constraints:gbc(insets:[3,6,3,3])) textField(text:beanModel.phone, columns:20, gridwidth:REMAINDER, fill:HORIZONTAL, weightx:1, insets:[3,3,3,6]) label('Address:', constraints:gbc(insets:[3,6,3,3])) textField(text:beanModel.addr, columns:20, gridwidth:REMAINDER, fill:HORIZONTAL, weightx:1, insets:[3,3,3,6]) button('Reset', actionPerformed:{beanModel.update()}, constraints:gbc(gridwidth:2, anchor:EAST, weightx:1, insets:[9,0,0,6])) button('Submit', insets:[9,0,0,0], actionPerformed: { beanModel.reverseUpdate() output.text = ("name = '$bean.name'\nphone = '$bean.phone'\naddr = '$bean.addr'\n\n") }) separator(gridwidth:REMAINDER, fill:HORIZONTAL, insets:[3,6,3,6]) label('Output:', gridwidth:REMAINDER, anchor:WEST, insets:[3,6,3,6]) scrollPane(preferredSize:[100, 100], gridwidth:REMAINDER, fill:BOTH, weighty:1, insets:[3,6,6,6]) { output = textArea() } } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy ModelNodeExample.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.