Java Applet

  Home  Java Programing  Java Applet


“Java Applet Programming Interview Questions and Answers will guide us now that a Java applet is an applet delivered to the users in the form of Java bytecode. Java applets can run in a Web browser using a Java Virtual Machine (JVM), or in Sun's AppletViewer, a stand-alone tool for testing applets. Learn Java Applet Programming or get preparation of Java Applet by the help of this Java Applet Programming Interview Questions with Answers guide”



26 Java Applet Questions And Answers

21⟩ What is AppletStub Interface?

The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface.

 155 views

22⟩ Can applets on different pages communicate with each other?

Use the getSize() method, which the Applet class inherits from the Component class in the Java.awt package. The getSize() method returns the size of the applet as a Dimension object, from which you extract separate width, height fields. The following code snippet explains this:

Dimension dim = getSize();

int appletwidth = dim.width();

int appletheight = dim.height();

 144 views

24⟩ How do I select a URL from my Applet and send the browser to that page?

Ask the applet for its applet context and invoke showDocument() on that context object.

URL targetURL;

String URLString

AppletContext context = getAppletContext();

try

{

targetURL = new URL(URLString);

}

catch (MalformedURLException e)

{

// Code for recover from the exception

}

context. showDocument (targetURL);

 160 views

25⟩ Why do you Canvas?

The Canvas class of java.awt is used to provide custom drawing and event handling. It provides a general GUI component for drawing images and text on the screen. It does not support any drawing methods of its own, but provides access to a Graphics object through its paint() method. The paint() method is invoked upon the creation and update of a canvas so that the Graphics object associated with a Canvas object can be updated.

 156 views