Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
The Sample Banner Example in Java 
 

Here, we will learn about making the banner in java applet. Simply the banner is used to advertising for any institution, shops and any organizations.

 

Java - The Sample Banner Example in Java

                         

Introduction

Here, we will learn about making the banner in java applet. Simply the banner is used to advertising for any institution, shops and any organizations. The advertising can be done by the different - different ways but the main aim is to popular our organization. For more popularity. But here, we will see what is a banner in the computer manner. As we know that the displaying detailed information in the graphics format on the page is known as banner. In other words, the banner is a collection of graphics and texts. With the help of banner we easily make to understand about the things.

In this program we will see how to display the banner in applet. This example has been used to display the simple text rotation in a rectangular area of the appropriate applet to understand that what is the banner and how to use that. There are four types of method have been used in this program these are explained below one by one : 

init() : 
This is the init() method which is the first method of the life cycle of an applet has been used to set the Background and Foreground colors of the banner.

start() : 
This is the start() method which is the second method of the life cycle of an applet has been used to create and start a thread.

run() : 
This is the run() method which has been used to set the time interval for the created thread. That means the rotation of text to be rotate on how much time.

paint() : 
And finally this is the paint() method which has been used to draw the rectangle, set it's color and display the moving text in the appropriate rectangle. 

Here is the Java code:

import java.awt.*;
import java.applet.*;

public class SampleBanner extends Applet implements Runnable{
  String str = "This is a simple Banner developed by Roseindia.net. ";
  Thread t ;
  boolean b;
  public void init() {
    setBackground(Color.gray);
    setForeground(Color.yellow);
  }

  public void start() {
    t = new Thread(this);
    b = false;
    t.start();
  }

  public void run () {
    char ch;
    for; ; ) {
      try {
        repaint();
        Thread.sleep(250);
        ch = str.charAt(0);
        str = str.substring(1, str.length());
        str = str + ch;
        catch(InterruptedException e) {}
    }
  }
  public void paint(Graphics g) {
    g.drawRect(1,1,300,150);
    g.setColor(Color.yellow);
    g.fillRect(1,1,300,150);
    g.setColor(Color.red);
    g.drawString(str, 1150);
  }
}

Here is the HTML code:

<HTML>
<BODY>
<APPLET CODE = "SampleBanner" WIDTH = "500" HEIGHT = "300"></APPLET>
</BODY>
</HTML>

Try online this example.

Download the Java Code

                         

» View all related tutorials
Related Tags: html c com orm air tags sed char tag rounding ai element tar character elements characters like start call cte

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.