Simple dialog with groovy
Code: "gui_dialog.groovy". Programming language: Groovy DMelt Version 1. Last modified: 12/12/2015. License: Pro
https://datamelt.org/code/cache/gui_dialog_317.groovy
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



import groovy.swing.SwingBuilder
import javax.swing.JFrame
import groovy.swing.factory.SwingBorderFactory
 
sb = new SwingBuilder()
 
def dialog(event){
dialog = sb.dialog(title: 'Entry')
def panel = sb.panel{
vbox {
hbox{
label(text: 'Name ')
textField(columns: 20, id: 'name')
}
hbox{
label(text: 'Password ')
passwordField(columns: 20, id: 'password')
}
hbox{
button('OK') // add actionPerformed:
button('Cancel')
}
}
}
dialog.getContentPane().add(panel)
dialog.pack()
dialog.show()
}
 
 
new SwingBuilder().frame( title: "TEST",defaultCloseOperation: JFrame.EXIT_ON_CLOSE, pack: true, show: true ){
panel{
button(actionPerformed: this.&dialog, "Click")
}
}

Ads help maintain this website.