Jprlastyrp

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

Teacher Evaluation Sheet

Name of Student: Thorat Akshada Dattatray


Enrolment No: 23651020421
Name of Program: Computer Technology Semester:- V
Course Title: Advance Java Programming Code: -22517
Title of the Micro Project: Exploring BorderLayout and FlowLayout
Course Outcomes Achieved:-
a) Develop programs using GUI Framework (AWT and Swing).
b) Handle events of AWT and Swings components.
c) Develop programs to handle events in Java Programming.
d) Develop Java programs using networking concepts.
e) Develop programs using database.
f) Develop programs using Servlets.

Evaluation as per Suggested Rubric for Assessment of Micro-Project:

Sr.
Characteristic to be Poor Average Good Excellent
No.
assessed (Marks 1-3) (Marks 4-5) (Marks 6 - 8) (Marks 9-10)
(A) Process and Product Assesssment (Convert above total marks out of 6 marks)
1 Relevance to the Course
Literature Survey /
2
Information Collection
Completion of the Target as
3
per project proposal
Analysis of data and
4
representation
5 Quality of Prototype / Model
6 Report Preparation
(B) Individual Presentation / Viva (Convert above total marks out of 4 marks)
8 Presentation
9 Viva
Micro – Project Evaluation Sheet:
Process Assessment Product Assessment
Part Project Part Individual Total
A – project Methodology B – Project Presentation / Marks 10
Name of Student Proposal (2 marks) Report / Working Viva (4 marks)
(2 marks) Model(2 marks)

Thorat Akshada Dattatray


Comments / Suggestions about team work / leadership / inter – personal communication (if any)

Any Other Comment

Name and designation of the faculty Member: Mr.P.G.Aher Signature

1
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION

SHRI H. H. J. B POLYTECHNIC,
CHANDWAD-423101 (Nashik)

MICRO PROJECT
Academic year 2024-25

TITLE OF PROJECT
Exploring BorderLayout and FlowLayout

Program: Computer Technology Program

Code:CM Course: Advance Java Programming Course

code:22517

3
MAHARASHTRA STATE BOARD OF TECHNICALEDUCATION

Sr.No. Name of Student Roll No Enrollment No Seat No


1. Thorat Akshada D. 55 23651020421

CERTIFICATE
This is to certify that :

Ms. Thorat Akshada Dattatray

Of 4thSemester of Diploma in Computer Technology of Institute, SHHJB


POLYTECHNIC, CHANDWAD (Code: 0079) has completed the Micro-Project
satisfactorily in Subject Advance Java Programming (22517) for the academic year 2024- 2025
as prescribed in the curriculum.

Place: CHANDWAD

Date: / /2024

Subject Teacher Head of the Department Principal


(Mr.P.G.Aher) (Mr.P.R.Sali) (Dr.V.A.Wankhede)

4
INDEX

SR_NO. CONTENT PAGE NO.


Part A

1.0 Brief Introduction

2.0 Aim of Micro Project

3.0 Action Plan

4.0 Resources Required

Part B

1.0 Aim of Micro Project

2.0 Course Outcome Integrated

3.0 Brief Description

4.0 Actual Procedure Followed

5.0 Actual Resource Used

6.0 Outputs of the Micro-projects

7.0 Skill Developed

8.0 Applications of this Microproject

5
PART A-Plan
Title of micro-project: Exploring BorderLayout and FlowLayout

1.0 Brief Introduction-

Although somewhat surprisingly, the original impetus for Java was not the
Internet! Instead, the primary motivation was the need for a platform-independent
(that is, architecture-neutral) language that could be used to create software to be
embedded in various consumer electronic devices, such as microwave ovens and
remote controls. However, with the emergence of the World Wide Web, Java was
propelled to the forefront of computer language design, because the Web, too,
demanded portable programs. After that the Internet helped catapult Java to the
forefront of programming, and Java, in turn, had a profound effect on the Internet. In
addition to simplifying web programming in general, Java innovated a new type of
networked program called the Applet that changed the way the online world thought
about content.

An applet is a special kind of Java program that is designed to be transmitted over


the Internet and automatically executed by a Java-compatible web browser.
Furthermore, an applet is downloaded on demand, without further interaction with the
user. If the user clicks a link that contains an applet, the applet will be automatically
downloaded and run in the browser. Applets are intended to be small programs. They
are typically used to display data provided by the server, handle user input, or provide
simple functions, such as a loan calculator, that execute locally, rather than on the
server. In essence, the applet allows some functionality to be moved from the server to
the client.

2.0 Aim/Benefits of the Micro-Project-

 To Perform a detailed study of the Applet Class in Java.


 To study the various methods in the Applet Class and Implement them.
 To get a better understanding of the concepts.

3.0 Action Plan-

Planned Start Planned Finish


Sr no. Details of activity
Date Date
1. Finalization of topic
2. Preparation of Abstract
3. Collection of data
4. Preparation of concept
5. Seminar / Presentation
6. Submission of Micro Project

6
4.0 Resources Required:

Sr.No Name of Specification Quantity Remarks


Resource/Material
1. Computer i5,RAM 8GB, Windows 11 1
(Desktop/Laptop)
2. Microsoft office word 2010 1
3. Softwares JDK version 8 ,Notepad 1
4. Books “Java: The Complete 1
Reference” by Herbert Schildt

7
PART B-Plan

Title of micro-project: Exploring BorderLayout and FlowLayout

1.0 Aims/Benefits of Micro Project:

 To Perform a detailed study of the BorderLayout and FlowLayout in Java.


 To study the various methods in the BorderLayout and FlowLayout
a and Implement them.
 To get a better understanding of the concepts.

2.0 Course Outcomes Achieved:

CO-a) Develop programs using GUI Framework (AWT and Swing).


CO-b) Handle events of AWT and Swings components.
CO-c) Develop programs to handle events in Java Programming.

3.0 Brief Description:

An applet is a special kind of Java program that is designed to be transmitted over the
Internet and automatically executed by a Java-compatible web browser. The Applet class,
provides the foundation for applets. The Applet class is contained in the java.applet package.
Applet contains several methods that give you detailed control over the execution of your
applet.
All applets are subclasses (either directly or indirectly) of Applet. Thus, all applets must
import java.applet. Applets must also import java.awt. AWT stands for the Abstract Window
Toolkit. Since all applets run in a window, it is necessary to include support for that window by
importing java.awt package.
Execution of an applet does not begin at main( ). Output to your applet’s window is not
performed by System.out.println( ). Rather, it is handled with various AWT methods, such as
drawString( ), which outputs a string to a specified X,Y location. Input is also handled differently
than in a console application.
Once an applet has been compiled, it is included in an HTML file using theAPPLET tag.
The applet will be executed by a Java-enabled web browser when it encounters the APPLET tag
within the HTML file.
To view and test an applet more conveniently, simply include a comment at the head of
your Java source code file that contains the APPLET tag.
Here is an example of such a comment:
/*
<applwt code= ”MyApplet” width =200 height=60>
</applet>
*/
This comment contains an APPLET tag that will run an applet called MyApplet in a
window that is 200 pixels wide and 60 pixels high. Since the inclusion of an APPLET command
makes testing applets easier, all of the applets shown in this tutorial will contain the appropriate
APPLET tag embedded in a comment.

8
The Applet Class: Applet extends the AWT class Panel. In turn, Panel extends
Container, which extends Component.

These classes provide support for Java’s window-based, graphical interface. Thus, Applet
provides all of the necessary support for window-based activities.

Applet Architecture: An applet is a window-based program. As such, its architecture is


different from the console-based programs . First, applets are event driven. It is important to
understand in a general way how the event driven architecture impacts the design of an applet.
Here is how the process works. An applet waits until an event occurs. The AWT notifies the
applet about an event by calling an event handler that has been provided by the applet. Once
this happens, the applet must take appropriate action and then quickly return control to the
AWT. This is a crucial point. For the most part, your applet should not enter a “mode” of
operation in which it maintains control for an extended period. Instead, it must perform specific
actions in response to events and then return control to the run-time system. In those
situations in which your applet needs to perform a repetitive task on its own (for example,
displaying a scrolling message across its window), you must start an additional thread of
execution.
Second, the user initiates interaction with an applet—not the other way around. As you
know, in a non windowed program, when the program needs input, it will prompt the user and
then call some input method, such as readLine( ). This is not the way it works in an applet.
Instead, the user interacts with the applet as he or she wants, when he or she wants.

An Applet Skeleton: Four methods—init( ), start( ), stop( ), and destroy( )—are


defined by Applet. Another, paint( ), is defined by the AWT Component class. All applets must
import java.applet. Applets must also import java.awt.

These five methods can be assembled into the skeleton shown here:
// An Applet skeleton.
import java.awt.*;
import java.applet.*;
/*
<applet code= “AppletSkel” width=300 height=100>
9
</applet>
*/
public class AppletSkel extends Applet
{
// Called first.
public void init()
{
// initialization
}
/* Called second, after init(). Also called whenever
the applet is restarted. */
public void start()
{
// start or resume execution
}
// Called when the applet is stopped.
public void stop()
{
// suspends execution
}
/* Called when applet is terminated. This is the last
method executed. */
public void destroy()
{
// perform shutdown activities
}
// Called when an applet's window must be restored.
public void paint(Graphics g)
{
// redisplay contents of window
}
}

Applet Life Cycle: The life cycle of an applet is as shown in the figure below:

As shown in the above diagram, the life cycle of an applet starts with init() method and ends
with destroy() method. Other life cycle methods are start(), stop() and paint(). The methods to
execute only once in the applet life cycle are init() and destroy(). Other methods execute
multiple times.
Below is the description of each applet life cycle method:

10
 init():The init( ) method is the first method to be called. This is where you should
initialize variables. This method is called only once during the run time of your
applet.
 start():The start( ) method is called after init( ). It is also called to restart an applet after
it has been stopped. Whereas init( ) is called once—the first time an applet is loaded—
start( ) is called each time an applet’s HTML document is displayed onscreen. So, if a
user leaves a web page and comes back, the applet resumes execution at start( ).
 paint():The paint( ) method is called each time your applet’s output must be
redrawn. This situation can occur for several reasons. paint( ) is also called when the
applet begins execution. Whatever the cause, whenever the applet must redraw its
output, paint( ) is called. The paint( ) method has one parameter of type Graphics.
 stop():The stop( ) method is called when a web browser leaves the HTML document
containing the applet—when it goes to another page, for example. When stop( ) is
called, the applet is probably running. You should use stop( ) to suspend threads that
don’t need to run when the applet is not visible. You can restart them when start( )
is called if the user returns to the page.
 destroy():The destroy( ) method is called when the environment determines that your
applet needs to be removed completely from memory. At this point, you should free up
any resources the applet may be using. The stop( ) method is always called before
destroy( ).
 Overriding update( ): In some situations, your applet may need to override another
method defined by the AWT, called update( ). This method is called when your applet
has requested that a portion of its window be redrawn. The default version of update( )
simply calls paint( ). However, you can override the update( ) method so that it
performs more subtle repainting. In general, overriding update( ) is a specialized
technique that is not applicable to all applets, and the examples in this book do not
override update( ).
The method execution sequence when an applet is executed is:
• init()
• start()
• paint()
The method execution sequence when an applet is closed is:
• stop()
• destroy()

How To Run an Applet Programe: There are two ways in which you can run an
applet:
■ Executing the applet within a Java-compatible Web browser.
■ Using an applet viewer, such as the standard SDK tool, appletviewer. An applet
viewer executes your applet in a window. This is generally the fastestand easiest way to
test your applet.
Using an applet viewer to run applet
Place the applet tag in comments in java source code.
Note:Code attribute value must be equal to name of class which extends Applet class.

Compiling: javac filename.java


Run: AppletViewer filename.java

Executing the applet within a Java-compatible Web browser


Compiling: javac SimpleApplet.java
Create an Html file and embeded Applet tag in html file.
Attributes in applet tag:
11
Code(attribute):specify name of applet class to load into browser.
Width(attribute):width of an applet.
Height(attribute):height of an applet.
<html>
<body>
<applet code="filename" width=300 height=200>
</applet>
</body>
</html>

Simple Applet Display Methods: As we’ve mentioned, applets are displayed in a


window and they use the AWT to perform input and output.To output a string to an applet, use
drawString( ), which is a member of the Graphics class.Graphics class is defined in java.awt
package.
void drawString(String message, int x, int y)
Here, message is the string to be output and x and y are x-coordinate ,y-coordinate
respectively. In a Java window, the upper-left corner is location 0,0.
To set the background color of an applet’s window, use setBackground( ). To set the
foreground color (the color in which text is shown, for example), use setForeground( ). These
methods are defined by Component, and they have the following general forms:
void setBackground(Color newColor)
void setForeground(Color newColor)
Here, newColor specifies the new color. The class Color defines the constants shown here that
can be used to specify colors:
Color.black Color.magenta
Color.blue Color.orange
Color.cyan Color.pink
Color.darkGray Color.red
Color.gray Color.white
Color.green Color.yellow
Color.lightGray
For example, this sets the background color to green and the text color to red:
setBackground(Color.green);
setForeground(Color.red);

Requesting Repainting: Whenever your applet needs to update the information


displayed in its window, it simply calls repaint( ).The repaint( ) method is defined by the AWT. It
causes the AWT run-time system to execute a call to your applet’s update( ) method, which, in
its default implementation, calls paint( ).

The simplest version of repaint( ) is shown here:


void repaint( )
This version causes the entire window to be repainted. The following version specifies a region
that will be repainted:
void repaint(int left, int top, int width, int height)
Here, the coordinates of the upper-left corner of the region are specified by left and top, and
the width and height of the region are passed in width and height. These dimensions are
specified in pixels. You save time by specifying a region to repaint.
The other two versions of repaint():

12
void repaint(long maxDelay)
void repaint(long maxDelay, int x, int y, int width, int height)
Here, maxDelay specifies the maximum number of milliseconds that can elapse before update()
is called.

Using the Status Window: 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.

The HTML APPLET Tag:


< APPLET
[CODEBASE = codebaseURL]
CODE = appletFile
[ALT = alternateText]
[NAME = appletInstanceName]
WIDTH = pixels
HEIGHT = pixels
[ALIGN = alignment]
[VSPACE = pixels]
[HSPACE = pixels]
>
[< PARAM NAME = AttributeName VALUE = AttributeValue>]
[< PARAM NAME = AttributeName2 VALUE = AttributeValue>]
...
[HTML Displayed in the absence of Java]
</APPLET>

Let’s take a look at each part now.


CODEBASE: CODEBASE is an optional attribute that specifies the base URL of the applet code,
which is the directory that will be searched for the applet’s executable class file (specified by
the CODE tag).
CODE :CODE is a required attribute that gives the name of the file containing your applet’s
compiled .class file. This file is relative to the code base URL of the applet, which is the
directory that the HTML file was in or the directory indicated by CODEBASE if set.

ALT :The ALT tag is an optional attribute used to specify a short text message that should be
displayed if the browser understands the APPLET tag but can’t currently run Java applets.

NAME: NAME is an optional attribute used to specify a name for the applet instance. Applets
must be named in order for other applets on the same page to find them by name and
communicate with them.

WIDTH AND HEIGHT :WIDTH and HEIGHT are required attributes that give the size (in pixels) of
the applet display area.

ALIGN: ALIGN is an optional attribute that specifies the alignment of the applet.The possible
values:LEFT, RIGHT, TOP, BOTTOM, MIDDLE, BASELINE, TEXTTOP, ABSMIDDLE,and
ABSBOTTOM.

VSPACE AND HSPACE :These attributes are optional. VSPACE specifies the space, in pixels,
above and below the applet. HSPACE specifies the space, in pixels, on each side of the applet.

13
PARAM NAME AND VALUE: The PARAM tag allows you to specify applet specific arguments in
an HTML page. Applets access their attributes with the getParameter( ) method.

Passing Parameters to Applets: As just discussed, the APPLET tag in HTML


allows you to pass parameters to your applet. To retrieve a parameter, use the
getParameter() method. It returns the value of the specified parameter in the form of a String
object. Thus, for numeric and boolean values, you will need to convert their string
representations into
their internal formats. If a parameter isn’t available, getParameter( ) will return null. Also,
conversions to numeric types must be attempted in a try statement that catches
NumberFormatException. Uncaught exceptions should never occur within an applet.

getDocumentBase( ) and getCodeBase( ): Often, you will create applets


that will need to explicitly load media and text. Java will allow the applet to load data from the
directory holding the HTML file that started the applet (the document base) and the directory
from which the applet’s class file was loaded (the code base). These directories are returned as
URL objects (described in Chapter 20) by getDocumentBase( ) and getCodeBase( ). They can
be concatenated with a string that names the file you want to load. To actually load another
file, you will use the showDocument( ) method defined by the AppletContext interface,
discussed in the next section.

4.0 Actual Methodology/Procedure Followed:


First I have discussed for my micro-project required resources . Then I have
collected required informations from many of websites , Books and from internet
about Applet class in Java Language .
After this I have created my project by creating a program implementing the
various functions of the afformentioned class. Then I have tested my program code
in javac Compiler for checking whether my program code is giving me expected
output or not ! . So if tested ok then program is fully functional , ready for use and
demonstration.
After testing work of program, I have created a detailed report to present my
research about how I used the concepts of the Applet class and implemented it.
After completing this report I have submitted it to our guidance .

5.0 Actual Resources Used:

Sr.No Name of Specification Quantity Remarks


Resource/Material
1. Computer i5,RAM 8GB, Windows 11 1
(Desktop/Laptop)
2. Microsoft office word 2010 1
3. Softwares Notepad and Command Prompt 1
4. Books “Java: The Complete 1
Reference” by Herbert Schildt

14
6.0 A Simple Applet Programme to display a Clock:

import java.applet.*;
import java.awt.*;
import java.util.*;
public class Clock extends Applet implements Runnable
{
Thread t;
//Initialize the applet
public void init()
{
setBackground(Color.white);
}
//Function to start the thread
public void start()
{
t = new Thread(this);
t.start();
}
//Function to execute the thread
public void run()
{
while(true)
{
Try
{
repaint();
//Delay by 1 sec
Thread.sleep(1000);
}
catch(Exception e)
{
}
}
}
//Function to draw the clock
public void paint(Graphics g)
{
Calendar time = Calendar.getInstance();
int hour = time.get(Calendar.HOUR_OF_DAY) % 12;
int minute = time.get(Calendar.MINUTE);
int second = time.get(Calendar.SECOND);
double angle;
int x,y;
//Draw a circle with center(250,250) & radius=150
g.drawOval(100,100,300,300);
//Label the clock

15
String s="12";
int i=0;
while(i<12)
{
angle = Math.toRadians(30*(i-3));
x = 250+(int)
(Math.cos(angle)*135); y = 250+
(int)(Math.sin(angle)*135);
g.drawString(s,x,y);
i++;
s=String.valueOf(i);
}
//Draw the hours hand
g.setColor(Color.green);
angle = Math.toRadians((30*hour)-90);
x = 250+(int)(Math.cos(angle)*100);
y = 250+(int)(Math.sin(angle)*100);
g.drawLine(250,250,x,y);
//Draw the minutes hand
g.setColor(Color.red);
angle = Math.toRadians((6*minute)-90);
x = 250+(int)(Math.cos(angle)*115);
y = 250+(int)(Math.sin(angle)*115);
g.drawLine(250,250,x,y);
//Draw the seconds hand
g.setColor(Color.blue);
angle = Math.toRadians((6*second)-90);
x = 250+(int)(Math.cos(angle)*130);
y = 250+(int)(Math.sin(angle)*130);
g.drawLine(250,250,x,y);
}
}
/*
<applet code = Clock.class width=500 height=500>
</applet>
*/

16
6.0 Output of the Micro-Project:

17
7.0 Skill Developed:

 Better understanding of the Applet Class.


 Improvement in programming skills.
 Detailed knowledge and understanding of the methods in applet class.
 Problem solving skills .
 Creativity .
 Critical thinking skills .

8.0 Applications of this Microproject:

 Java applets are used to provide interactive features to web applications and can be
executed by browsers for many platforms.
 Applets provide sound, graphics and animation in various forms and formats for
webpages.
 They are used in games, gaming consoles, commercial websites, learning tools and
many more.

18

You might also like