Failed to load /WEB-INF/template/template_widget_demo.zul

Cause: Sourced file: inline evaluation of: ``                   		import java.awt.*; 		import java.awt.image.*; 		import java . . . '' unknown error: Unable to make public void sun.java2d.SunGraphics2D.setStroke(java.awt.Stroke) accessible: module java.desktop does not "exports sun.java2d" to unnamed module @a7e140b : at Line: 42 : in file: inline evaluation of: ``                   		import java.awt.*; 		import java.awt.image.*; 		import java . . . '' : BufferedImage bufferimg = newimg ( false ) 

Called from method: newimg : at Line: 42 : in file: inline evaluation of: ``                   		import java.awt.*; 		import java.awt.image.*; 		import java . . . '' : newimg ( false ) 
org.zkoss.zk.ui.UiException: Sourced file: inline evaluation of: ``                   		import java.awt.*; 		import java.awt.image.*; 		import java . . . '' unknown error: Unable to make public void sun.java2d.SunGraphics2D.setStroke(java.awt.Stroke) accessible: module java.desktop does not "exports sun.java2d" to unnamed module @a7e140b : at Line: 42 : in file: inline evaluation of: ``                   		import java.awt.*; 		import java.awt.image.*; 		import java . . . '' : BufferedImage bufferimg = newimg ( false ) 

Called from method: newimg : at Line: 42 : in file: inline evaluation of: ``                   		import java.awt.*; 		import java.awt.image.*; 		import java . . . '' : newimg ( false ) 
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	at org.zkoss.lang.Classes.newInstance(Classes.java:77)
	at org.zkoss.lang.Exceptions.wrap(Exceptions.java:164)
	at org.zkoss.zk.ui.UiException$Aide.wrap(UiException.java:51)
	at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:136)
	at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:343)
	at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:969)
...
Description & Source Code

The image component can either display an image file given its path or an image rendered dynamically using Java's graphical APIs.

dynamic_image.zul
<window border="normal" width="500px">
	<hlayout>
		<vlayout>
			<button label="Switch Image">
				<attribute name="onClick"><![CDATA[
					image.setContent(new org.zkoss.image.AImage("t", 
						desktop.webApp.getResourceAsStream((odd = !odd) ? 
							"/widgets/multimedia/dynamic_image/img/image2.png" : 
							"/widgets/multimedia/dynamic_image/img/image1.png")));				
				]]></attribute>
			</button>
			<image id="image" src="/widgets/multimedia/dynamic_image/img/image1.png" />
		</vlayout>
		<vlayout>
			<button label="Render Image" onClick="update()" />
			<image id="img" />
		</vlayout>
	</hlayout>
	<zscript><![CDATA[
		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 = update ? new Line2D.Double(10, 10, 130, 130) : new Line2D.Double(10, 130, 130, 10);
			Rectangle2D 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>