-
-
Save mresetar/962501 to your computer and use it in GitHub Desktop.
UUID generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.swing.SwingBuilder | |
import java.awt.BorderLayout as BL | |
import java.awt.datatransfer.Clipboard | |
import java.awt.datatransfer.StringSelection | |
import java.awt.Toolkit | |
import javax.swing.* | |
class UUIDgenerator { | |
def readIcon() { | |
byte[] iconBytes = new byte[990] | |
def stream = this.getClass().getClassLoader().getResourceAsStream('barcode.gif') | |
assert stream : 'Icon not found!' | |
// read icon | |
stream.read(iconBytes) | |
def imageIcon = new ImageIcon(iconBytes) | |
} | |
def start() { | |
def icon = readIcon().image | |
def window = SwingBuilder.build { | |
frame(title:'UUID generator', size:[300,250], location:[300,300], pack: true, show: true, defaultCloseOperation:JFrame.EXIT_ON_CLOSE, iconImage:icon, resizable: false) { | |
borderLayout() | |
scrollPane(constraints: BL.NORTH) { | |
textlabel = textArea(rows:10,columns:40,text:"", autoscrolls:true) | |
} | |
button(text:'Generate', | |
actionPerformed: {String uuid = UUID.randomUUID().toString(); | |
textlabel.text+=uuid + '\n'; | |
StringSelection stringSelection = new StringSelection( uuid ); | |
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); | |
clipboard.setContents( stringSelection, null );}, | |
constraints:BL.SOUTH) | |
} | |
} | |
} | |
public static void main(String[] args){ | |
new UUIDgenerator().start() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment