SlideShare a Scribd company logo
1 of 12
CS3135/CS2135
Object Oriented Programming (Java)
BSCS-3 / MCS-3
Lecture # 6
JFrame,
JScrollPane
JLabel
GUI Components  JFrame
javax.swing.JFrame
• JFrame()
• JFrame(String)
• void super()
• void super(String)
• void setLayout()
• void setTitle(String)
• String getTitle()
• void setLocation(int, int) // x, y
• void setSize(int, int) // width, height
• void setBounds(int, int, int, int) // x, y, width, height
• void setVisible(boolean)
• void getContentPane().setBackground(Color)
• void setUndecorated(boolean)
Instructor: Tanzila Kehkashan
2
• setIconImage(ImageIcon.getImage())
• setExtendedState(int) //state constant
• setCursor(Cursor)
• add(component)
• void setJMenuBar(JMenuBar)
• void setDefaultCloseOperation(int)
• int getDefaultCloseOperation()
Default Close Constants
• DO_NOTHING_ON_CLOSE
• HIDE_ON_CLOSE //Default for JDialog and JFrame
• DISPOSE_ON_CLOSE //removes window from screen and frees up any resources used by it
• EXIT_ON_CLOSE //Exits the application, using System.exit(0)
GUI Components  JFrame
Instructor: Tanzila Kehkashan
3
State constants
• NORMAL • ICONIFIED • MAXIMIZED_BOTH • MAXIMIZED_HORIZ
• MAXIMIZED_VERT
GUI Components  JFrame
Instructor: Tanzila Kehkashan
4
GUI Components  JFrame  Cursor
java.awt.Cursor
• Cursor(int) // Cursor constant
• Cursor getDefaultCursor()
• Cursor getPredefinedCursor(int) //cursor constant
Cursor Constant
• CROSSHAIR_CURSOR • DEFAULT_CURSOR • E_RESIZE_CURSOR
• HAND_CURSOR • MOVE_CURSOR • N_RESIZE_CURSOR
• NE_RESIZE_CURSOR • NW_RESIZE_CURSOR • S_RESIZE_CURSOR
• SE_RESIZE_CURSOR • SW_RESIZE_CURSOR • TEXT_CURSOR
• W_RESIZE_CURSOR • WAIT_CURSOR
Instructor: Tanzila Kehkashan
5
javax.swing.JScrollPane
• JScrollPane()
• JScrollPane(Component)
• void setHorizontalScrollBarPolicy(int) // method determines when horizontal scroll bar appears
• void setVerticalScrollBarPolicy(int) // method determines when vertical scroll bar appears
• void setHorizontalScrollBar(JScrollBar)
• void setVerticalScrollBar(JScrollBar)
Policies Constants
• HORIZONTAL_SCROLLBAR_ALWAYS
• HORIZONTAL_SCROLLBAR_AS_NEEDED //default
• HORIZONTAL_SCROLLBAR_NEVER
• VERTICAL_SCROLLBAR_ALWAYS
• VERTICAL_SCROLLBAR_AS_NEEDED //default
• VERTICAL_SCROLLBAR_NEVER
GUI Components  JFrame  JScrollPane
Instructor: Tanzila Kehkashan
6
Instructor: Tanzila Kehkashan
7
javax.swing.JLabel
• JLabel(ImageIcon)
• JLabel(ImageIcon, int)
• int specifies horizontal alignment of label’s contents
• LEFT, CENTER, RIGHT, LEADING, TRAILING.
• JLabel(String)
• JLabel(String, ImageIcon, int)
• JLabel(String, int)
• JLabel()
• void setText(String)
• String getText()
• void setIcon(ImageIcon)
• Icon getIcon()
• setToolTipText(String)
GUI Components  JFrame  JLabel
Instructor: Tanzila Kehkashan
8
• void setVisible(boolean)
• void setVerticalTextPosition(int)
• int getVerticalTextPosition()
• void setHorizontalTextPosition(int)
• int getHorizontalTextPosition()
Horizontal position constants
• LEFT
• CENTER
• RIGHT
Vertical position constants
• TOP
• CENTER
• BOTTOM
GUI Components  JFrame  JLabel
Instructor: Tanzila Kehkashan
9
Instructor: Tanzila Kehkashan
10
• Create your project’s interface:
• Splash screen
• Signup
• Sign in
• Main screen
• Levels
• Help
• Create package of your project
ASSIGNMENT
Instructor: Tanzila Kehkashan
11
Instructor: Tanzila Kehkashan
12

More Related Content

More from Tanzila Kehkashan

More from Tanzila Kehkashan (20)

OOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxOOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptx
 
OOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptxOOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptx
 
OOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxOOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptx
 
OOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptxOOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptx
 
OOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxOOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptx
 
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxOOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptx
 
OOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxOOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptx
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptx
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptx
 
OOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxOOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptx
 
OOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxOOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptx
 
OOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxOOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptx
 
OOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxOOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptx
 
OOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxOOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptx
 
OOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxOOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptx
 
OOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxOOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptx
 
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptxOOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
 
OOP Lecture 4-Arrays, String.pptx
OOP Lecture 4-Arrays, String.pptxOOP Lecture 4-Arrays, String.pptx
OOP Lecture 4-Arrays, String.pptx
 
OOP Lecture 3-Packages.pptx
OOP Lecture 3-Packages.pptxOOP Lecture 3-Packages.pptx
OOP Lecture 3-Packages.pptx
 
OOP Lecture 2-Run time Input.pptx
OOP Lecture 2-Run time Input.pptxOOP Lecture 2-Run time Input.pptx
OOP Lecture 2-Run time Input.pptx
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 

OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx

  • 1. CS3135/CS2135 Object Oriented Programming (Java) BSCS-3 / MCS-3 Lecture # 6 JFrame, JScrollPane JLabel
  • 2. GUI Components  JFrame javax.swing.JFrame • JFrame() • JFrame(String) • void super() • void super(String) • void setLayout() • void setTitle(String) • String getTitle() • void setLocation(int, int) // x, y • void setSize(int, int) // width, height • void setBounds(int, int, int, int) // x, y, width, height • void setVisible(boolean) • void getContentPane().setBackground(Color) • void setUndecorated(boolean) Instructor: Tanzila Kehkashan 2
  • 3. • setIconImage(ImageIcon.getImage()) • setExtendedState(int) //state constant • setCursor(Cursor) • add(component) • void setJMenuBar(JMenuBar) • void setDefaultCloseOperation(int) • int getDefaultCloseOperation() Default Close Constants • DO_NOTHING_ON_CLOSE • HIDE_ON_CLOSE //Default for JDialog and JFrame • DISPOSE_ON_CLOSE //removes window from screen and frees up any resources used by it • EXIT_ON_CLOSE //Exits the application, using System.exit(0) GUI Components  JFrame Instructor: Tanzila Kehkashan 3
  • 4. State constants • NORMAL • ICONIFIED • MAXIMIZED_BOTH • MAXIMIZED_HORIZ • MAXIMIZED_VERT GUI Components  JFrame Instructor: Tanzila Kehkashan 4
  • 5. GUI Components  JFrame  Cursor java.awt.Cursor • Cursor(int) // Cursor constant • Cursor getDefaultCursor() • Cursor getPredefinedCursor(int) //cursor constant Cursor Constant • CROSSHAIR_CURSOR • DEFAULT_CURSOR • E_RESIZE_CURSOR • HAND_CURSOR • MOVE_CURSOR • N_RESIZE_CURSOR • NE_RESIZE_CURSOR • NW_RESIZE_CURSOR • S_RESIZE_CURSOR • SE_RESIZE_CURSOR • SW_RESIZE_CURSOR • TEXT_CURSOR • W_RESIZE_CURSOR • WAIT_CURSOR Instructor: Tanzila Kehkashan 5
  • 6. javax.swing.JScrollPane • JScrollPane() • JScrollPane(Component) • void setHorizontalScrollBarPolicy(int) // method determines when horizontal scroll bar appears • void setVerticalScrollBarPolicy(int) // method determines when vertical scroll bar appears • void setHorizontalScrollBar(JScrollBar) • void setVerticalScrollBar(JScrollBar) Policies Constants • HORIZONTAL_SCROLLBAR_ALWAYS • HORIZONTAL_SCROLLBAR_AS_NEEDED //default • HORIZONTAL_SCROLLBAR_NEVER • VERTICAL_SCROLLBAR_ALWAYS • VERTICAL_SCROLLBAR_AS_NEEDED //default • VERTICAL_SCROLLBAR_NEVER GUI Components  JFrame  JScrollPane Instructor: Tanzila Kehkashan 6
  • 8. javax.swing.JLabel • JLabel(ImageIcon) • JLabel(ImageIcon, int) • int specifies horizontal alignment of label’s contents • LEFT, CENTER, RIGHT, LEADING, TRAILING. • JLabel(String) • JLabel(String, ImageIcon, int) • JLabel(String, int) • JLabel() • void setText(String) • String getText() • void setIcon(ImageIcon) • Icon getIcon() • setToolTipText(String) GUI Components  JFrame  JLabel Instructor: Tanzila Kehkashan 8
  • 9. • void setVisible(boolean) • void setVerticalTextPosition(int) • int getVerticalTextPosition() • void setHorizontalTextPosition(int) • int getHorizontalTextPosition() Horizontal position constants • LEFT • CENTER • RIGHT Vertical position constants • TOP • CENTER • BOTTOM GUI Components  JFrame  JLabel Instructor: Tanzila Kehkashan 9
  • 11. • Create your project’s interface: • Splash screen • Signup • Sign in • Main screen • Levels • Help • Create package of your project ASSIGNMENT Instructor: Tanzila Kehkashan 11