APPLET / CATATAN</>↗Applet10 Apr 2010
To display an image in an applet we first need to obtain the image object itself. A call to applet’s getImage(URL url, String name) method help us to create an image object from the specified URL of the image. For displaying the image on the applet’s screen we draw it in the paint() method using […]
APPLET / CATATAN</>↗Applet05 Apr 2010
The code snippet below show you how to get the URL of the document (HTML, JSP, etc.) where the Applet is embedded. To obtain this document URL we use the getDocumentBase() method call provided by the Applet class. In the paint() method below we use the getDocumentBase() to create a URL as a link to […]
APPLET / CATATAN</>↗Applet26 Mei 2007
In this applet example you’ll see how to display a message in browser status bar. To make the example a bit more interesting we’ll display the current time as the message. The time will be updated every on second during the lifetime of the applet. package org.kodejava.applet; import java.applet.Applet; import java.awt.Graphics; import java.text.DateFormat; import java.text.SimpleDateFormat; […]
APPLET / CATATAN</>↗Applet07 Apr 2007
By default, the applet will usually have a grey background when displayed in a web browser. If you want to change it then you can call the setBackground(java.awt.Color) method and choose the color you want. Defining the background color in the init() method will change the color as soon as the applet initialized. package org.kodejava.applet; […]
APPLET / CATATAN</>↗Applet22 Mar 2007
package org.kodejava.applet; import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class AppletParameterExample extends Applet { private String name = ""; public void init() { // Here we read a parameter named name from the applet tag definition // in our html file. name = getParameter("name"); } public void paint(Graphics g) { g.setColor(Color.BLUE); g.drawString("Hello " + name […]
APPLET / CATATAN</>↗Applet20 Jan 2007
The code below demonstrate the very basic of Java applet. Applet is a small Java application that can be embedded on the web browser. package org.kodejava.applet; import java.applet.*; import java.awt.*; public class HelloWorldApplet extends Applet { public void init() { } public void start() { } public void stop() { } public void destroy() { […]