SlideShare uma empresa Scribd logo
1 de 18
Quiz Application using Swings
BY
SANA MATEEN
Containers
• A container holds a group of components.
• Thus, a container is a special type of component that is designed to hold other
components.
• Furthermore, in order for a component to be displayed, it must be held within
a container.
• Thus, all Swing GUIs will have at least one container.
• Because containers are components, a container can also hold other
containers.
• This enables Swing to define what is called a containment hierarchy, at the top
of which must be a top-level container.
• Swing defines two types of containers.
• The first are top-level containers: JFrame, JApplet, JWindow, and JDialog.
These containers do not inherit JComponent. They do, however, inherit the
AWT classes Component and Container. Unlike Swing’s other components,
which are lightweight, the top-level containers are heavyweight. This makes
the top-level containers a special case in the Swing component library.
Java JFrame
• The javax.swing.JFrame class is a type of container which inherits the
java.awt.Frame class. JFrame works like the main window where
components like labels, buttons, textfields are added to create a GUI.
• Unlike Frame, JFrame has the option to hide or close the window with the
help of setDefaultCloseOperation(int) method.
Constructor Description
JFrame() It constructs a new frame that is initially
invisible.
JFrame(GraphicsConfiguration gc) It creates a Frame in the specified
GraphicsConfiguration of a screen device and
a blank title.
JFrame(String title) It creates a new, initially invisible Frame
with the specified title.
JFrame(String title,
GraphicsConfiguration gc)
It creates a JFrame with the specified title
and the specified GraphicsConfiguration of a
screen device.
JLabel
• The class JLabel can display either text, an image, or both. Label's
contents are aligned by setting the vertical and horizontal alignment in its
display area. By default, labels are vertically centered in their display area.
Text-only labels are leading edge aligned, by default; image-only labels are
horizontally centered, by default.
• Following is the declaration for javax.swing.JLabel class −
• public class JLabel extends JComponent implements SwingConstants,
Accessible
Constructor Description
JLabel() Creates a JLabel instance with no image and
with an empty string for the title.
JLabel(String s) Creates a JLabel instance with the specified
text.
JLabel(Icon i) Creates a JLabel instance with the specified
image.
JLabel(String s, Icon i, int
horizontalAlignment)
Creates a JLabel instance with the specified
text, image, and horizontal alignment.
Constructor & Description
1
JLabel()
Creates a JLabel instance with no image and with an empty
string for the title.
2
JLabel(Icon image)
Creates a JLabel instance with the specified image.
3
JLabel(Icon image, int horizontalAlignment)
Creates a JLabel instance with the specified image and
horizontal alignment.
4
JLabel(String text)
Creates a JLabel instance with the specified text.
5
JLabel(String text, Icon icon, int horizontalAlignment)
Creates a JLabel instance with the specified text, image, and
horizontal alignment.
6
JLabel(String text, int horizontalAlignment)
Creates a JLabel instance with the specified text and horizontal
alignment.
Java JPanel
• The JPanel is a simplest container class. It provides space in which an
application can attach any other component. It inherits the JComponents
class.
• It doesn't have title bar.
• JPanel class declaration
• public class JPanel extends JComponent implements Accessible
Constructor Description
JPanel() It is used to create a new JPanel
with a double buffer and a flow
layout.
JPanel(boolean
isDoubleBuffered)
It is used to create a new JPanel
with FlowLayout and the specified
buffering strategy.
JPanel(LayoutManager
layout)
It is used to create a new JPanel
with the specified layout manager.
JRadioButton
• The JRadioButton class is used to create a radio button. It is used to choose one
option from multiple options. It is widely used in exam systems or quiz.
• It should be added in ButtonGroup to select one radio button only.
• JRadioButton class declaration
• Let's see the declaration for javax.swing.JRadioButton class.
• public class JRadioButton extends JToggleButton implements Accessible
Constructor Description
JRadioButton() Creates an unselected radio
button with no text.
JRadioButton(String s) Creates an unselected radio
button with specified text.
JRadioButton(String s, boolean
selected)
Creates a radio button with the
specified text and selected
status.
Elements are then added to the button group via the following
method:
void add(AbstractButton ab)
Here, ab is a reference to the button to be added to the group.
A JRadioButton generates action events, item events, and change
events each time the button selection changes.
Most often, it is the action event that is handled, which means that
you will normally implement the ActionListener interface.
Java JButton
• The JButton class is used to create a labeled button that has platform
independent implementation.
• The application result in some action when the button is pushed. It
inherits AbstractButton class.
• JButton class declaration
• void setIcon(Icon b)It is used to set the specified Icon on the button.
• public class JButton extends AbstractButton implements Accessible
Constructor Description
JButton() It creates a button with no text and icon.
JButton(String s) It creates a button with the specified text.
JButton(Icon i) It creates a button with the specified icon
object.
Java JTabbedPane
• The JTabbedPane class is used to switch between a group of components
by clicking on a tab with a given title or icon. It inherits JComponent class.
• JTabbedPane class declaration
• Let's see the declaration for javax.swing.JTabbedPane class.
• public class JTabbedPane extends JComponent implements Serializable, A
ccessible, SwingConstants
Constructor Description
JTabbedPane() Creates an empty TabbedPane
with a default tab placement of
JTabbedPane.Top.
JTabbedPane(int tabPlacement) Creates an empty TabbedPane
with a specified tab placement.
JTabbedPane(int tabPlacement,
int tabLayoutPolicy)
Creates an empty TabbedPane
with a specified tab placement
and tab layout policy.
Java JDialog
• The JDialog control represents a top level window with a border and a title
used to take some form of input from the user. It inherits the Dialog class.
• Unlike JFrame, it doesn't have maximize and minimize buttons.
• JDialog class declaration
• Let's see the declaration for javax.swing.JDialog class.
• public class JDialog extends Dialog implements WindowConstants, Accessible,
RootPaneContainer
Constructor Description
JDialog() It is used to create a modeless
dialog without a title and without
a specified Frame owner.
JDialog(Frame owner) It is used to create a modeless
dialog with specified Frame as its
owner and an empty title.
JDialog(Frame owner, String title,
boolean modal)
It is used to create a dialog with
the specified title, owner Frame
and modality.
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)

Mais conteúdo relacionado

Mais procurados

Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
Narayana Swamy
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
PRN USM
 

Mais procurados (20)

Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
 
Java swing
Java swingJava swing
Java swing
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
 
PDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTPDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPT
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
 
Java awt
Java awtJava awt
Java awt
 
Gui
GuiGui
Gui
 
Swing
SwingSwing
Swing
 
Java awt tutorial javatpoint
Java awt tutorial   javatpointJava awt tutorial   javatpoint
Java awt tutorial javatpoint
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
Graphic Programming
Graphic ProgrammingGraphic Programming
Graphic Programming
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Console to GUI
Console to GUIConsole to GUI
Console to GUI
 

Destaque (13)

Jsp elements
Jsp elementsJsp elements
Jsp elements
 
Reading init param
Reading init paramReading init param
Reading init param
 
Http request and http response
Http request and http responseHttp request and http response
Http request and http response
 
Xml schema
Xml schemaXml schema
Xml schema
 
Dom parser
Dom parserDom parser
Dom parser
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Xml dom
Xml domXml dom
Xml dom
 
Jdbc in servlets
Jdbc in servletsJdbc in servlets
Jdbc in servlets
 
Understanding layout managers
Understanding layout managersUnderstanding layout managers
Understanding layout managers
 
Using cookies and sessions
Using cookies and sessionsUsing cookies and sessions
Using cookies and sessions
 
Xhtml
XhtmlXhtml
Xhtml
 
Intro xml
Intro xmlIntro xml
Intro xml
 
Events1
Events1Events1
Events1
 

Semelhante a Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)

Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptx
TadeseBeyene
 

Semelhante a Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel) (20)

13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
DSJ_Unit III.pdf
DSJ_Unit III.pdfDSJ_Unit III.pdf
DSJ_Unit III.pdf
 
Swing
SwingSwing
Swing
 
Swings
SwingsSwings
Swings
 
Swing basics
Swing basicsSwing basics
Swing basics
 
Advanced java programming
Advanced java programmingAdvanced java programming
Advanced java programming
 
Unit-2 swing and mvc architecture
Unit-2 swing and mvc architectureUnit-2 swing and mvc architecture
Unit-2 swing and mvc architecture
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
JAVA Jcheckbox in simple and easy .pptx
JAVA Jcheckbox in simple and  easy .pptxJAVA Jcheckbox in simple and  easy .pptx
JAVA Jcheckbox in simple and easy .pptx
 
SWING USING JAVA WITH VARIOUS COMPONENTS
SWING USING  JAVA WITH VARIOUS COMPONENTSSWING USING  JAVA WITH VARIOUS COMPONENTS
SWING USING JAVA WITH VARIOUS COMPONENTS
 
Programming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event HandlingProgramming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event Handling
 
Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptx
 
GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
JAVA Programming: Topic -AWT(Abstract Window Tool )
JAVA Programming: Topic -AWT(Abstract Window Tool )JAVA Programming: Topic -AWT(Abstract Window Tool )
JAVA Programming: Topic -AWT(Abstract Window Tool )
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managers
 
11basic Swing
11basic Swing11basic Swing
11basic Swing
 
Java Swing
Java SwingJava Swing
Java Swing
 
JavaAdvUnit-1.pptx
JavaAdvUnit-1.pptxJavaAdvUnit-1.pptx
JavaAdvUnit-1.pptx
 

Último

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 

Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup,jpanel)

  • 1. Quiz Application using Swings BY SANA MATEEN
  • 2. Containers • A container holds a group of components. • Thus, a container is a special type of component that is designed to hold other components. • Furthermore, in order for a component to be displayed, it must be held within a container. • Thus, all Swing GUIs will have at least one container. • Because containers are components, a container can also hold other containers. • This enables Swing to define what is called a containment hierarchy, at the top of which must be a top-level container. • Swing defines two types of containers. • The first are top-level containers: JFrame, JApplet, JWindow, and JDialog. These containers do not inherit JComponent. They do, however, inherit the AWT classes Component and Container. Unlike Swing’s other components, which are lightweight, the top-level containers are heavyweight. This makes the top-level containers a special case in the Swing component library.
  • 3. Java JFrame • The javax.swing.JFrame class is a type of container which inherits the java.awt.Frame class. JFrame works like the main window where components like labels, buttons, textfields are added to create a GUI. • Unlike Frame, JFrame has the option to hide or close the window with the help of setDefaultCloseOperation(int) method. Constructor Description JFrame() It constructs a new frame that is initially invisible. JFrame(GraphicsConfiguration gc) It creates a Frame in the specified GraphicsConfiguration of a screen device and a blank title. JFrame(String title) It creates a new, initially invisible Frame with the specified title. JFrame(String title, GraphicsConfiguration gc) It creates a JFrame with the specified title and the specified GraphicsConfiguration of a screen device.
  • 4. JLabel • The class JLabel can display either text, an image, or both. Label's contents are aligned by setting the vertical and horizontal alignment in its display area. By default, labels are vertically centered in their display area. Text-only labels are leading edge aligned, by default; image-only labels are horizontally centered, by default. • Following is the declaration for javax.swing.JLabel class − • public class JLabel extends JComponent implements SwingConstants, Accessible Constructor Description JLabel() Creates a JLabel instance with no image and with an empty string for the title. JLabel(String s) Creates a JLabel instance with the specified text. JLabel(Icon i) Creates a JLabel instance with the specified image. JLabel(String s, Icon i, int horizontalAlignment) Creates a JLabel instance with the specified text, image, and horizontal alignment.
  • 5. Constructor & Description 1 JLabel() Creates a JLabel instance with no image and with an empty string for the title. 2 JLabel(Icon image) Creates a JLabel instance with the specified image. 3 JLabel(Icon image, int horizontalAlignment) Creates a JLabel instance with the specified image and horizontal alignment. 4 JLabel(String text) Creates a JLabel instance with the specified text. 5 JLabel(String text, Icon icon, int horizontalAlignment) Creates a JLabel instance with the specified text, image, and horizontal alignment. 6 JLabel(String text, int horizontalAlignment) Creates a JLabel instance with the specified text and horizontal alignment.
  • 6. Java JPanel • The JPanel is a simplest container class. It provides space in which an application can attach any other component. It inherits the JComponents class. • It doesn't have title bar. • JPanel class declaration • public class JPanel extends JComponent implements Accessible Constructor Description JPanel() It is used to create a new JPanel with a double buffer and a flow layout. JPanel(boolean isDoubleBuffered) It is used to create a new JPanel with FlowLayout and the specified buffering strategy. JPanel(LayoutManager layout) It is used to create a new JPanel with the specified layout manager.
  • 7. JRadioButton • The JRadioButton class is used to create a radio button. It is used to choose one option from multiple options. It is widely used in exam systems or quiz. • It should be added in ButtonGroup to select one radio button only. • JRadioButton class declaration • Let's see the declaration for javax.swing.JRadioButton class. • public class JRadioButton extends JToggleButton implements Accessible Constructor Description JRadioButton() Creates an unselected radio button with no text. JRadioButton(String s) Creates an unselected radio button with specified text. JRadioButton(String s, boolean selected) Creates a radio button with the specified text and selected status.
  • 8. Elements are then added to the button group via the following method: void add(AbstractButton ab) Here, ab is a reference to the button to be added to the group. A JRadioButton generates action events, item events, and change events each time the button selection changes. Most often, it is the action event that is handled, which means that you will normally implement the ActionListener interface.
  • 9. Java JButton • The JButton class is used to create a labeled button that has platform independent implementation. • The application result in some action when the button is pushed. It inherits AbstractButton class. • JButton class declaration • void setIcon(Icon b)It is used to set the specified Icon on the button. • public class JButton extends AbstractButton implements Accessible Constructor Description JButton() It creates a button with no text and icon. JButton(String s) It creates a button with the specified text. JButton(Icon i) It creates a button with the specified icon object.
  • 10. Java JTabbedPane • The JTabbedPane class is used to switch between a group of components by clicking on a tab with a given title or icon. It inherits JComponent class. • JTabbedPane class declaration • Let's see the declaration for javax.swing.JTabbedPane class. • public class JTabbedPane extends JComponent implements Serializable, A ccessible, SwingConstants Constructor Description JTabbedPane() Creates an empty TabbedPane with a default tab placement of JTabbedPane.Top. JTabbedPane(int tabPlacement) Creates an empty TabbedPane with a specified tab placement. JTabbedPane(int tabPlacement, int tabLayoutPolicy) Creates an empty TabbedPane with a specified tab placement and tab layout policy.
  • 11. Java JDialog • The JDialog control represents a top level window with a border and a title used to take some form of input from the user. It inherits the Dialog class. • Unlike JFrame, it doesn't have maximize and minimize buttons. • JDialog class declaration • Let's see the declaration for javax.swing.JDialog class. • public class JDialog extends Dialog implements WindowConstants, Accessible, RootPaneContainer Constructor Description JDialog() It is used to create a modeless dialog without a title and without a specified Frame owner. JDialog(Frame owner) It is used to create a modeless dialog with specified Frame as its owner and an empty title. JDialog(Frame owner, String title, boolean modal) It is used to create a dialog with the specified title, owner Frame and modality.