SlideShare a Scribd company logo
1 of 20
ADVANCED JAVA PROGRAMMING
APPLETS- ARCHITECTURE
ADVANCED JAVA PROGRAMMING
APPLET – BASICS
Applets in Java are small and dynamic internet-based programs. A Java Applet can be only
executed within the applet framework of Java. For an easy execution of applets, a restricted
‘sandbox’ is provided by the applet framework.
Generally, the applet code is embedded within an HTML page. The applet codes are
executed when the HTML pages get loaded into the Java-compatible web browsers.
ADVANCED JAVA PROGRAMMING
APPLET – BASICS
ADVANCED JAVA PROGRAMMING
APPLET- SKELETON
Four of these methods—init( ), start( ), stop( ), and destroy( )—are defined by Applet. Another, paint( ), is
defined by the AWT Component class.
init() : init() is the first method to be called. This is where variable are initialized. This method is called
only once during the runtime of applet.
start() : start() method is called after init(). This method is called to restart an applet after it has been
stopped.
stop() : stop() method is called to suspend thread that does not need to run when applet is not visible.
destroy() : destroy() method is called when your applet needs to be removed completely from memory.
ADVANCED JAVA PROGRAMMING
SIMPLE APPLET
/*<applet code = “Hell” width=300 height=300></applet>*/
import java.applet.Applet;
import java.awt.Graphics;
public class Hell extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hello World", 20, 20);
}
}
ADVANCED JAVA PROGRAMMING
REQUESTING REPAINTING HTML APPLET TAG
An applet writes to its window only when its paint( ) method is called by the AWT.
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,
ADVANCED JAVA PROGRAMMING
REQUESTING REPAINTING HTML APPLET TAG
1.void repaint( )
This version causes the entire window to be repainted.
2.void repaint(int left, int top, int width, int height)
This version specifies a region that will be repainted.
3. void repaint(long maxDelay)
Here, maxDelay specifies the maximum number of milliseconds that can elapse before update( ) is
called.
4.void repaint(long maxDelay, int x, int y, int width, int height)
ADVANCED JAVA PROGRAMMING
PASSING PARAMETERS TO APPLETS
Parameters specify extra information that can be passed to an applet from the HTML page.
Parameters are specified using the HTML’s param tag.
Param Tag
The <param> tag is a sub tag of the <applet> tag. The <param> tag contains two
attributes: name and value which are used to specify the name of the parameter and the
value of the parameter respectively.
ADVANCED JAVA PROGRAMMING
GRAPHICS
All graphics are drawn relative to a window. This can be the main window of an applet, a
child window of an applet, or a stand-alone application window.
The origin of each window is at the top-left Coordinates 0,0. Coordinates are specified in
pixels. All output to a window takes place through a graphics context.
A graphics context is encapsulated by the Graphics class and is obtained in two ways:
It is passed to an applet when one of its various methods, such as paint() or update(), is
called.
It is returned by the getGraphics( ) method of Component.
ADVANCED JAVA PROGRAMMING
GRAPHICS
Methods of Graphics class
public abstract void drawString(String str, int x, int y): is used to draw the specified string.
public void drawRect(int x, int y, int width, int height): draw a rectangle with the specified
width and height.
public abstract void fillRect(int x, int y, int width, int height): is used to fill the rectangle
with the default color and specified width and height.
public abstract void drawOval(int x, int y, int width, int height): is used to draw oval with
the specified width and height.
ADVANCED JAVA PROGRAMMING
FONT
Font is a class that belongs to the java.awt package. It implements the Serializable
interface. FontUIResource is the direct known subclass of the Java Font class.
It represents the font that are used to render the text. In Java, there are two technical
terms that are used to represent font are characters and Glyphs.
Types of Fonts in Java
Physical Fonts
Logical Fonts
ADVANCED JAVA PROGRAMMING
COLORCLASSES
The primary purpose of AWT Color is to allow developers to create new colors using Java
code using RGB (red, green, blue), RGBA (red, green, blue, alpha), or HSB (hue, saturation,
BRI components) packages.
The class contains two values - the code of the shade and the value of
opacity/transparency.
Color defines several constants (for example, Color.black) to specify a number of common
colors. We can also create your own colors, using one of the color constructors.
ADVANCED JAVA PROGRAMMING
SWING-JAPPLET
JApplet is a java swing public class designed for developers usually written in Java. JApplet is
generally in the form of Java bytecode that runs with the help of a Java virtual machine
(JVM) or Applet viewer from Sun Microsystems. It was first introduced in 1995.
JApplet can also be written in other programming languages and can later be compiled to
Java byte code.
Java applets can be executed on multiple platforms which include Microsoft Windows,
UNIX, Mac OS and Linux. JApplet can also be run as an application, though this would
require a little extra coding.
ADVANCED JAVA PROGRAMMING
JFRAME
The javax.swing.JFrame class is a type of container which inherits the java.awt.Frame class.
JFrame works like the main window where components like labels, buttons, textfields are
added to create a GUI.
create a JFrame
JFrame class has many constructors that are used to create a new JFrame. You can create a
JFrame using these methods:
JFrame(): This helps in creating a frame which is invisible.
JFrame(String Title): Helps in creating a frame with a title.
JFrame(GraphicsConfiguration gc): Creates a frame with blank title and the graphics
configuration of screen.
ADVANCED JAVA PROGRAMMING
JCOMPONENT DIFFERENCES BETWEEN COMPONENT
No. Java AWT Java Swing
1)
AWT components are platform-
dependent.
Java swing components are platform-independent.
2)
AWT components are heavyweight. Swing components are lightweight.
3)
AWT doesn't support pluggable look and
feel.
Swing supports pluggable look and feel.
ADVANCED JAVA PROGRAMMING
CONTAINER
An applet container is the environment that runs a Java applet and provides secure applet
execution. Examples include Web browsers and the applet viewer in Java's software
development kit (SDK).
Types of Containers
The Container class, like Component is an abstract class. It has two direct subclasses:
Panel, which is only used for grouping components;
Window, which is, as its name says, for creating and handling windows.
ADVANCED JAVA PROGRAMMING
ICONS
Swing introduces the concept of an icon for use in a variety of components.
The Icon interface and ImageIcon class make dealing with simple images extremely easy.
The Icon interface is very simple, specifying just three methods used to determine the size
of the Icon and to display it. Implementors of this interface are free to store and display the
image in any way, providing a great deal of flexibility.
ADVANCED JAVA PROGRAMMING
JLabel
The object of JLabel class is a component for placing text in a container. It is used to display
a single line of read only text. The text can be changed by an application but a user cannot
edit it directly. It inherits JComponent class.
Java JTextField
The object of a JTextField class is a text component that allows the editing of a single line
text. It inherits JTextComponent class.
ADVANCED JAVA PROGRAMMING
Java JButton
The JButton class is used to create a labeled button that has platform independent
implementation. The application result in some action when the button is pushed. It
inherits AbstractButton class.
Java JCheckBox
The JCheckBox class is used to create a checkbox. It is used to turn an option on (true) or off
(false). Clicking on a CheckBox changes its state from "on" to "off" or from "off" to "on ". It
inherits JToggleButton class.
ADVANCED JAVA PROGRAMMING
Java JRadioButton
The JRadioButton class is used to create a radio button. It is used to choose one option
from multiple options. It is widely used in exam systems or quiz.
It should be added in ButtonGroup to select one radio button only.
Java JComboBox
The object of Choice class is used to show popup menu of choices. Choice selected by user
is shown on the top of a menu. It inherits JComponent class.

More Related Content

Similar to JavaAdvUnit-1.pptx

Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programmingKuntal Bhowmick
 
Java basics notes
Java basics notesJava basics notes
Java basics notesNexus
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Javayht4ever
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxoops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxrani marri
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02Ankit Dubey
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCFAKHRUN NISHA
 

Similar to JavaAdvUnit-1.pptx (20)

GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Applets
AppletsApplets
Applets
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
Java applet
Java appletJava applet
Java applet
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Smart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdfSmart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdf
 
Smart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdfSmart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdf
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxoops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 

More from DrPrabakaranPerumal (10)

Java.pptx
Java.pptxJava.pptx
Java.pptx
 
IoT.pptx
IoT.pptxIoT.pptx
IoT.pptx
 
EthicalHacking.pptx
EthicalHacking.pptxEthicalHacking.pptx
EthicalHacking.pptx
 
SoftwareEngineering.pptx
SoftwareEngineering.pptxSoftwareEngineering.pptx
SoftwareEngineering.pptx
 
SoftwareTesting.pptx
SoftwareTesting.pptxSoftwareTesting.pptx
SoftwareTesting.pptx
 
Html-Prabakaran
Html-PrabakaranHtml-Prabakaran
Html-Prabakaran
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Programming-in-C
Programming-in-CProgramming-in-C
Programming-in-C
 
VOSUnit
VOSUnitVOSUnit
VOSUnit
 
OpeatingSystemPPT
OpeatingSystemPPTOpeatingSystemPPT
OpeatingSystemPPT
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

JavaAdvUnit-1.pptx

  • 2. ADVANCED JAVA PROGRAMMING APPLET – BASICS Applets in Java are small and dynamic internet-based programs. A Java Applet can be only executed within the applet framework of Java. For an easy execution of applets, a restricted ‘sandbox’ is provided by the applet framework. Generally, the applet code is embedded within an HTML page. The applet codes are executed when the HTML pages get loaded into the Java-compatible web browsers.
  • 4. ADVANCED JAVA PROGRAMMING APPLET- SKELETON Four of these methods—init( ), start( ), stop( ), and destroy( )—are defined by Applet. Another, paint( ), is defined by the AWT Component class. init() : init() is the first method to be called. This is where variable are initialized. This method is called only once during the runtime of applet. start() : start() method is called after init(). This method is called to restart an applet after it has been stopped. stop() : stop() method is called to suspend thread that does not need to run when applet is not visible. destroy() : destroy() method is called when your applet needs to be removed completely from memory.
  • 5. ADVANCED JAVA PROGRAMMING SIMPLE APPLET /*<applet code = “Hell” width=300 height=300></applet>*/ import java.applet.Applet; import java.awt.Graphics; public class Hell extends Applet { public void paint(Graphics g) { g.drawString("Hello World", 20, 20); } }
  • 6. ADVANCED JAVA PROGRAMMING REQUESTING REPAINTING HTML APPLET TAG An applet writes to its window only when its paint( ) method is called by the AWT. 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,
  • 7. ADVANCED JAVA PROGRAMMING REQUESTING REPAINTING HTML APPLET TAG 1.void repaint( ) This version causes the entire window to be repainted. 2.void repaint(int left, int top, int width, int height) This version specifies a region that will be repainted. 3. void repaint(long maxDelay) Here, maxDelay specifies the maximum number of milliseconds that can elapse before update( ) is called. 4.void repaint(long maxDelay, int x, int y, int width, int height)
  • 8. ADVANCED JAVA PROGRAMMING PASSING PARAMETERS TO APPLETS Parameters specify extra information that can be passed to an applet from the HTML page. Parameters are specified using the HTML’s param tag. Param Tag The <param> tag is a sub tag of the <applet> tag. The <param> tag contains two attributes: name and value which are used to specify the name of the parameter and the value of the parameter respectively.
  • 9. ADVANCED JAVA PROGRAMMING GRAPHICS All graphics are drawn relative to a window. This can be the main window of an applet, a child window of an applet, or a stand-alone application window. The origin of each window is at the top-left Coordinates 0,0. Coordinates are specified in pixels. All output to a window takes place through a graphics context. A graphics context is encapsulated by the Graphics class and is obtained in two ways: It is passed to an applet when one of its various methods, such as paint() or update(), is called. It is returned by the getGraphics( ) method of Component.
  • 10. ADVANCED JAVA PROGRAMMING GRAPHICS Methods of Graphics class public abstract void drawString(String str, int x, int y): is used to draw the specified string. public void drawRect(int x, int y, int width, int height): draw a rectangle with the specified width and height. public abstract void fillRect(int x, int y, int width, int height): is used to fill the rectangle with the default color and specified width and height. public abstract void drawOval(int x, int y, int width, int height): is used to draw oval with the specified width and height.
  • 11. ADVANCED JAVA PROGRAMMING FONT Font is a class that belongs to the java.awt package. It implements the Serializable interface. FontUIResource is the direct known subclass of the Java Font class. It represents the font that are used to render the text. In Java, there are two technical terms that are used to represent font are characters and Glyphs. Types of Fonts in Java Physical Fonts Logical Fonts
  • 12. ADVANCED JAVA PROGRAMMING COLORCLASSES The primary purpose of AWT Color is to allow developers to create new colors using Java code using RGB (red, green, blue), RGBA (red, green, blue, alpha), or HSB (hue, saturation, BRI components) packages. The class contains two values - the code of the shade and the value of opacity/transparency. Color defines several constants (for example, Color.black) to specify a number of common colors. We can also create your own colors, using one of the color constructors.
  • 13. ADVANCED JAVA PROGRAMMING SWING-JAPPLET JApplet is a java swing public class designed for developers usually written in Java. JApplet is generally in the form of Java bytecode that runs with the help of a Java virtual machine (JVM) or Applet viewer from Sun Microsystems. It was first introduced in 1995. JApplet can also be written in other programming languages and can later be compiled to Java byte code. Java applets can be executed on multiple platforms which include Microsoft Windows, UNIX, Mac OS and Linux. JApplet can also be run as an application, though this would require a little extra coding.
  • 14. ADVANCED JAVA PROGRAMMING JFRAME The javax.swing.JFrame class is a type of container which inherits the java.awt.Frame class. JFrame works like the main window where components like labels, buttons, textfields are added to create a GUI. create a JFrame JFrame class has many constructors that are used to create a new JFrame. You can create a JFrame using these methods: JFrame(): This helps in creating a frame which is invisible. JFrame(String Title): Helps in creating a frame with a title. JFrame(GraphicsConfiguration gc): Creates a frame with blank title and the graphics configuration of screen.
  • 15. ADVANCED JAVA PROGRAMMING JCOMPONENT DIFFERENCES BETWEEN COMPONENT No. Java AWT Java Swing 1) AWT components are platform- dependent. Java swing components are platform-independent. 2) AWT components are heavyweight. Swing components are lightweight. 3) AWT doesn't support pluggable look and feel. Swing supports pluggable look and feel.
  • 16. ADVANCED JAVA PROGRAMMING CONTAINER An applet container is the environment that runs a Java applet and provides secure applet execution. Examples include Web browsers and the applet viewer in Java's software development kit (SDK). Types of Containers The Container class, like Component is an abstract class. It has two direct subclasses: Panel, which is only used for grouping components; Window, which is, as its name says, for creating and handling windows.
  • 17. ADVANCED JAVA PROGRAMMING ICONS Swing introduces the concept of an icon for use in a variety of components. The Icon interface and ImageIcon class make dealing with simple images extremely easy. The Icon interface is very simple, specifying just three methods used to determine the size of the Icon and to display it. Implementors of this interface are free to store and display the image in any way, providing a great deal of flexibility.
  • 18. ADVANCED JAVA PROGRAMMING JLabel The object of JLabel class is a component for placing text in a container. It is used to display a single line of read only text. The text can be changed by an application but a user cannot edit it directly. It inherits JComponent class. Java JTextField The object of a JTextField class is a text component that allows the editing of a single line text. It inherits JTextComponent class.
  • 19. ADVANCED JAVA PROGRAMMING Java JButton The JButton class is used to create a labeled button that has platform independent implementation. The application result in some action when the button is pushed. It inherits AbstractButton class. Java JCheckBox The JCheckBox class is used to create a checkbox. It is used to turn an option on (true) or off (false). Clicking on a CheckBox changes its state from "on" to "off" or from "off" to "on ". It inherits JToggleButton class.
  • 20. ADVANCED JAVA PROGRAMMING Java JRadioButton The JRadioButton class is used to create a radio button. It is used to choose one option from multiple options. It is widely used in exam systems or quiz. It should be added in ButtonGroup to select one radio button only. Java JComboBox The object of Choice class is used to show popup menu of choices. Choice selected by user is shown on the top of a menu. It inherits JComponent class.