Java Applets: Using Status Bar

You can display a short message on the status bar of the window using the showstatus() method. Consider the following applet:

//Status.java

public class Status extends java.applet.Applet

{

public void paint(java.awt.Graphics g)

{

setBackground(java.awt.Color.gray);

g.drawString(“This is in the applet window”, 20, 30);

showStatus(“This is shown in the status bar”);

}

}

Now, create an HTML document containing an <appiet> tag as follows:

<applet code=”status” width=”300” height=”50”>

</applet>

Alternatively, you can embed in the file Status.java as explained previously. Now run appletviewer specifying the file name containing the applet as an argument. A sample result is shown in Figure 16.13:

Source: Uttam Kumar Roy (2015), Advanced Java programming, Oxford University Press.

Leave a Reply

Your email address will not be published. Required fields are marked *