Skip to content

Instantly share code, notes, and snippets.

@kellyrob99
Created September 10, 2009 03:46
Show Gist options
  • Save kellyrob99/184277 to your computer and use it in GitHub Desktop.
Save kellyrob99/184277 to your computer and use it in GitHub Desktop.
import org.jdesktop.swingx.JXTable
import javax.swing.*
@Grab(group='org.swinglabs', module='swingx', version='0.9.3')
@Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='0.9.7')
def getHtml(url) {
def parser = new XmlParser(new org.ccil.cowan.tagsoup.Parser())
parser.parse(url)
}
def data = [ ]
def my = groovy.swing.SwingBuilder.build {
frame = frame(title:'Groovy Grab Test', size:[800,500], show:true, pack:true, defaultCloseOperation: WindowConstants.DISPOSE_ON_CLOSE) {
actions(){
action(name:'Fetch', id:'fetchAction')
{
data.clear
getHtml(urlField.text).body.'**'.a.@href.each{ data << [url:it] }
frame.repaint()
}
}
boxLayout(axis: BoxLayout.Y_AXIS)
scrollPane() {
myTable = table(new JXTable(columnControlVisible:true)){
tableModel(list:data){
propertyColumn(header: 'URL', propertyName: 'url')
}
}
}
textField(id:'urlField')
button(fetchAction)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment