Source :
<?xml version="1.0" encoding="UTF-8"?>
<zk>
<!--Upload-->
<button label="Upload" upload="true">
<attribute name="onUpload">{
org.zkoss.util.media.Media media = event.getMedia();
if (media instanceof org.zkoss.image.Image) {
org.zkoss.zul.Image image = new org.zkoss.zul.Image();
image.setContent(media);
image.setParent(pics);
} else {
Messagebox.show("Not an image: "+media, "Error", Messagebox.OK, Messagebox.ERROR);
break; //not to show too many errors
}
}</attribute>
</button>
<vbox id="pics" > </vbox>
<!--Download-->
<button label="Download sun.jpg">
<attribute name="onClick">
Filedownload.save("/home/aerdy/a.png", null);
</attribute>
</button>
<!--Timer-->
<label id="now" />
<timer id="timer" delay="1000" repeats="true">
<attribute name="onTimer">
now.setValue(new Date().toString());
pm.value = pm.value == 100 ? 0 : pm.value + 10;
</attribute>
</timer>
<separator bar="true" />
<progressmeter id="pm" value="0" />
<separator bar="true" />
<button label="Stops timer" onClick="timer.stop()" />
<button label="Starts timer" onClick="timer.start()" />
<!-- Menjalankan FLash-->
<zk>
<flash src="http://www.zkoss.org/resource/file/product/zkstudio/zkstudio.swf"
height="300" width="800">
</flash>
</zk>
<!--AUDIO DAn VIDEO-->
<zk>
<audio id="audio" height="40" />
<separator />
<fileupload id="fileupload" label="Upload">
<attribute name="onUpload">
Object media = event.getMedia();
</attribute>
</fileupload>
<separator />
<button label="Play">
<attribute name="onClick">{
import org.zkoss.util.media.Media;
try{
if (media instanceof org.zkoss.sound.Audio)
audio.setContent(media);
else if (media != null)
Messagebox.show("Not an audio: "+media, "Error", Messagebox.OK, Messagebox.ERROR);
}catch(e){}
audio.play();
}
</attribute>
</button>
<button label="Stop" onClick="audio.stop()" />
</zk>
<!-- DINAMIC IMAGES -->
<zk>
<hbox>
<window title="Label and Image" border="normal" width="300px">
<image src="/img/Centigrade-Widget-Icons/Globe-128x128.png"/>
<separator/>
Do you like the photo?
<label id="label"/>
<hbox>
<button label="Yes" onClick="label.value = self.label"/>
<button label="No" onClick="label.value = self.label"/>
</hbox>
</window>
<window title="Dynamic Image" border="normal" width="300px">
Click the button to Change Image
<hbox>
<vbox>
<button label="Change Resource">
<attribute name="onClick">
image.setContent(new org.zkoss.image.AImage("t", desktop.webApp.getResourceAsStream((odd = !odd) ? "/img/msn2.gif" : "/img/msn1.gif")));
</attribute>
</button>
<image id="image" src="/img/msn1.gif" />
</vbox>
<vbox>
<button label="Dynamic Render" onClick="update()" />
<image id="img" />
</vbox>
</hbox>
<zscript>
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.*;
boolean odd = false;
boolean odd1 = false;
void update() {
BufferedImage bufferimg = newimg((odd1 = !odd1));
img.setContent(bufferimg);
}
BufferedImage newimg(boolean update) {
BufferedImage bi = new BufferedImage(150, 150, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();
g2d.setStroke(new BasicStroke(5));
Line2D line = null; Rectangle2D retangle = null ;
if (update) {
line = new Line2D.Double(10, 10, 130, 130);
retangle = new Rectangle2D.Double(25,25,85,85);
}else {
line = new Line2D.Double(10, 130, 130, 10);
retangle = new Rectangle2D.Double(25,25,85,85);
}
g2d.setColor(update ? Color.cyan : Color.RED);
g2d.draw(line);
g2d.setColor(update ? Color.yellow : Color.pink);
g2d.draw(retangle);
return bi;
}
BufferedImage bufferimg = newimg(false);
img.setContent(bufferimg);
</zscript>
</window>
</hbox>
</zk>
</zk>
Hasil :