Menu

[r313]: / trunk / php-java-bridge / tests.php4 / swt.php  Maximize  Restore  History

Download this file

42 lines (34 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/php
<?php
if(!extension_loaded('java')) {
dl('java.' . PHP_SHLIB_SUFFIX);
}
class SelectionImpl {
var $shell;
function SelectionImpl($shell) {
$this->shell = $shell;
}
function widgetSelected($arg) { $this->message($arg); }
function widgetDefaultSelected($arg) { echo "widget default selected \n"; }
function message($e) {
$mb = new java("org.eclipse.swt.widgets.MessageBox", $this->shell);
$mb->setMessage("Thank you.");
$mb->open();
}
}
$SWT = new JavaClass("org.eclipse.swt.SWT");
$display = new java("org.eclipse.swt.widgets.Display");
$shell = new java("org.eclipse.swt.widgets.Shell");
$shell->setSize(320, 200);
$shell->setLayout(new java("org.eclipse.swt.layout.FillLayout"));
$button = new java("org.eclipse.swt.widgets.Button", $shell, $SWT->PUSH);
$button->setText("Click here.");
$button->addSelectionListener(java_closure(new SelectionImpl($shell)));
$shell->open();
while (!$shell->isDisposed()) {
if (!$display->readAndDispatch()) {
$display->sleep();
}
}
$display->dispose();
?>