import groovy.swing.SwingBuilder
import static java.awt.BorderLayout.*
import java.awt.event.*
// set up variables
count = 0
def textlabel
def text = "Actions: "
def update = { c ->
text += c
textlabel.text = text
}
// create the listener
def closureMap = [
mousePressed: { update 'M' },
keyPressed: { update 'K' },
focusLost: { update 'F' },
windowIconified: { update 'W' }
]
def interfaces = [WindowListener, KeyListener, MouseListener, FocusListener]
def listener = ProxyGenerator.instantiateAggregate(closureMap, interfaces)
// now the GUI
def swing = new SwingBuilder()
def frame = swing.frame(title:'Frame') {
borderLayout()
textlabel = label(text:text, constraints: NORTH)
button = button(text:'Click Me', constraints: SOUTH)
}
frame.addWindowListener listener
['Key', 'Mouse', 'Focus'].each {
button."add${it}Listener" listener
textlabel."add${it}Listener" listener
}
frame.pack()
frame.show()
| Brush name | Brush aliases | File name |
|---|
| ActionScript3 | as3, actionscript3 | shBrushAS3.js |
| Bash/shell | bash, shell | shBrushBash.js |
| ColdFusion | cf, coldfusion | shBrushColdFusion.js |
| C# | c-sharp, csharp | shBrushCSharp.js |
| C++ | cpp, c | shBrushCpp.js |
| CSS | css | shBrushCss.js |
| Delphi | delphi, pas, pascal | shBrushDelphi.js |
| Diff | diff, patch | shBrushDiff.js |
| Erlang | erl, erlang | shBrushErlang.js |
| Groovy | groovy | shBrushGroovy.js |
| JavaScript | js, jscript, javascript | shBrushJScript.js |
| Java | java | shBrushJava.js |
| JavaFX | jfx, javafx | shBrushJavaFX.js |
| Perl | perl, pl | shBrushPerl.js |
| PHP | php | shBrushPhp.js |
| Plain Text | plain, text | shBrushPlain.js |
| PowerShell | ps, powershell | shBrushPowerShell.js |
| Python | py, python | shBrushPython.js |
| Ruby | rails, ror, ruby | shBrushRuby.js |
| Scala | scala | shBrushScala.js |
| SQL | sql | shBrushSql.js |
| Visual Basic | vb, vbnet | shBrushVb.js |
| XML | xml, xhtml, xslt, html, xhtml | shBrushXml.js |
SyntaxHighlighter was originally created in 2004 and is still maintained by Alex Gorbatchev.
Copyright 2004-2011 Alex Gorbatchev.