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()
<html>
<body>
<div style="font-weight: bold"><?= str_replace("\n", "<br/>", $var) ?></div>
<?
/***********************************
** Multiline block comments
**********************************/
$stringWithUrl = "http://alexgorbatchev.com";
$stringWithUrl = 'http://alexgorbatchev.com';
ob_start("parseOutputBuffer"); // Start Code Buffering
session_start();
?>
</body>
</html>
<html>
<body>
<div style="font-weight: bold"><?= str_replace("\n", "<br/>", $var) ?></div>
<?
/***********************************
** Multiline block comments
**********************************/
$stringWithUrl = "http://alexgorbatchev.com";
$stringWithUrl = 'http://alexgorbatchev.com';
ob_start("parseOutputBuffer"); // Start Code Buffering
session_start();
?>
</body>
</html>
留言
張貼留言