• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Design an applet that displays the string “Hello College Name” moving from left to right. When it reaches to right, it scrolls back to left.

July 1, 2012 by ProjectsGeek Leave a Comment

Assignment No 03


AIM:


A) Design an applet that displays the string “Hello AIT” moving from left to right. When it reaches to right, it scrolls back to left.


B) Design an applet that displays circle which grows outwards  (up to certain value) and finally it reduces to 0.


THEORY:


The abstract Windowing toolkit(AWT) is an API that is responsible for building the GUI. It is a part of JFC. Java programs are classified into two groups namely applications and applets. An applet is a dynamic and interactive program that can run inside a web page displayed by Java capable browser. This can be also executed using applet viewer application.

Some of the important tags used inside an applet .html file are


Major Applet activities are :


init() method gets called as soon as applet is started. Initialization of all variables, creation of objects, setting of parameters can be done in this method.  start() method is executed  after the init() method where the applet is started. stop() method is used to halt the running of an applet. destroy() method is used to free the memory occupied by the variables and objects initialized in the applet. Any cleaning up activity that needs to be performed can be done in this method. paint() method helps in drawing, writing and creating a colored background or an image onto the applet. It takes an argument, which is an instance of Graphics class. repaint() method is used in case an applet is to be repainted. The repaint() calls the update() method to clear the screen of any existing contents. The update() method in turn calls paint() method that then draws the contents of the current frame.


Methods in Graphics class are


g.drawBytes(byte[ ] data, int offset, int length, int x, int y)

g.drawChars(char[ ] data, int offset, int length, int x, int y)

g.drawString(String str, int x, int y)

g.drawLine( int x1, int y1, int x2, int y2)

g.drawRect( int x1, int y2, int width, int height)

g.fillRect( int x1, int y2, int width, int height)

g.drawRoundRect( int x1, int y2, int width, int height, int width1, int height1)

g.fillRoundRect( int x1, int y2, int width, int height, int width1, int height1)

g.drawOval( int x1, int y2, int width, int height)

g.fillOval( int x1, int y2, int width, int height)

g.draw3DRect( int x1, int y2, int width, int height, true/false)

g.drawPolygon( int xs[ ], int ys [ ] )

g.fillPolygon( int xs[ ], int ys [ ] )

g.drawArc(int x1, int y1, int width, int height, angle1, angle2)

g.fillArc(int x1, int y1, int width, int height, angle1, angle2)

g.drawImage(image img, int x, int y, int width, int height,  imageObserver)


Font class represents Fonts. Text can be written inside an applet using different fonts.

Constructor:

          Font f = new Font (string name, int style, int size);


Name: The logical name of the font.

Style: The style of the font as Font.BOLD, Font.ITALIC, Font.PLAIN

Size: The size of the font

For setting the font setFont(f) method present in a graphics class can be used.


Color class represents color. Color is represented as a combination of red, blue and green. Each component can have a number between 0 and 255. 0,0,0 is black and 255,255,255 is white.

Constructor:         

Color c = new Color(0,0,0);

Method:      

                   g.setColor( c)                 //can be used present in Graphics class.


Animation is the technique by which an object is moved on the screen. The object to be moved can be simple drawing or a complex image loaded from an image file. This object, in animation region is called a frame of animation.


CONCLUSION


Both applets are successfully implemented. 


PROGRAM CODE


import java.awt.*;
import java.applet.Applet;
public classmovingBall extends Applet implements Runnable {
Thread mythread = null;
int position =0;

public void start( )
{
mythread =new mythread (this); // this refers to current object
mythread.start( );
}

public void run( )
{
while(true)
{
for(position=o; position {
repaint();
try{ mythread.sleep(100); }
catch(InterruptedException e) { };
}
}
}

public void stop( )
{
mythread.stop( );
mythread=null;
}

public void paint(graphics g)
{
g.setColor(Color.gray);
g.fillOval(position,50,30,30);
g.setColor(Color.black);
g.fillOval(position+6,58,5,5);
g.drawLine(position,58,10,12);
}
}


Design an applet that displays the string “Hello College Name” moving from left to right. When it reaches to right, it scrolls back to left. 3

Download Code Here

Other Projects to Try:

  1. Java Applet Tutorial for Beginners
  2. Communication between applet and servlet Java Code
  3. How to convert String to int using Java
  4. To Perform various String Operation in Java
  5. Moving Balls mini project using Java Applet

Filed Under: Java Assignments

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy