SlideShare a Scribd company logo
1 of 69
Download to read offline
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
1
Prepared By: Asst. Prof. Sejal Jadav
Unit-4
CS – 19 : Programming with Java
UNIT – 4
Applets, Layout Manager
B.C.A & B.SC.(IT) – 4
Prepared By: Asst. Prof. Sejal Jadav
Simple Applet program:
• Example: Applet1.java
• Compile: javac Applet1.java
• Run: appletviewer sj.html
Prepared By: Asst. Prof. Sejal Jadav
Q-3 Explain Applet life cycle.
• Each applet has a life cycle. So every time an applet is
initialized it goes through four states and finally after its
execution the applet is destroyed.
• At those state the applet calls a set of methods in an order.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
• These methods are init(), start(), stop() and destroy().
• Those are methods defined by the applet class and one can override
these methods as needed.
• In addition to those four methods the paint() method is another
method which is in the Component class of java.awt package.
• Those methods are described below.
Prepared By: Asst. Prof. Sejal Jadav
The init() method:
• The init() method is the first method called by an applet.
• In this method the initialization process in done.
• The variables, objects, background colors, fonts etc. are initialized in
this method.
• This method is called only once after an applet is created since
initialization should be one only once.
Prepared By: Asst. Prof. Sejal Jadav
Its syntax is:
public void init()
{
//initialized process
}
Prepared By: Asst. Prof. Sejal Jadav
The start() method:
• After the init() method, start() method is called.
• This method start the applet. It is also called to restart the applet if it is
stopped.
• This method can be called more than once since it needs to restart each time
it is stopped.
• In a browser if you leave the applet page, the applet is stopped and when you
again come back to that page it is restarted. Or when the applet window is
minimized, it is stopped and as it is restored, the applet is restarted.
Prepared By: Asst. Prof. Sejal Jadav
The syntax of start) method is:
public void start()
{
//the code to start applet
}
Prepared By: Asst. Prof. Sejal Jadav
The paint() method:
• The paint() method is of the component class which is in the java.awt
package.
• This method is called when the applet execution starts or the contents
of applet needs to be redrawn.
• The paint() method takes a parameter of type graphic class. This
graphic object is used to draw the text or any shapes etc. in the
applet window.
Prepared By: Asst. Prof. Sejal Jadav
• Its syntax is:
public void paint(Graphic g)
{
//code to display in the applet
}
Prepared By: Asst. Prof. Sejal Jadav
The stop() method:
• The stop() method is called when you minimize the applet window or
leave the applet page and go to another page in the browser.
• If you are working with thread then you should block or suspend the
thread when applet stops.
• After stopping an applet it can be restarted by the start() method
Prepared By: Asst. Prof. Sejal Jadav
• Its syntax is:
public void stop()
{
//statements……
}
Prepared By: Asst. Prof. Sejal Jadav
The destroy() method:
• The destroy() method is called when your applet is to be terminated
and needs to removed from the memory.
• In this method you should do the cleanup of the object and other
resource.
• The destroy() method is called after the stop() method and is
called only once.
Prepared By: Asst. Prof. Sejal Jadav
Its syntax is:
public void destroy()
{
//code for finalization…….
}
Prepared By: Asst. Prof. Sejal Jadav
• Example:
• AppletMethodEx.java
• AppletMethodEx.html
Prepared By: Asst. Prof. Sejal Jadav
Q-4 Explain Applet Class
• Applets are created using the applet class which is in java.applet
package.
• To create applet program, you must extend the applet class.
• The methods of applet class are listed below.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
METHOD Description
void init() Initialize this applet
void start() Starts this applet
void stop() Stops this applet
void destroy() Destroys this applet
AppletContext getAppletContext() returns the Applet Context
String getAppletInfo() It returns a string containing the applet
information.
URL getCodeBase() It returns the URL (path) of the applet
class file.
URL getDocumentBase() It returns the URL of the HTML
document that executes the applet.
Prepared By: Asst. Prof. Sejal Jadav
• Example: Folder Applet Methods
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
String getParameter(String paramName) It returns the value of parameter
paramName.
Boolean isActive() It returns true if the applet has been
started and returns false if the applet
has been stopped.
void resize(int width,int height) It resize the applet according to the
dimensions specified by width and
height.
void showStatus(String status) It display the status in the bar of the
browser or applet viewer. If the browser
does not support a status window,
nothing happens.
Prepared By: Asst. Prof. Sejal Jadav
• Example: Folder Applet Methods
Prepared By: Asst. Prof. Sejal Jadav
Playing Audio Example
public interface AudioClip
• The AudioClip interface is a simple abstraction for playing a sound clip.
Multiple AudioClip items can be playing at the same time, and the
resulting sound is mixed together to produce a composite.
Prepared By: Asst. Prof. Sejal Jadav
There some Method Detail:
• Example : PlaySoundApplet folder
void play() Starts playing this audio clip.
the clip is restarted from the beginning.
void loop() Starts playing this audio clip in a loop.
void stop() Stops playing this audio clip.
Prepared By: Asst. Prof. Sejal Jadav
Explain Graphic class.
• The graphic class is in the java.awt package and it contains
several methods that can help to perform graphics related
operations in the applet.
• Those methods include drawing text, lines and many different
shapes. These methods are:
Prepared By: Asst. Prof. Sejal Jadav
• 1.void drawString(String msg, int x, int y)
• The msg is displayed at the specified location specified by the x and y
coordinates.
• Ex:myapplet.java
Prepared By: Asst. Prof. Sejal Jadav
2.void drawLine (int x1, int y1, int x2, int y2)
• This method draws a line joining the points (x1,y1) and (x2,y2).
• EX: shapeEx1.java
Prepared By: Asst. Prof. Sejal Jadav
3.void drawRect (int x, int y, int width, int height)
• This method draws a rectangle from the upper-left corner at the point
(x,y) of the width and height specified by width and height. The
rectangle is filled with the current color.
• Ex:shapeEx3.java
Prepared By: Asst. Prof. Sejal Jadav
4.void fillRect (int x, int y, int width, int height)
• This method draws a rectangle from the upper-left corner at the point
(x,y) of the width and height specified by width and height. The
rectangle is filled with the current color.
• Ex:shapeEx4.java
Prepared By: Asst. Prof. Sejal Jadav
5.void drawOval (int x, int y, int width, int height)
• This method draws an oval. The top-left corner of rectangle is the point
(x,y) and its width and height are specified by width and height. To
draw a circle the width and height should be same.
• Ex:shapeEx5.java
Prepared By: Asst. Prof. Sejal Jadav
6.void fillOval (int x, int y, int width, int height)
• It draws and fills the oval with the color.
• Ex:shapeEx6.java
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
7.void drawArc ( int x, int y, int width, int height, int startangle,
int endAngle )
• This method draws an arc which is bounded by the rectangle. The
rectangle’s top-left corner is point (x,y) and its width and height are
specified by width and height. The arc is drawn from the startangle
to the endAngle. Angles are is degrees.
• Ex:shapeEx7.java
Prepared By: Asst. Prof. Sejal Jadav
8.void fillArc ( int x, int y, int width, int height, int startAngle, int
endAngle)
• It draw and fills the arc with the color.
• Ex:shapeEx7.java
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
9.void drawPolygon ( int x[], int y[], int numOfPoints)
• This method draws a polygon of numOfpoint angles.
• The polygon’s endpoints are specified by the x and y arrays.
• It simply joins the points specified by the array specified by the
array elements.
• Means it joins the point ( x[0],y[0]) to the point (x[1],y[1]),then
point ( x[2],y[2]) is joined to point (x[1],y[1]) and so on.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
drawPolygon ( int x[], int y[], int numOfPoints)
• Ex:shapeEx8.java
Prepared By: Asst. Prof. Sejal Jadav
• 10. void fillPolygon (int x[], int y[], int numOfPoints)
• It draws and fills the polygon with the color.
Prepared By: Asst. Prof. Sejal Jadav
Layout Managers
Part-2
Prepared By: Asst. Prof. Sejal Jadav
Layout Managers
• The Layout manager decides how the control should be
arranged or positioned within a container or a window. It does
so by using some algorithm or you can say a method.
• In some languages like visual basic (VB) you can arrange your
controls as you like using the form designer.
Prepared By: Asst. Prof. Sejal Jadav
• But in Java there is no such form designer, but you have to write the
code to arrange the controls where you want them.
• Some editors allow contain the layout tool that allows you to position
your components like visual Basic. But it is necessary for us to know
how this layout manager works.
Prepared By: Asst. Prof. Sejal Jadav
• To set the layout following method is used.
void setLayout (LayoutManager obj)
• The obj is an object of the specified layout manager.
• If no layout manager is set by the setLayout() method, the
default layout manager is used which is the FlowLayout.
Prepared By: Asst. Prof. Sejal Jadav
(1)FlowLayout
• The FlowLayout is the default layout manager. i.e if no layout
manager is set by the setLayout() method, this layout is used to
arrange the controls in a container.
• In this layout manager the components are arranged from the
upper-left corner to the right side edge of the container. When
there is no space for the component it is arranged from the next
line. A little space is added between each component at all of the
four sides.
Prepared By: Asst. Prof. Sejal Jadav
The constructors for this class are:
• FlowLayout()
• FlowLayout(int align)
• FlowLayout(int align, hspace, vspace)
• Here the align parameter specified the alignment for the components. Like:
• FlowLayout(FlowLayout.RIGHT)
• FlowLayout(FlowLayout.CENTER)
• FlowLayout(FlowLayout.LEFT)
Prepared By: Asst. Prof. Sejal Jadav
• The default is FlowLayout.CENTER
• The hspace and vspace specifies the horizontal and vertical space
between the components respectively.
• The default space is 5 pixel from both horizontal and vertical.
• Example: FlowLayoutEx.java
Prepared By: Asst. Prof. Sejal Jadav
(2)Border Layout
• The BorderLayout arranges the components in five portions.
• These portions are the four edges of the window and the fifth is the
center part.
• These portions are known as north, south, east, west and center.
• These portions are specified by the following constants.
Prepared By: Asst. Prof. Sejal Jadav
• BorderLayout.NORTH: The top edge of the window.
• BorderLayout.SOUTH: The bottom edge of the window.
• BorderLayout.EAST: The right side edge of the window.
• BorderLayout.WEST: The left side edge of the window.
• BorderLayout.CENTER: The remaining center portion of the window.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
• Constructors for BorderLayout are:
• BorderLayout()
• BorderLayout(int hspace,int vspace)
• Here hspace and vspace specify the horizontal and vertical spaces between the
component.
• After creating the BorderLayout object you can add components by the following
method:
void add(Component obj , Object where)
Prepared By: Asst. Prof. Sejal Jadav
Method is:
• void add(Component obj , Object where)
For Example:
pane.add(new JButton("NORTH"),BorderLayout.NORTH);
pane.add(new JButton("SOUTH"),BorderLayout.SOUTH);
pane.add(new JButton("EAST"),BorderLayout.EAST);
pane.add(new JButton("WEST"),BorderLayout.WEST);
Prepared By: Asst. Prof. Sejal Jadav
• Example: BorderLayoutEx.java
Prepared By: Asst. Prof. Sejal Jadav
(3)GridLayout
• The GridLayout class creates a layout which has a grid of rows and
columns.
• The constructors for GridLayout are:
• GridLayout()
• GridLayout( int rows, int columns)
• GridLayout( int rows, int columns, int hspace, int vspace)
Prepared By: Asst. Prof. Sejal Jadav
• The first constructor is the default constructor which will
create only one column grid.
• Here rows and columns specify the number of rows and
columns of the grid and the hspace and vspace specify the
horizontal and vertical spaces between the components.
Prepared By: Asst. Prof. Sejal Jadav
Example: GridLayoutEx.java
Prepared By: Asst. Prof. Sejal Jadav
Introduction to BoxLayout [only Theory]
• The BoxLayout is used to arrange the components either vertically or
horizontally.
• For this purpose, BoxLayout provides four constants.
• They are as follows:
• Note: BoxLayout class is found in javax.swing package.
Prepared By: Asst. Prof. Sejal Jadav
• Fields of BoxLayout class:
1. public static final int X_AXIS
2. public static final int Y_AXIS
3. public static final int LINE_AXIS
4. public static final int PAGE_AXIS
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
• BoxLayoutExample1.java
Prepared By: Asst. Prof. Sejal Jadav
Introduction to SpringLayout [only Theory]
• A SpringLayout arranges the children of its associated container
according to a set of constraints. Constraints are nothing but horizontal
and vertical distance between two-component edges.
• Every constraint is represented by a SpringLayout.Constraint object.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Introduction to GroupLayout [only Theory]
• The class GroupLayout hierarchically groups components in order to
position them in a Container
Prepared By: Asst. Prof. Sejal Jadav
• GroupLayout groups its components and places them in a Container
hierarchically.
• The grouping is done by instances of the Group class.
• Group is an abstract class, and two concrete classes which implement
this Group class are SequentialGroup and ParallelGroup.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
• After unit-5
• Concepts: Swing component’s
Prepared By: Asst. Prof. Sejal Jadav
(4)Card Layout
• The CardLayout has some special capabilities the other layout do not have.
• The CardLayout creates a layout like the playing cards.
• Assume more than one card on one another.
• Here only the card on the top is visible at a time. But you can shuffle the cards
to see other cards.
• Some way the CardLayout can switch among several panels.
Prepared By: Asst. Prof. Sejal Jadav
The constructors for CardLayout are:
• CardLayout()
• CardLayout(int hspace, int vspace)
• Here hspace and vspace specify the horizontal and vertical spaces
between the component.
• To add components or panels to the card Layout panel following
method is used.
Prepared By: Asst. Prof. Sejal Jadav
void add(Component obj,ObjectpanelName)
• Here the panelName is the name of the panel object.
• After Defining the panel object you can show or shuffle the card panels
by one or following methods.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Methods Description
void show(Container panelobj, String panelName) It is show the panel specified by the
panelobj and whose name is panelName.
void first(Container panelObj) It shows the first card i.e. panel.
void last(Container panelObj) It shows the last card i.e. panel.
void next(Container panelObj) It shows the next card i.e. panel.
void previous(Container panelObj) It shows the previous card i.e. panel.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
• Example:CardLayoutEx.java
Prepared By: Asst. Prof. Sejal Jadav
(5) GridBagLayout
•GridBagLayout.pdf
•Example: GridBagLayoutEx.java
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
76

More Related Content

Similar to concept of applet and concept of Layout Managers

Similar to concept of applet and concept of Layout Managers (20)

Java Applet
Java AppletJava Applet
Java Applet
 
GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Hello java
Hello java   Hello java
Hello java
 
Hello Java-First Level
Hello Java-First LevelHello Java-First Level
Hello Java-First Level
 
Hello java
Hello java  Hello java
Hello java
 
Applets
AppletsApplets
Applets
 
Applets
AppletsApplets
Applets
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
 
Programming Java Concept of Event Handling
Programming Java Concept of Event HandlingProgramming Java Concept of Event Handling
Programming Java Concept of Event Handling
 
Applets 101-fa06
Applets 101-fa06Applets 101-fa06
Applets 101-fa06
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Applet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introductionApplet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introduction
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
 
Applet
AppletApplet
Applet
 
Cse java
Cse javaCse java
Cse java
 
Applets
AppletsApplets
Applets
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Java introduction
Java introductionJava introduction
Java introduction
 

More from Jadavsejal

Programming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassProgramming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassJadavsejal
 
C++ unit-2-part-3
C++ unit-2-part-3C++ unit-2-part-3
C++ unit-2-part-3Jadavsejal
 
C++ unit-2-part-2
C++ unit-2-part-2C++ unit-2-part-2
C++ unit-2-part-2Jadavsejal
 
C++ unit-2-part-1
C++ unit-2-part-1C++ unit-2-part-1
C++ unit-2-part-1Jadavsejal
 
C++ unit-1-part-15
C++ unit-1-part-15C++ unit-1-part-15
C++ unit-1-part-15Jadavsejal
 
C++ unit-1-part-14
C++ unit-1-part-14C++ unit-1-part-14
C++ unit-1-part-14Jadavsejal
 
C++ unit-1-part-13
C++ unit-1-part-13C++ unit-1-part-13
C++ unit-1-part-13Jadavsejal
 
C++ unit-1-part-12
C++ unit-1-part-12C++ unit-1-part-12
C++ unit-1-part-12Jadavsejal
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11Jadavsejal
 
C++ unit-1-part-10
C++ unit-1-part-10C++ unit-1-part-10
C++ unit-1-part-10Jadavsejal
 
C++ unit-1-part-9
C++ unit-1-part-9C++ unit-1-part-9
C++ unit-1-part-9Jadavsejal
 
C++ unit-1-part-8
C++ unit-1-part-8C++ unit-1-part-8
C++ unit-1-part-8Jadavsejal
 
C++ unit-1-part-7
C++ unit-1-part-7C++ unit-1-part-7
C++ unit-1-part-7Jadavsejal
 
C++ unit-1-part-6
C++ unit-1-part-6C++ unit-1-part-6
C++ unit-1-part-6Jadavsejal
 
C++ unit-1-part-5
C++ unit-1-part-5C++ unit-1-part-5
C++ unit-1-part-5Jadavsejal
 
C++ unit-1-part-4
C++ unit-1-part-4C++ unit-1-part-4
C++ unit-1-part-4Jadavsejal
 
C++ unit-1-part-2
C++ unit-1-part-2C++ unit-1-part-2
C++ unit-1-part-2Jadavsejal
 
C++ unit-1-part-3
C++ unit-1-part-3C++ unit-1-part-3
C++ unit-1-part-3Jadavsejal
 
C++-Unit-1-Part-1
C++-Unit-1-Part-1C++-Unit-1-Part-1
C++-Unit-1-Part-1Jadavsejal
 
05_system architecture
05_system architecture05_system architecture
05_system architectureJadavsejal
 

More from Jadavsejal (20)

Programming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassProgramming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone Class
 
C++ unit-2-part-3
C++ unit-2-part-3C++ unit-2-part-3
C++ unit-2-part-3
 
C++ unit-2-part-2
C++ unit-2-part-2C++ unit-2-part-2
C++ unit-2-part-2
 
C++ unit-2-part-1
C++ unit-2-part-1C++ unit-2-part-1
C++ unit-2-part-1
 
C++ unit-1-part-15
C++ unit-1-part-15C++ unit-1-part-15
C++ unit-1-part-15
 
C++ unit-1-part-14
C++ unit-1-part-14C++ unit-1-part-14
C++ unit-1-part-14
 
C++ unit-1-part-13
C++ unit-1-part-13C++ unit-1-part-13
C++ unit-1-part-13
 
C++ unit-1-part-12
C++ unit-1-part-12C++ unit-1-part-12
C++ unit-1-part-12
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
 
C++ unit-1-part-10
C++ unit-1-part-10C++ unit-1-part-10
C++ unit-1-part-10
 
C++ unit-1-part-9
C++ unit-1-part-9C++ unit-1-part-9
C++ unit-1-part-9
 
C++ unit-1-part-8
C++ unit-1-part-8C++ unit-1-part-8
C++ unit-1-part-8
 
C++ unit-1-part-7
C++ unit-1-part-7C++ unit-1-part-7
C++ unit-1-part-7
 
C++ unit-1-part-6
C++ unit-1-part-6C++ unit-1-part-6
C++ unit-1-part-6
 
C++ unit-1-part-5
C++ unit-1-part-5C++ unit-1-part-5
C++ unit-1-part-5
 
C++ unit-1-part-4
C++ unit-1-part-4C++ unit-1-part-4
C++ unit-1-part-4
 
C++ unit-1-part-2
C++ unit-1-part-2C++ unit-1-part-2
C++ unit-1-part-2
 
C++ unit-1-part-3
C++ unit-1-part-3C++ unit-1-part-3
C++ unit-1-part-3
 
C++-Unit-1-Part-1
C++-Unit-1-Part-1C++-Unit-1-Part-1
C++-Unit-1-Part-1
 
05_system architecture
05_system architecture05_system architecture
05_system architecture
 

Recently uploaded

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
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
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
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
 
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
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
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
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
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
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
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
 
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
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

concept of applet and concept of Layout Managers

  • 1. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav 1
  • 2. Prepared By: Asst. Prof. Sejal Jadav Unit-4 CS – 19 : Programming with Java UNIT – 4 Applets, Layout Manager B.C.A & B.SC.(IT) – 4
  • 3. Prepared By: Asst. Prof. Sejal Jadav Simple Applet program: • Example: Applet1.java • Compile: javac Applet1.java • Run: appletviewer sj.html
  • 4. Prepared By: Asst. Prof. Sejal Jadav Q-3 Explain Applet life cycle. • Each applet has a life cycle. So every time an applet is initialized it goes through four states and finally after its execution the applet is destroyed. • At those state the applet calls a set of methods in an order.
  • 5. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav
  • 6. Prepared By: Asst. Prof. Sejal Jadav • These methods are init(), start(), stop() and destroy(). • Those are methods defined by the applet class and one can override these methods as needed. • In addition to those four methods the paint() method is another method which is in the Component class of java.awt package. • Those methods are described below.
  • 7. Prepared By: Asst. Prof. Sejal Jadav The init() method: • The init() method is the first method called by an applet. • In this method the initialization process in done. • The variables, objects, background colors, fonts etc. are initialized in this method. • This method is called only once after an applet is created since initialization should be one only once.
  • 8. Prepared By: Asst. Prof. Sejal Jadav Its syntax is: public void init() { //initialized process }
  • 9. Prepared By: Asst. Prof. Sejal Jadav The start() method: • After the init() method, start() method is called. • This method start the applet. It is also called to restart the applet if it is stopped. • This method can be called more than once since it needs to restart each time it is stopped. • In a browser if you leave the applet page, the applet is stopped and when you again come back to that page it is restarted. Or when the applet window is minimized, it is stopped and as it is restored, the applet is restarted.
  • 10. Prepared By: Asst. Prof. Sejal Jadav The syntax of start) method is: public void start() { //the code to start applet }
  • 11. Prepared By: Asst. Prof. Sejal Jadav The paint() method: • The paint() method is of the component class which is in the java.awt package. • This method is called when the applet execution starts or the contents of applet needs to be redrawn. • The paint() method takes a parameter of type graphic class. This graphic object is used to draw the text or any shapes etc. in the applet window.
  • 12. Prepared By: Asst. Prof. Sejal Jadav • Its syntax is: public void paint(Graphic g) { //code to display in the applet }
  • 13. Prepared By: Asst. Prof. Sejal Jadav The stop() method: • The stop() method is called when you minimize the applet window or leave the applet page and go to another page in the browser. • If you are working with thread then you should block or suspend the thread when applet stops. • After stopping an applet it can be restarted by the start() method
  • 14. Prepared By: Asst. Prof. Sejal Jadav • Its syntax is: public void stop() { //statements…… }
  • 15. Prepared By: Asst. Prof. Sejal Jadav The destroy() method: • The destroy() method is called when your applet is to be terminated and needs to removed from the memory. • In this method you should do the cleanup of the object and other resource. • The destroy() method is called after the stop() method and is called only once.
  • 16. Prepared By: Asst. Prof. Sejal Jadav Its syntax is: public void destroy() { //code for finalization……. }
  • 17. Prepared By: Asst. Prof. Sejal Jadav • Example: • AppletMethodEx.java • AppletMethodEx.html
  • 18. Prepared By: Asst. Prof. Sejal Jadav Q-4 Explain Applet Class • Applets are created using the applet class which is in java.applet package. • To create applet program, you must extend the applet class. • The methods of applet class are listed below.
  • 19. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav METHOD Description void init() Initialize this applet void start() Starts this applet void stop() Stops this applet void destroy() Destroys this applet AppletContext getAppletContext() returns the Applet Context String getAppletInfo() It returns a string containing the applet information. URL getCodeBase() It returns the URL (path) of the applet class file. URL getDocumentBase() It returns the URL of the HTML document that executes the applet.
  • 20. Prepared By: Asst. Prof. Sejal Jadav • Example: Folder Applet Methods
  • 21. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav String getParameter(String paramName) It returns the value of parameter paramName. Boolean isActive() It returns true if the applet has been started and returns false if the applet has been stopped. void resize(int width,int height) It resize the applet according to the dimensions specified by width and height. void showStatus(String status) It display the status in the bar of the browser or applet viewer. If the browser does not support a status window, nothing happens.
  • 22. Prepared By: Asst. Prof. Sejal Jadav • Example: Folder Applet Methods
  • 23. Prepared By: Asst. Prof. Sejal Jadav Playing Audio Example public interface AudioClip • The AudioClip interface is a simple abstraction for playing a sound clip. Multiple AudioClip items can be playing at the same time, and the resulting sound is mixed together to produce a composite.
  • 24. Prepared By: Asst. Prof. Sejal Jadav There some Method Detail: • Example : PlaySoundApplet folder void play() Starts playing this audio clip. the clip is restarted from the beginning. void loop() Starts playing this audio clip in a loop. void stop() Stops playing this audio clip.
  • 25. Prepared By: Asst. Prof. Sejal Jadav Explain Graphic class. • The graphic class is in the java.awt package and it contains several methods that can help to perform graphics related operations in the applet. • Those methods include drawing text, lines and many different shapes. These methods are:
  • 26. Prepared By: Asst. Prof. Sejal Jadav • 1.void drawString(String msg, int x, int y) • The msg is displayed at the specified location specified by the x and y coordinates. • Ex:myapplet.java
  • 27. Prepared By: Asst. Prof. Sejal Jadav 2.void drawLine (int x1, int y1, int x2, int y2) • This method draws a line joining the points (x1,y1) and (x2,y2). • EX: shapeEx1.java
  • 28. Prepared By: Asst. Prof. Sejal Jadav 3.void drawRect (int x, int y, int width, int height) • This method draws a rectangle from the upper-left corner at the point (x,y) of the width and height specified by width and height. The rectangle is filled with the current color. • Ex:shapeEx3.java
  • 29. Prepared By: Asst. Prof. Sejal Jadav 4.void fillRect (int x, int y, int width, int height) • This method draws a rectangle from the upper-left corner at the point (x,y) of the width and height specified by width and height. The rectangle is filled with the current color. • Ex:shapeEx4.java
  • 30. Prepared By: Asst. Prof. Sejal Jadav 5.void drawOval (int x, int y, int width, int height) • This method draws an oval. The top-left corner of rectangle is the point (x,y) and its width and height are specified by width and height. To draw a circle the width and height should be same. • Ex:shapeEx5.java
  • 31. Prepared By: Asst. Prof. Sejal Jadav 6.void fillOval (int x, int y, int width, int height) • It draws and fills the oval with the color. • Ex:shapeEx6.java
  • 32. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav 7.void drawArc ( int x, int y, int width, int height, int startangle, int endAngle ) • This method draws an arc which is bounded by the rectangle. The rectangle’s top-left corner is point (x,y) and its width and height are specified by width and height. The arc is drawn from the startangle to the endAngle. Angles are is degrees. • Ex:shapeEx7.java
  • 33. Prepared By: Asst. Prof. Sejal Jadav 8.void fillArc ( int x, int y, int width, int height, int startAngle, int endAngle) • It draw and fills the arc with the color. • Ex:shapeEx7.java
  • 34. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav 9.void drawPolygon ( int x[], int y[], int numOfPoints) • This method draws a polygon of numOfpoint angles. • The polygon’s endpoints are specified by the x and y arrays. • It simply joins the points specified by the array specified by the array elements. • Means it joins the point ( x[0],y[0]) to the point (x[1],y[1]),then point ( x[2],y[2]) is joined to point (x[1],y[1]) and so on.
  • 35. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav drawPolygon ( int x[], int y[], int numOfPoints) • Ex:shapeEx8.java
  • 36. Prepared By: Asst. Prof. Sejal Jadav • 10. void fillPolygon (int x[], int y[], int numOfPoints) • It draws and fills the polygon with the color.
  • 37. Prepared By: Asst. Prof. Sejal Jadav Layout Managers Part-2
  • 38. Prepared By: Asst. Prof. Sejal Jadav Layout Managers • The Layout manager decides how the control should be arranged or positioned within a container or a window. It does so by using some algorithm or you can say a method. • In some languages like visual basic (VB) you can arrange your controls as you like using the form designer.
  • 39. Prepared By: Asst. Prof. Sejal Jadav • But in Java there is no such form designer, but you have to write the code to arrange the controls where you want them. • Some editors allow contain the layout tool that allows you to position your components like visual Basic. But it is necessary for us to know how this layout manager works.
  • 40. Prepared By: Asst. Prof. Sejal Jadav • To set the layout following method is used. void setLayout (LayoutManager obj) • The obj is an object of the specified layout manager. • If no layout manager is set by the setLayout() method, the default layout manager is used which is the FlowLayout.
  • 41. Prepared By: Asst. Prof. Sejal Jadav (1)FlowLayout • The FlowLayout is the default layout manager. i.e if no layout manager is set by the setLayout() method, this layout is used to arrange the controls in a container. • In this layout manager the components are arranged from the upper-left corner to the right side edge of the container. When there is no space for the component it is arranged from the next line. A little space is added between each component at all of the four sides.
  • 42. Prepared By: Asst. Prof. Sejal Jadav The constructors for this class are: • FlowLayout() • FlowLayout(int align) • FlowLayout(int align, hspace, vspace) • Here the align parameter specified the alignment for the components. Like: • FlowLayout(FlowLayout.RIGHT) • FlowLayout(FlowLayout.CENTER) • FlowLayout(FlowLayout.LEFT)
  • 43. Prepared By: Asst. Prof. Sejal Jadav • The default is FlowLayout.CENTER • The hspace and vspace specifies the horizontal and vertical space between the components respectively. • The default space is 5 pixel from both horizontal and vertical. • Example: FlowLayoutEx.java
  • 44. Prepared By: Asst. Prof. Sejal Jadav (2)Border Layout • The BorderLayout arranges the components in five portions. • These portions are the four edges of the window and the fifth is the center part. • These portions are known as north, south, east, west and center. • These portions are specified by the following constants.
  • 45. Prepared By: Asst. Prof. Sejal Jadav • BorderLayout.NORTH: The top edge of the window. • BorderLayout.SOUTH: The bottom edge of the window. • BorderLayout.EAST: The right side edge of the window. • BorderLayout.WEST: The left side edge of the window. • BorderLayout.CENTER: The remaining center portion of the window.
  • 46. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav
  • 47. Prepared By: Asst. Prof. Sejal Jadav • Constructors for BorderLayout are: • BorderLayout() • BorderLayout(int hspace,int vspace) • Here hspace and vspace specify the horizontal and vertical spaces between the component. • After creating the BorderLayout object you can add components by the following method: void add(Component obj , Object where)
  • 48. Prepared By: Asst. Prof. Sejal Jadav Method is: • void add(Component obj , Object where) For Example: pane.add(new JButton("NORTH"),BorderLayout.NORTH); pane.add(new JButton("SOUTH"),BorderLayout.SOUTH); pane.add(new JButton("EAST"),BorderLayout.EAST); pane.add(new JButton("WEST"),BorderLayout.WEST);
  • 49. Prepared By: Asst. Prof. Sejal Jadav • Example: BorderLayoutEx.java
  • 50. Prepared By: Asst. Prof. Sejal Jadav (3)GridLayout • The GridLayout class creates a layout which has a grid of rows and columns. • The constructors for GridLayout are: • GridLayout() • GridLayout( int rows, int columns) • GridLayout( int rows, int columns, int hspace, int vspace)
  • 51. Prepared By: Asst. Prof. Sejal Jadav • The first constructor is the default constructor which will create only one column grid. • Here rows and columns specify the number of rows and columns of the grid and the hspace and vspace specify the horizontal and vertical spaces between the components.
  • 52. Prepared By: Asst. Prof. Sejal Jadav Example: GridLayoutEx.java
  • 53. Prepared By: Asst. Prof. Sejal Jadav Introduction to BoxLayout [only Theory] • The BoxLayout is used to arrange the components either vertically or horizontally. • For this purpose, BoxLayout provides four constants. • They are as follows: • Note: BoxLayout class is found in javax.swing package.
  • 54. Prepared By: Asst. Prof. Sejal Jadav • Fields of BoxLayout class: 1. public static final int X_AXIS 2. public static final int Y_AXIS 3. public static final int LINE_AXIS 4. public static final int PAGE_AXIS
  • 55. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav • BoxLayoutExample1.java
  • 56. Prepared By: Asst. Prof. Sejal Jadav Introduction to SpringLayout [only Theory] • A SpringLayout arranges the children of its associated container according to a set of constraints. Constraints are nothing but horizontal and vertical distance between two-component edges. • Every constraint is represented by a SpringLayout.Constraint object.
  • 57. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav
  • 58. Prepared By: Asst. Prof. Sejal Jadav Introduction to GroupLayout [only Theory] • The class GroupLayout hierarchically groups components in order to position them in a Container
  • 59. Prepared By: Asst. Prof. Sejal Jadav • GroupLayout groups its components and places them in a Container hierarchically. • The grouping is done by instances of the Group class. • Group is an abstract class, and two concrete classes which implement this Group class are SequentialGroup and ParallelGroup.
  • 60. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav
  • 61. Prepared By: Asst. Prof. Sejal Jadav • After unit-5 • Concepts: Swing component’s
  • 62. Prepared By: Asst. Prof. Sejal Jadav (4)Card Layout • The CardLayout has some special capabilities the other layout do not have. • The CardLayout creates a layout like the playing cards. • Assume more than one card on one another. • Here only the card on the top is visible at a time. But you can shuffle the cards to see other cards. • Some way the CardLayout can switch among several panels.
  • 63. Prepared By: Asst. Prof. Sejal Jadav The constructors for CardLayout are: • CardLayout() • CardLayout(int hspace, int vspace) • Here hspace and vspace specify the horizontal and vertical spaces between the component. • To add components or panels to the card Layout panel following method is used.
  • 64. Prepared By: Asst. Prof. Sejal Jadav void add(Component obj,ObjectpanelName) • Here the panelName is the name of the panel object. • After Defining the panel object you can show or shuffle the card panels by one or following methods.
  • 65. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Methods Description void show(Container panelobj, String panelName) It is show the panel specified by the panelobj and whose name is panelName. void first(Container panelObj) It shows the first card i.e. panel. void last(Container panelObj) It shows the last card i.e. panel. void next(Container panelObj) It shows the next card i.e. panel. void previous(Container panelObj) It shows the previous card i.e. panel.
  • 66. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav
  • 67. Prepared By: Asst. Prof. Sejal Jadav • Example:CardLayoutEx.java
  • 68. Prepared By: Asst. Prof. Sejal Jadav (5) GridBagLayout •GridBagLayout.pdf •Example: GridBagLayoutEx.java
  • 69. Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav Prepared By: Asst. Prof. Sejal Jadav 76