SlideShare a Scribd company logo
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 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)
 
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

MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxssuserbdd3e8
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxDenish Jangid
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersPedroFerreira53928
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXMIRIAMSALINAS13
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativePeter Windle
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasGeoBlogs
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdfCarlosHernanMontoyab2
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationDelapenabediema
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfjoachimlavalley1
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsparmarsneha2
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismDeeptiGupta154
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated crops
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 

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.