SlideShare una empresa de Scribd logo
1 de 8
QUESTION BANK
UNIT –I
Q.1 Write a Short note on “Event Listeners”?Explain the workingwith code specification.
Ans: 1. The Event listener represent the interfacesresponsibleto handleevents.Java providesusvariousEvent
listener classes
2. It is also known aseventhandler.Listeneris responsibleforgenerating responseto an event.
3. Fromjava implementation pointof view the listener is also an object.Listener waits until it receives an
event.Once theevent is received , the listener processthe event and then returns.
Code specification:
importjava.awt.*;
importjava.awt.event.*;//Using AWTeventsand listener interfaces
public class HELLO extendsFrameimplementsWindowListener{
HELLO() {
setLayout(new FlowLayout());
Button btnCount=newButton("ok");
add(btnCount);
addWindowListener(this);
setTitle("WindowEventDemo");
setSize(250, 100);
setVisible(true);
}
public static void main(String[] args){
HELLO h= newHELLO ();
}
public void windowClosing(WindowEvente) {
System.exit(0); //Terminatethe program
}
public void windowOpened(WindowEvente) { }
public void windowClosed(WindowEvente) { }
public void windowIconified(WindowEvente) { }
public void windowDeiconified(WindowEvente) { }
public void windowActivated(WindowEvente) { }
public void windowDeactivated(WindowEvente) { }
}
Q.2 How does AWTcreate radio buttons ? Explain with syntax & code specification.
Ans:  Radiobuttons givea more userfriendly environmentwhen theuserhasto select onlyone option
amongmany.
 There is no radio button classin java.awt package.
 AWT usesthe Checkbox classforboth check boxesand radio buttons.
 Radio buttonsarea group of checkboxesgrouped asoneunit.In the unit,if anotherradio button is
selected, theearlier gets automatically deselected.
 Becauseradio button isa check box,all the methodsillustrated in "Java AWTCheckbox" can beused
here.
 To create a radio button,you need to create check boxes,and add themto a checkbox group.
Code specification:
importjava.awt.*;
importjava.awt.event.*;
public class Demo3extendsFrameimplementsItemListener{
Label stLabel;
Demo3(){
setLayout(newFlowLayout());
CheckboxGroup fruitGroup=newCheckboxGroup();
Checkbox chkApple=new Checkbox("Apple",fruitGroup,true);
Checkbox chkMango =newCheckbox("Mango",fruitGroup,false);
Checkbox chkPeer= newCheckbox("Peer",fruitGroup,false);
add(chkApple);
add(chkMango);
add(chkPeer);
stLabel=newLabel();
add(stLabel);
chkApple.addItemListener(this);
chkMango.addItemListener(this);
chkPeer.addItemListener(this);
setTitle("WindowEventDemo");
setSize(250, 100);
setVisible(true);
}
public static void main(String[] args){
Demo3d=new Demo3();
}
public void itemStateChanged(ItemEvente) {
stLabel.setText(e.getItem()
+" Checkbox:"
+ (e.getStateChange()==1?"checked":"unchecked"));
}
}
Q.3 What is the defaultlayout of the frame?Explain the same.
Ans: 1. A containerhasa so-called layoutmanagerto arrangeitscomponents.Thelayoutmanagersprovidea
level of abstraction to map youruserinterface on all windowing systems,so thatthelayoutcan be
platform-independent.
2. AWT providesthefollowing layoutmanagers(in
packagejava.awt): FlowLayout, GridLayout, BorderLayout, GridBagLayout, BoxLayout, CardLayout,and
others.
3. DefaultLayoutof the frameis Border Layout
4. In java.awt.BorderLayout, thecontaineris divided into 5 zones:EAST, WEST, SOUTH, NORTH,
and CENTER.
5. Constructor:
 public BorderLayout();
 public BorderLayout(inthgap,intvgap);
6. Code Specification:
importjava.awt.*;
public class Demo extendsFrame{
Demo() {
setLayout(newBorderLayout(3,3));
ButtonbtnNorth= newButton("NORTH");
add(btnNorth, BorderLayout.NORTH);
ButtonbtnSouth= newButton("SOUTH");
add(btnSouth,BorderLayout.SOUTH);
ButtonbtnCenter= newButton("CENTER");
add(btnCenter,BorderLayout.CENTER);
ButtonbtnEast = newButton("EAST");
add(btnEast,BorderLayout.EAST);
ButtonbtnWest= newButton("WEST");
add(btnWest,BorderLayout.WEST);
setTitle("BorderLayoutDemo");//"this"Frame setstitle
setSize(280,150); // "this"Frame setsinitial size
setVisible(true); // "this"Frame shows
}
public static void main(String[] args) {
Demo d=new Demo();
}
}
Q.4 Write a java AWT program that creates the followingGUI( considerthe window closingevent)
Login Screen
Userid:
Passwd:
Ans:
importjava.awt.*;
public class LoginfrmextendsFrame implementsWindowListener{
Loginfrm(){
setLayout(new FlowLayout());
addWindowListener(this)
Label a = new Label("Userid :");
add(a);
TextField tf = newTextField("EnterUR name",10);
tf.setEditable(true);
add(tf);
Label b = newLabel("Passwd :");
add(b);
TextField tf1 = new TextField("EnterURname",5);
tf.setEditable(true);
add(tf1);
Button btn= new Button("SUBMIT");
add(btn);
Button btn1= newButton("CANCEL");
add(btn1);
setTitle("DemoForm");
setSize(300, 100);
setVisible(true);
}
public static void main(String[] args) {
Loginfrm d=new Loginfrm();
}
public void windowClosing(WindowEvente) {
System.exit(0); //Terminatethe program
}
public void windowOpened(WindowEvente) { }
public void windowClosed(WindowEvente) { }
public void windowIconified(WindowEvente) { }
CANCELSUBMIT
public void windowDeiconified(WindowEvente) { }
public void windowActivated(WindowEvente) { }
public void windowDeactivated(WindowEvente) { } }
Q.5 List differenttypesof layout manager ? ExplainGridLayout.
Ans: Sr.
No.
LayoutManager & Description
1
BorderLayout
The borderlayout arranges the components to fit in the five regions: east, west, north, south and
center.
2
CardLayout
The CardLayout object treats each component in the container as a card. Onlyone card is
visible at a time.
3
FlowLayout
The FlowLayout is the default layout.It layouts the components in a directionalflow.
4
GridLayout
The GridLayout manages the components in form of a rectangular grid.
5
GridBagLayout
This is the most flexible layout manager class.The object of GridBagLayout alignsthe
component vertically,horizontallyor along their baseline without requiringthe components of
same size.
GridLayout:
A GridLayoutobjectplacescomponentsin a grid of cells. Each componenttakesallthe availablespace within its
cell, and each cell is exactly the samesize. If the GridLayoutDemo window isresized, the GridLayoutobject
changesthecell size so thatthe cells are as large as possible,given the spaceavailableto the container.
GridLayoutDesign :
Q.6 Compare and contrast AWT& Swings
Ans:  AWT componentsarecalled HeavyWeight componentand Swingsarecalled ligth weightcomponent
becauseswing componentssitson thetop of AWT componentsand do thework.
 Swingscomponentsaremadein purely java and they are platformindependentwhereasAWT
compoentsareplatformdependent.
 We can havedifferentlookand feel in Swing whereasthis featureis notsupported in AWT.
 Swing hasmany advanced featureslikeJTabel,Jtabbed pane which isnot availablein awt
Q.7. Explainthe java EventDelegationmodel
Ans:
EventHandlingisthe mechanismthatcontrolsthe eventanddecideswhatshouldhappenif anevent
occurs. Thismechanismhas the code whichisknownas eventhandlerthatisexecuted whenanevent
occurs java Usesthe DelegationEventModel to handle the events. Thismodel definesthe standard
mechanismtogenerate andhandle the events.
The DelegationEventModel has the followingkeyparticipants namely:
 Source - The source is an objectonwhicheventoccurs.Source isresponsibleforprovidinginformation
of the occurredeventtoit's handler.Javaprovide aswithclassesforsource object.
 Listener- It isalsoknownas eventhandler.Listenerisresponsible forgeneratingresponse toanevent.
From javaimplementationpointof view the listenerisalsoanobject.Listenerwaitsuntilitreceivesan
event.Once the eventisreceived,the listenerprocessthe event andthenreturns.
The benefitof thisapproach isthat
 The user interface logiciscompletelyseparatedfromthe logicthatgeneratesthe event.
 The user interface elementisable todelegate the processingof aneventtothe separate piece of
code.
 In thismodel ,Listenerneedsto be registeredwiththe source objectsothat the listenercanreceive
the eventnotification.
 Thisis an efficientwayof handlingthe eventbecause the eventnotificationsare sentonlytothose
listenerthatwanttoreceive them.
Q.8. What are adapter classes? Whatare innerclasses? Explain withexamples.
Ans: Adapter Classes:
An adapterclass providesthedefaultimplementation of all methodsin an eventlistener interface.Adapter
classesare very usefulwhen you wantto processonly few of the eventsthatare handled by a particularevent
listenerinterface.You can definea new classby extending oneof theadapterclasses and implement only those
eventsrelevantto you.
Exampleof Adapter class:Here's a mouseadapterthatbeeps when themouseis clicked
importjava.awt.*;
importjava.awt.event.*;
public class MouseBeeperextendsMouseAdapter
{
public void mouseClicked(MouseEventevt)
{
Toolkit.getDefaultToolkit().beep();
}
}
By subclassing MouseAdapterratherthan implementing MouseListenerdirectly,you avoid having to writethe
methodsyou don'tactually need.You only overridethosethatyou plan to actually implement.
Inner Class:
Innerclasses are classwithin Class.Innerclass instancehasspecial relationship with Outer class.This special
relationship givesinner class accessto memberof outerclass asif they are thepart of outerclass.
Exampleof Inner class:
importjava.awt.Frame;
importjava.awt.event.WindowAdapter;
importjava.awt.event.WindowEvent;
public class FrameClosing3extendsFrame
{
publicFrameClosing3()
{
addWindowListener(newWindowAdapter()
{
public void windowClosing(WindowEvente)
{ System.exit(0);}
}
);
setTitle("Frame closing Style 3");
setSize(300, 300);
setVisible(true);
}
public static void main(String args[])
{
new FrameClosing3();
}
}
Q.9 What are differentoperationsthat can be carried out on frame windows?
Ans: A Frameis a top-levelwindowwitha title and a border.The size of the frameincludesany area designated for
the border.The dimensionsof theborderarea may be obtained using thegetInsetsmethod,however,since
these dimensionsareplatform-dependent,a valid insetsvaluecannotbe obtained untilthe frameis made
displayableby either calling packor show.The defaultlayoutfora frameis BorderLayout.
Operationsassociated withframe:
1. Add(Componentobj)
2. setLayout(LayoutManagerObject)
3. setSize(int,int)
4. setSize(Dimension ob)
5. setVisible(Boolean)
6. pack()/show()
Example:
importjava.awt.*;
public class NewMain extendsFrame{
NewMain(){
setLayout(new BorderLayout(3,3));
Button btnNorth=newButton("NORTH");
add(btnNorth,BorderLayout.NORTH);
Button btnSouth=newButton("SOUTH");
add(btnSouth,BorderLayout.SOUTH);
Button btnCenter= newButton("CENTER");
add(btnCenter,BorderLayout.CENTER);
Button btnEast= newButton("EAST");
add(btnEast,BorderLayout.EAST);
Button btnWest= new Button("WEST");
add(btnWest,BorderLayout.WEST);
setTitle("BorderLayoutDemo");//"this"Framesetstitle
setSize(280, 150); //"this" Framesets initial size
setVisible(true); //"this" Frameshows
}
public static void main(String[] args) {
NewMain nw=newNewMain();
}}

Más contenido relacionado

La actualidad más candente

Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's NewTed Pennings
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsIMC Institute
 
Apache Struts 2 Advance
Apache Struts 2 AdvanceApache Struts 2 Advance
Apache Struts 2 AdvanceEmprovise
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVCGuy Nir
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android OKirill Rozov
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC AnnotationsJordan Silva
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session ManagementFahad Golra
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in SpringSunil kumar Mohanty
 

La actualidad más candente (20)

Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom Tags
 
JSP Technology II
JSP Technology IIJSP Technology II
JSP Technology II
 
Apache Struts 2 Advance
Apache Struts 2 AdvanceApache Struts 2 Advance
Apache Struts 2 Advance
 
Hibernate III
Hibernate IIIHibernate III
Hibernate III
 
JEE5 New Features
JEE5 New FeaturesJEE5 New Features
JEE5 New Features
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
Struts course material
Struts course materialStruts course material
Struts course material
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android O
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
 
Jpa 2.1 Application Development
Jpa 2.1 Application DevelopmentJpa 2.1 Application Development
Jpa 2.1 Application Development
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in Spring
 
Servlets lecture1
Servlets lecture1Servlets lecture1
Servlets lecture1
 
Chap4 4 1
Chap4 4 1Chap4 4 1
Chap4 4 1
 

Destacado

Παρουσίαση για πρόγραμμα του Γυμνασίου Σπηλίου
Παρουσίαση για πρόγραμμα του Γυμνασίου ΣπηλίουΠαρουσίαση για πρόγραμμα του Γυμνασίου Σπηλίου
Παρουσίαση για πρόγραμμα του Γυμνασίου Σπηλίουvaggreth
 
Amr Farag CV
Amr Farag CVAmr Farag CV
Amr Farag CVAmr Farag
 
Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...
Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...
Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...tartleader4357
 
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez AnsaryInternship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez AnsaryMoez Ansary
 
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary Moez Ansary
 
Community Development Through Cooperative in Ethiopia
Community Development Through Cooperative in EthiopiaCommunity Development Through Cooperative in Ethiopia
Community Development Through Cooperative in Ethiopiasintayehu chokolu
 
Computer institute website(TYIT project)
Computer institute website(TYIT project)Computer institute website(TYIT project)
Computer institute website(TYIT project)Lokesh Singrol
 
HP Software Testing project (Advanced)
HP Software Testing project (Advanced)HP Software Testing project (Advanced)
HP Software Testing project (Advanced)Lokesh Singrol
 
Project black book TYIT
Project black book TYITProject black book TYIT
Project black book TYITLokesh Singrol
 

Destacado (20)

Pra taruna
Pra tarunaPra taruna
Pra taruna
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 
TY.BSc.IT Java QB U2
TY.BSc.IT Java QB U2TY.BSc.IT Java QB U2
TY.BSc.IT Java QB U2
 
Pat
PatPat
Pat
 
Παρουσίαση για πρόγραμμα του Γυμνασίου Σπηλίου
Παρουσίαση για πρόγραμμα του Γυμνασίου ΣπηλίουΠαρουσίαση για πρόγραμμα του Γυμνασίου Σπηλίου
Παρουσίαση για πρόγραμμα του Γυμνασίου Σπηλίου
 
Amr Farag CV
Amr Farag CVAmr Farag CV
Amr Farag CV
 
OSF BROCHURE FINAL ORIGINAL
OSF BROCHURE FINAL ORIGINALOSF BROCHURE FINAL ORIGINAL
OSF BROCHURE FINAL ORIGINAL
 
4
44
4
 
Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...
Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...
Toyota Industrial Equipment to Partner With I.D. Systems on New Wireless Vehi...
 
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez AnsaryInternship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
 
майстер клас. 07
майстер клас. 07майстер клас. 07
майстер клас. 07
 
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
Internship Report on Financial Statements Analysis of FSIBL by Moez Ansary
 
Community Development Through Cooperative in Ethiopia
Community Development Through Cooperative in EthiopiaCommunity Development Through Cooperative in Ethiopia
Community Development Through Cooperative in Ethiopia
 
TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6
 
TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5
 
HLW Report Shahnawaz Lodhi
HLW Report Shahnawaz LodhiHLW Report Shahnawaz Lodhi
HLW Report Shahnawaz Lodhi
 
Sosok pilihan
Sosok pilihanSosok pilihan
Sosok pilihan
 
Computer institute website(TYIT project)
Computer institute website(TYIT project)Computer institute website(TYIT project)
Computer institute website(TYIT project)
 
HP Software Testing project (Advanced)
HP Software Testing project (Advanced)HP Software Testing project (Advanced)
HP Software Testing project (Advanced)
 
Project black book TYIT
Project black book TYITProject black book TYIT
Project black book TYIT
 

Similar a TY.BSc.IT Java QB U1

event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptxGood657694
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comKeatonJennings91
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO Yehuda Katz
 
Organizing jQuery Projects Without OO
Organizing jQuery Projects Without OOOrganizing jQuery Projects Without OO
Organizing jQuery Projects Without OOYehuda Katz
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.pptAnkitPangasa1
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.pptbryafaissal
 
PATTERNS06 - The .NET Event Model
PATTERNS06 - The .NET Event ModelPATTERNS06 - The .NET Event Model
PATTERNS06 - The .NET Event ModelMichael Heron
 
Android - Preventing common memory leaks
Android - Preventing common memory leaksAndroid - Preventing common memory leaks
Android - Preventing common memory leaksAli Muzaffar
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developersPavel Lahoda
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon Berlin
 
Chap 1.5 - Java Documentation.pdf
Chap 1.5 - Java Documentation.pdfChap 1.5 - Java Documentation.pdf
Chap 1.5 - Java Documentation.pdfssuser2c5ec41
 
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180Mahmoud Samir Fayed
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2Leonid Maslov
 

Similar a TY.BSc.IT Java QB U1 (20)

event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.com
 
Diifeerences In C#
Diifeerences In C#Diifeerences In C#
Diifeerences In C#
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO
 
Organizing jQuery Projects Without OO
Organizing jQuery Projects Without OOOrganizing jQuery Projects Without OO
Organizing jQuery Projects Without OO
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.ppt
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.ppt
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
PATTERNS06 - The .NET Event Model
PATTERNS06 - The .NET Event ModelPATTERNS06 - The .NET Event Model
PATTERNS06 - The .NET Event Model
 
Android - Preventing common memory leaks
Android - Preventing common memory leaksAndroid - Preventing common memory leaks
Android - Preventing common memory leaks
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
Chap 1.5 - Java Documentation.pdf
Chap 1.5 - Java Documentation.pdfChap 1.5 - Java Documentation.pdf
Chap 1.5 - Java Documentation.pdf
 
C++ to java
C++ to javaC++ to java
C++ to java
 
Exercises
ExercisesExercises
Exercises
 
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180
 
GWT MVP Case Study
GWT MVP Case StudyGWT MVP Case Study
GWT MVP Case Study
 
Graphical User Components Part 1
Graphical User Components Part 1Graphical User Components Part 1
Graphical User Components Part 1
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 

Más de Lokesh Singrol

Top Technology product failure
Top Technology product failureTop Technology product failure
Top Technology product failureLokesh Singrol
 
Testing project (basic)
Testing project (basic)Testing project (basic)
Testing project (basic)Lokesh Singrol
 
Computer institute Website(TYIT project)
Computer institute Website(TYIT project)Computer institute Website(TYIT project)
Computer institute Website(TYIT project)Lokesh Singrol
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)Lokesh Singrol
 
Desktop system,clustered system,Handheld system
Desktop system,clustered system,Handheld systemDesktop system,clustered system,Handheld system
Desktop system,clustered system,Handheld systemLokesh Singrol
 

Más de Lokesh Singrol (10)

MCLS 45 Lab Manual
MCLS 45 Lab ManualMCLS 45 Lab Manual
MCLS 45 Lab Manual
 
MCSL 036 (Jan 2018)
MCSL 036 (Jan 2018)MCSL 036 (Jan 2018)
MCSL 036 (Jan 2018)
 
Top Technology product failure
Top Technology product failureTop Technology product failure
Top Technology product failure
 
Testing project (basic)
Testing project (basic)Testing project (basic)
Testing project (basic)
 
Computer institute Website(TYIT project)
Computer institute Website(TYIT project)Computer institute Website(TYIT project)
Computer institute Website(TYIT project)
 
Trees and graphs
Trees and graphsTrees and graphs
Trees and graphs
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)
 
Desktop system,clustered system,Handheld system
Desktop system,clustered system,Handheld systemDesktop system,clustered system,Handheld system
Desktop system,clustered system,Handheld system
 
Raster Scan display
Raster Scan displayRaster Scan display
Raster Scan display
 
Flash memory
Flash memoryFlash memory
Flash memory
 

Último

GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 

Último (20)

YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 

TY.BSc.IT Java QB U1

  • 1. QUESTION BANK UNIT –I Q.1 Write a Short note on “Event Listeners”?Explain the workingwith code specification. Ans: 1. The Event listener represent the interfacesresponsibleto handleevents.Java providesusvariousEvent listener classes 2. It is also known aseventhandler.Listeneris responsibleforgenerating responseto an event. 3. Fromjava implementation pointof view the listener is also an object.Listener waits until it receives an event.Once theevent is received , the listener processthe event and then returns. Code specification: importjava.awt.*; importjava.awt.event.*;//Using AWTeventsand listener interfaces public class HELLO extendsFrameimplementsWindowListener{ HELLO() { setLayout(new FlowLayout()); Button btnCount=newButton("ok"); add(btnCount); addWindowListener(this); setTitle("WindowEventDemo"); setSize(250, 100); setVisible(true); } public static void main(String[] args){ HELLO h= newHELLO (); } public void windowClosing(WindowEvente) { System.exit(0); //Terminatethe program } public void windowOpened(WindowEvente) { } public void windowClosed(WindowEvente) { } public void windowIconified(WindowEvente) { } public void windowDeiconified(WindowEvente) { } public void windowActivated(WindowEvente) { } public void windowDeactivated(WindowEvente) { }
  • 2. } Q.2 How does AWTcreate radio buttons ? Explain with syntax & code specification. Ans:  Radiobuttons givea more userfriendly environmentwhen theuserhasto select onlyone option amongmany.  There is no radio button classin java.awt package.  AWT usesthe Checkbox classforboth check boxesand radio buttons.  Radio buttonsarea group of checkboxesgrouped asoneunit.In the unit,if anotherradio button is selected, theearlier gets automatically deselected.  Becauseradio button isa check box,all the methodsillustrated in "Java AWTCheckbox" can beused here.  To create a radio button,you need to create check boxes,and add themto a checkbox group. Code specification: importjava.awt.*; importjava.awt.event.*; public class Demo3extendsFrameimplementsItemListener{ Label stLabel; Demo3(){ setLayout(newFlowLayout()); CheckboxGroup fruitGroup=newCheckboxGroup(); Checkbox chkApple=new Checkbox("Apple",fruitGroup,true); Checkbox chkMango =newCheckbox("Mango",fruitGroup,false); Checkbox chkPeer= newCheckbox("Peer",fruitGroup,false); add(chkApple); add(chkMango); add(chkPeer); stLabel=newLabel(); add(stLabel); chkApple.addItemListener(this); chkMango.addItemListener(this); chkPeer.addItemListener(this); setTitle("WindowEventDemo"); setSize(250, 100); setVisible(true); } public static void main(String[] args){ Demo3d=new Demo3(); } public void itemStateChanged(ItemEvente) { stLabel.setText(e.getItem() +" Checkbox:" + (e.getStateChange()==1?"checked":"unchecked")); } }
  • 3. Q.3 What is the defaultlayout of the frame?Explain the same. Ans: 1. A containerhasa so-called layoutmanagerto arrangeitscomponents.Thelayoutmanagersprovidea level of abstraction to map youruserinterface on all windowing systems,so thatthelayoutcan be platform-independent. 2. AWT providesthefollowing layoutmanagers(in packagejava.awt): FlowLayout, GridLayout, BorderLayout, GridBagLayout, BoxLayout, CardLayout,and others. 3. DefaultLayoutof the frameis Border Layout 4. In java.awt.BorderLayout, thecontaineris divided into 5 zones:EAST, WEST, SOUTH, NORTH, and CENTER. 5. Constructor:  public BorderLayout();  public BorderLayout(inthgap,intvgap); 6. Code Specification: importjava.awt.*; public class Demo extendsFrame{ Demo() { setLayout(newBorderLayout(3,3)); ButtonbtnNorth= newButton("NORTH"); add(btnNorth, BorderLayout.NORTH); ButtonbtnSouth= newButton("SOUTH"); add(btnSouth,BorderLayout.SOUTH); ButtonbtnCenter= newButton("CENTER"); add(btnCenter,BorderLayout.CENTER); ButtonbtnEast = newButton("EAST"); add(btnEast,BorderLayout.EAST); ButtonbtnWest= newButton("WEST"); add(btnWest,BorderLayout.WEST); setTitle("BorderLayoutDemo");//"this"Frame setstitle setSize(280,150); // "this"Frame setsinitial size setVisible(true); // "this"Frame shows } public static void main(String[] args) { Demo d=new Demo(); } }
  • 4. Q.4 Write a java AWT program that creates the followingGUI( considerthe window closingevent) Login Screen Userid: Passwd: Ans: importjava.awt.*; public class LoginfrmextendsFrame implementsWindowListener{ Loginfrm(){ setLayout(new FlowLayout()); addWindowListener(this) Label a = new Label("Userid :"); add(a); TextField tf = newTextField("EnterUR name",10); tf.setEditable(true); add(tf); Label b = newLabel("Passwd :"); add(b); TextField tf1 = new TextField("EnterURname",5); tf.setEditable(true); add(tf1); Button btn= new Button("SUBMIT"); add(btn); Button btn1= newButton("CANCEL"); add(btn1); setTitle("DemoForm"); setSize(300, 100); setVisible(true); } public static void main(String[] args) { Loginfrm d=new Loginfrm(); } public void windowClosing(WindowEvente) { System.exit(0); //Terminatethe program } public void windowOpened(WindowEvente) { } public void windowClosed(WindowEvente) { } public void windowIconified(WindowEvente) { } CANCELSUBMIT
  • 5. public void windowDeiconified(WindowEvente) { } public void windowActivated(WindowEvente) { } public void windowDeactivated(WindowEvente) { } } Q.5 List differenttypesof layout manager ? ExplainGridLayout. Ans: Sr. No. LayoutManager & Description 1 BorderLayout The borderlayout arranges the components to fit in the five regions: east, west, north, south and center. 2 CardLayout The CardLayout object treats each component in the container as a card. Onlyone card is visible at a time. 3 FlowLayout The FlowLayout is the default layout.It layouts the components in a directionalflow. 4 GridLayout The GridLayout manages the components in form of a rectangular grid. 5 GridBagLayout This is the most flexible layout manager class.The object of GridBagLayout alignsthe component vertically,horizontallyor along their baseline without requiringthe components of same size. GridLayout: A GridLayoutobjectplacescomponentsin a grid of cells. Each componenttakesallthe availablespace within its cell, and each cell is exactly the samesize. If the GridLayoutDemo window isresized, the GridLayoutobject changesthecell size so thatthe cells are as large as possible,given the spaceavailableto the container. GridLayoutDesign : Q.6 Compare and contrast AWT& Swings Ans:  AWT componentsarecalled HeavyWeight componentand Swingsarecalled ligth weightcomponent becauseswing componentssitson thetop of AWT componentsand do thework.  Swingscomponentsaremadein purely java and they are platformindependentwhereasAWT compoentsareplatformdependent.  We can havedifferentlookand feel in Swing whereasthis featureis notsupported in AWT.  Swing hasmany advanced featureslikeJTabel,Jtabbed pane which isnot availablein awt Q.7. Explainthe java EventDelegationmodel Ans: EventHandlingisthe mechanismthatcontrolsthe eventanddecideswhatshouldhappenif anevent
  • 6. occurs. Thismechanismhas the code whichisknownas eventhandlerthatisexecuted whenanevent occurs java Usesthe DelegationEventModel to handle the events. Thismodel definesthe standard mechanismtogenerate andhandle the events. The DelegationEventModel has the followingkeyparticipants namely:  Source - The source is an objectonwhicheventoccurs.Source isresponsibleforprovidinginformation of the occurredeventtoit's handler.Javaprovide aswithclassesforsource object.  Listener- It isalsoknownas eventhandler.Listenerisresponsible forgeneratingresponse toanevent. From javaimplementationpointof view the listenerisalsoanobject.Listenerwaitsuntilitreceivesan event.Once the eventisreceived,the listenerprocessthe event andthenreturns. The benefitof thisapproach isthat  The user interface logiciscompletelyseparatedfromthe logicthatgeneratesthe event.  The user interface elementisable todelegate the processingof aneventtothe separate piece of code.  In thismodel ,Listenerneedsto be registeredwiththe source objectsothat the listenercanreceive the eventnotification.  Thisis an efficientwayof handlingthe eventbecause the eventnotificationsare sentonlytothose listenerthatwanttoreceive them. Q.8. What are adapter classes? Whatare innerclasses? Explain withexamples. Ans: Adapter Classes: An adapterclass providesthedefaultimplementation of all methodsin an eventlistener interface.Adapter classesare very usefulwhen you wantto processonly few of the eventsthatare handled by a particularevent listenerinterface.You can definea new classby extending oneof theadapterclasses and implement only those eventsrelevantto you. Exampleof Adapter class:Here's a mouseadapterthatbeeps when themouseis clicked importjava.awt.*; importjava.awt.event.*; public class MouseBeeperextendsMouseAdapter { public void mouseClicked(MouseEventevt) { Toolkit.getDefaultToolkit().beep(); } } By subclassing MouseAdapterratherthan implementing MouseListenerdirectly,you avoid having to writethe methodsyou don'tactually need.You only overridethosethatyou plan to actually implement. Inner Class: Innerclasses are classwithin Class.Innerclass instancehasspecial relationship with Outer class.This special relationship givesinner class accessto memberof outerclass asif they are thepart of outerclass. Exampleof Inner class: importjava.awt.Frame; importjava.awt.event.WindowAdapter; importjava.awt.event.WindowEvent;
  • 7. public class FrameClosing3extendsFrame { publicFrameClosing3() { addWindowListener(newWindowAdapter() { public void windowClosing(WindowEvente) { System.exit(0);} } ); setTitle("Frame closing Style 3"); setSize(300, 300); setVisible(true); } public static void main(String args[]) { new FrameClosing3(); } } Q.9 What are differentoperationsthat can be carried out on frame windows? Ans: A Frameis a top-levelwindowwitha title and a border.The size of the frameincludesany area designated for the border.The dimensionsof theborderarea may be obtained using thegetInsetsmethod,however,since these dimensionsareplatform-dependent,a valid insetsvaluecannotbe obtained untilthe frameis made displayableby either calling packor show.The defaultlayoutfora frameis BorderLayout. Operationsassociated withframe: 1. Add(Componentobj) 2. setLayout(LayoutManagerObject) 3. setSize(int,int) 4. setSize(Dimension ob) 5. setVisible(Boolean) 6. pack()/show() Example: importjava.awt.*; public class NewMain extendsFrame{ NewMain(){ setLayout(new BorderLayout(3,3)); Button btnNorth=newButton("NORTH"); add(btnNorth,BorderLayout.NORTH); Button btnSouth=newButton("SOUTH"); add(btnSouth,BorderLayout.SOUTH); Button btnCenter= newButton("CENTER"); add(btnCenter,BorderLayout.CENTER); Button btnEast= newButton("EAST"); add(btnEast,BorderLayout.EAST); Button btnWest= new Button("WEST"); add(btnWest,BorderLayout.WEST);
  • 8. setTitle("BorderLayoutDemo");//"this"Framesetstitle setSize(280, 150); //"this" Framesets initial size setVisible(true); //"this" Frameshows } public static void main(String[] args) { NewMain nw=newNewMain(); }}