Revision: 2508
Updated Code
at March 8, 2007 13:37 by dima767
Updated Code
// copyright Dierk Koenig 2006
import groovy.swing.SwingBuilder
import javax.swing.*
key = 'your-flickr-key-here'
counter = 1
def updateButton(button) {
counter++
def apiUrl = "http://www.flickr.com/services/rest/?" +
"method=flickr.interestingness.getList&per_page=1&" +
"page=$counter&api_key=$key"
def rsp = new XmlParser().parse(apiUrl)
def photo = rsp.photos.photo[0]
def imageUrl = "http://static.flickr.com/" +
"${photo.'@server'}/${photo.'@id'}_${photo.'@secret'}_m.jpg"
button.icon = new ImageIcon(imageUrl.toURL())
button.text = photo.'@title'
return button
}
def frame = new SwingBuilder().frame(
title: 'Groovy Flickr Viewer',
defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE) {
updateButton( button (
horizontalTextPosition: SwingConstants.CENTER,
verticalTextPosition: SwingConstants.BOTTOM,
actionPerformed: { updateButton(it.source) }
))
}
frame.pack()
frame.show()
Revision: 2507
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 8, 2007 13:36 by dima767
Initial Code
import groovy.swing.SwingBuilder
import javax.swing.*
key = 'your-flickr-key-here'
counter = 1
def updateButton(button) {
counter++
def apiUrl = "http://www.flickr.com/services/rest/?" +
"method=flickr.interestingness.getList&per_page=1&" +
"page=$counter&api_key=$key"
def rsp = new XmlParser().parse(apiUrl)
def photo = rsp.photos.photo[0]
def imageUrl = "http://static.flickr.com/" +
"${photo.'@server'}/${photo.'@id'}_${photo.'@secret'}_m.jpg"
button.icon = new ImageIcon(imageUrl.toURL())
button.text = photo.'@title'
return button
}
def frame = new SwingBuilder().frame(
title: 'Groovy Flickr Viewer',
defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE) {
updateButton( button (
horizontalTextPosition: SwingConstants.CENTER,
verticalTextPosition: SwingConstants.BOTTOM,
actionPerformed: { updateButton(it.source) }
))
}
frame.pack()
frame.show()
Initial URL
Initial Description
Initial Title
Groovy Swing builder Flickr example
Initial Tags
groovy
Initial Language
Groovy