Set Status Message in Applet Window Example

In addition to displaying information in its window ,an applet can also output a message to the status window of the browser or applet viewer on which it is running to do so ,call showStatus() with the string that you want displayed.Th status window is a good place to give the user feedback about what is occurring in the applet,suggest options ,or possibly report some types of errors .The status window also make an excellent debugging aid because it gives you an easy way to output information about your applet

Sample program  SetStatusMessageExample.java

import java.applet.Applet;
import java.awt.Graphics;

 /*
<applet code="SetStatusMessageExample" width=200 height=200>
</applet>
*/

public class SetStatusMessageExample extends Applet
{

        public void paint(Graphics g)
         {
                /*
                 * Show status message in an Applet window using
                 * void showStatus(String msg) method of an applet class.
                 */
             
                //this will be displayed inside an applet
                g.drawString("Show Status Example", 50, 50);
             
                //this will be displayed in a status bar of an applet window
                showStatus("This is a status message of an applet window");
        }
}
Output 
Set Status Message in Applet Window Example



0 comments:

Post a Comment

 

learn java programming Copyright © 2011-2012 | Powered by appsackel.org