SlideShare une entreprise Scribd logo
1  sur  63
Simple Control Structures boolean s, the  if  statement switch-case
What are control structures? ,[object Object],[object Object],[object Object],[object Object],[object Object]
boolean ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Declaring  boolean   variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Numeric comparisons ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The  if  statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Compound statements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The  if  statement again ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Flowchart for the  if   statement condition? statement true false
The  if-else  statement ,[object Object],[object Object],[object Object],[object Object],[object Object]
Example  if-else  statements ,[object Object],[object Object]
Flowchart for the  if-else   statement condition? true statement-1 statement-2 false
Aside: the “mod” operator ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Nesting  if   (or  if-then ) statements ,[object Object],[object Object]
Operations on  boolean s ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Simpler tests ,[object Object],[object Object],[object Object],[object Object]
The  if-else  statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dangling Else ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multiway selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
“ if” ladder ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The “switch” statement ,[object Object],[object Object],[object Object],[object Object]
Sample switch statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
“ break” optimisation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Characters in “switch” ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Boolean operators ! || && Java true if parameter is false; false if parameter is true; NOT true if at least one parameter is true OR true if both parameters are true AND Meaning Boolean Algebra
Operator precedence ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reversing expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Afvinkopdracht 5: Tic-tac-toe
Graphic programming The GUI revisited
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Frames ,[object Object],[object Object],[object Object]
import  javax.swing.*; class MyFrame extends JFrame { public MyFrame() {   setTitle("My first graphics program");   setSize(400,300); } } public class FrameTest { public static void main(String[] args) { JFrame frame=new MyFrame(); frame.show(); } }
 
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Swing inheritance hierarchy ,[object Object],[object Object],[object Object]
JFrame JComponent JPanel … .. Component Frame Window Container
[object Object],[object Object],[object Object]
Displaying graphics in frames – panels ,[object Object],[object Object],[object Object],Container contentPane=frame.getContentPane(); Component c= ….;  // UI or graphical component contentPane.add (c); // Add to the frame
Content  pane Frame JPanel SomeText JField
Panels ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Drawing on panels ,[object Object],[object Object]
[object Object],class MyPanel extends JPanel { public  void paintComponent(Graphics g) { super.paintComponent(g);   // Code placed here to draw graphics } }
[object Object],[object Object],[object Object]
Displaying text in graphics windows ,[object Object],[object Object],[object Object],[object Object]
import javax.swing.*; import java.awt.*; public  class MyPanel extends JPanel { public void paintComponent(Graphics g) {   super.paintComponent(g);   g.drawString("Hello there!",150,125); } }
import java.awt.event.*; import javax.swing.*; import java.awt.*; public class HelloFrame extends JFrame { public HelloFrame() {   setTitle("Drawing a string example");   setSize(400,300);   addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });   Container contentPane=getContentPane();   contentPane.add(new MyPanel()); } }
public class FrameTest { public static void main(String[] args) { JFrame frame=new HelloFrame(); frame.show(); } }
 
[object Object],[object Object],[object Object],public  class MyPanel extends JPanel { public void paintComponent(Graphics g) {   super.paintComponent(g);   Font f=new Font(“Helvetica”,Font.BOLD,25);   g.setFont(f);   g.drawString("Hello there!",150,125); } }
 
Drawing simple graphics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class DrawPanel extends JPanel { public void paintComponent(Graphics g) {   super.paintComponent(g);   g.setColor(Color.red);   g.drawRect(20,30,50,50);   g.setColor(Color.green);   g.drawOval(100,30,90,60);   g.fillOval(100,30,90,60);   g.setColor(Color.yellow);   int[] xcoords={180,200,250,275,225};   int[] ycoords={170,130,130,150,200};   g.drawPolygon(xcoords,ycoords,5);   g.fillPolygon(xcoords,ycoords,5); } }
 
Displaying images ,[object Object],[object Object],[object Object],[object Object]
Normal program thread Load image from file Create new thread Image loading thread Program waits to be informed when image loaded Image loading complete – send signal Normal program thread resumes
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
import java.awt.*; import java.awt.event.*; import javax.swing.*; class ImagePanel extends JPanel { public ImagePanel() {   image = Toolkit.getDefaultToolkit().getImage( “Pisa.jpg” );   MediaTracker tracker=new MediaTracker(this);   tracker.addImage(image,0);   try {tracker.waitForID(0);}   catch (InterruptedException e){} } public void paintComponent(Graphics g)   {   super.paintComponent(g);   g.drawImage(image,0,0,this); } private Image image; }
 
And finally …. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
“ 640K ought to be enough for anybody.” --Bill Gates, 1981
Nu inschrijven voor het schaaktoernooi

Contenu connexe

Tendances

Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statementsKuppusamy P
 
Chapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsChapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsIt Academy
 
Java loops for, while and do...while
Java loops   for, while and do...whileJava loops   for, while and do...while
Java loops for, while and do...whileJayfee Ramos
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetitionOnline
 
Control structures in java
Control structures in javaControl structures in java
Control structures in javaVINOTH R
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentationJava if else condition - powerpoint persentation
Java if else condition - powerpoint persentationManeesha Caldera
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__elseeShikshak
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statementsrajshreemuthiah
 
Visula C# Programming Lecture 3
Visula C# Programming Lecture 3Visula C# Programming Lecture 3
Visula C# Programming Lecture 3Abou Bakr Ashraf
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
Control Structures
Control StructuresControl Structures
Control StructuresGhaffar Khan
 
java programming- control statements
 java programming- control statements java programming- control statements
java programming- control statementsjyoti_lakhani
 

Tendances (20)

Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Chapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsChapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java Statements
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Java loops for, while and do...while
Java loops   for, while and do...whileJava loops   for, while and do...while
Java loops for, while and do...while
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Control statement in c
Control statement in cControl statement in c
Control statement in c
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentationJava if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Control statements in java programmng
Control statements in java programmngControl statements in java programmng
Control statements in java programmng
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statements
 
Visula C# Programming Lecture 3
Visula C# Programming Lecture 3Visula C# Programming Lecture 3
Visula C# Programming Lecture 3
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Control Structures
Control StructuresControl Structures
Control Structures
 
Decision making and looping
Decision making and loopingDecision making and looping
Decision making and looping
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
java programming- control statements
 java programming- control statements java programming- control statements
java programming- control statements
 

En vedette

Snakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, Vandaag
Snakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, VandaagSnakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, Vandaag
Snakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, VandaagAte van der Meer
 
Java Introductie
Java IntroductieJava Introductie
Java Introductiembruggen
 

En vedette (6)

M C6java4
M C6java4M C6java4
M C6java4
 
Snakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, Vandaag
Snakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, VandaagSnakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, Vandaag
Snakeware en MerkMakers Nieuwe Media, Technologie Van Morgen, Vandaag
 
M C6java3
M C6java3M C6java3
M C6java3
 
M C6java2
M C6java2M C6java2
M C6java2
 
M C6java7
M C6java7M C6java7
M C6java7
 
Java Introductie
Java IntroductieJava Introductie
Java Introductie
 

Similaire à M C6java5

Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionalish sha
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionalish sha
 
Java căn bản - Chapter5
Java căn bản - Chapter5Java căn bản - Chapter5
Java căn bản - Chapter5Vince Vo
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control StructuresPRN USM
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 Bdplunkett
 
Chapter 4 flow control structures and arrays
Chapter 4 flow control structures and arraysChapter 4 flow control structures and arrays
Chapter 4 flow control structures and arrayssshhzap
 
Java input Scanner
Java input Scanner Java input Scanner
Java input Scanner Huda Alameen
 
Ch05 Visual Aids
Ch05 Visual AidsCh05 Visual Aids
Ch05 Visual Aidskhaifuture
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c languagechintupro9
 
control statements
control statementscontrol statements
control statementsAzeem Sultan
 
Lecture - 5 Control Statement
Lecture - 5 Control StatementLecture - 5 Control Statement
Lecture - 5 Control Statementmanish kumar
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrolsteach4uin
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingPathomchon Sriwilairit
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 SlidesRakesh Roshan
 

Similaire à M C6java5 (20)

Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Java căn bản - Chapter5
Java căn bản - Chapter5Java căn bản - Chapter5
Java căn bản - Chapter5
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control Structures
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 B
 
Chapter 4 flow control structures and arrays
Chapter 4 flow control structures and arraysChapter 4 flow control structures and arrays
Chapter 4 flow control structures and arrays
 
Control All
Control AllControl All
Control All
 
Java input Scanner
Java input Scanner Java input Scanner
Java input Scanner
 
Ch05 Visual Aids
Ch05 Visual AidsCh05 Visual Aids
Ch05 Visual Aids
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c language
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
control statement
control statement control statement
control statement
 
control statements
control statementscontrol statements
control statements
 
Lecture - 5 Control Statement
Lecture - 5 Control StatementLecture - 5 Control Statement
Lecture - 5 Control Statement
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
 
LOOPS AND DECISIONS
LOOPS AND DECISIONSLOOPS AND DECISIONS
LOOPS AND DECISIONS
 
7 decision-control
7 decision-control7 decision-control
7 decision-control
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 

Dernier

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

M C6java5

  • 1. Simple Control Structures boolean s, the if statement switch-case
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Flowchart for the if statement condition? statement true false
  • 10.
  • 11.
  • 12. Flowchart for the if-else statement condition? true statement-1 statement-2 false
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. Boolean operators ! || && Java true if parameter is false; false if parameter is true; NOT true if at least one parameter is true OR true if both parameters are true AND Meaning Boolean Algebra
  • 26.
  • 27.
  • 29. Graphic programming The GUI revisited
  • 30.
  • 31.
  • 32.
  • 33. import javax.swing.*; class MyFrame extends JFrame { public MyFrame() { setTitle("My first graphics program"); setSize(400,300); } } public class FrameTest { public static void main(String[] args) { JFrame frame=new MyFrame(); frame.show(); } }
  • 34.  
  • 35.
  • 36.
  • 37. JFrame JComponent JPanel … .. Component Frame Window Container
  • 38.
  • 39.
  • 40. Content pane Frame JPanel SomeText JField
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46. import javax.swing.*; import java.awt.*; public class MyPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.drawString("Hello there!",150,125); } }
  • 47. import java.awt.event.*; import javax.swing.*; import java.awt.*; public class HelloFrame extends JFrame { public HelloFrame() { setTitle("Drawing a string example"); setSize(400,300); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane=getContentPane(); contentPane.add(new MyPanel()); } }
  • 48. public class FrameTest { public static void main(String[] args) { JFrame frame=new HelloFrame(); frame.show(); } }
  • 49.  
  • 50.
  • 51.  
  • 52.
  • 53.
  • 54. class DrawPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.red); g.drawRect(20,30,50,50); g.setColor(Color.green); g.drawOval(100,30,90,60); g.fillOval(100,30,90,60); g.setColor(Color.yellow); int[] xcoords={180,200,250,275,225}; int[] ycoords={170,130,130,150,200}; g.drawPolygon(xcoords,ycoords,5); g.fillPolygon(xcoords,ycoords,5); } }
  • 55.  
  • 56.
  • 57. Normal program thread Load image from file Create new thread Image loading thread Program waits to be informed when image loaded Image loading complete – send signal Normal program thread resumes
  • 58.
  • 59. import java.awt.*; import java.awt.event.*; import javax.swing.*; class ImagePanel extends JPanel { public ImagePanel() { image = Toolkit.getDefaultToolkit().getImage( “Pisa.jpg” ); MediaTracker tracker=new MediaTracker(this); tracker.addImage(image,0); try {tracker.waitForID(0);} catch (InterruptedException e){} } public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(image,0,0,this); } private Image image; }
  • 60.  
  • 61.
  • 62. “ 640K ought to be enough for anybody.” --Bill Gates, 1981
  • 63. Nu inschrijven voor het schaaktoernooi