Objektorienteeritud programmeerimine

Size: px
Start display at page:

Download "Objektorienteeritud programmeerimine"

Transcription

1 Objektorienteeritud programmeerimine 8. loeng 26. märts Eno Tõnisson 1

2 Kasutatud H. Heina loengumaterjalid J. Kiho Väike Java leksikon Y. D. Liang Introduction to Java Programming 2

3 Eelmisel nädalal loeng tunnikontroll graafiline kasutajaliides praktikum abstraktsed klassid, liidesed kevade algus, üleminek suveajale 3

4 Järeltöö Järeltöö 30. märtsil või 4. aprillil 8.15, registreerimine ÕISis. Oma kontrolltöö analüüs. Vt. Moodle is 4

5 Umbes mitu tundi tegelesite eelmisel nädalal selle ainega (loeng+praktikum+iseseisvalt)? 1. paariline tundi tundi tundi tundi tundi tundi tundi 8. üle 14 tunni 0% 0% 0% 0% 0% 0% 0% 0%

6 Kuivõrd olete selle ainega graafikus? 1. Isegi ees 2. Täiesti graafikus 1. paariline 3. Veidi maas, aga saan ise hakkama 4. Kõvasti maas, vajan abi 5. Ei oska öelda 0% 0% 0% 0% 0%

7 Umbes mitu tundi tegelesite eelmisel nädalal selle ainega (loeng+praktikum+iseseisvalt)? 2. paariline tundi tundi tundi tundi tundi tundi tundi 8. üle 14 tunni 0% 0% 0% 0% 0% 0% 0% 0%

8 Kuivõrd olete selle ainega graafikus? 1. Isegi ees 2. Täiesti graafikus 2. paariline 3. Veidi maas, aga saan ise hakkama 4. Kõvasti maas, vajan abi 5. Ei oska öelda 0% 0% 0% 0% 0%

9 Natuke kordavalt juhuslik arv konstruktorid Täna Graafiline kasutajaliides Tunnikontrollist tulevikust 9

10 Juhuslik arv Iga kord tuleb erinev!? Math.random() Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range. Juhuslik, pseudojuhuslik Varem täringutega, kaartidega, ruletiga, juhuslike arvude tabelist. 10

11 Raamatust A Million Random Digits with 100,000 Normal Deviates a. RAND Corporation 11

12 /index.html 12

13 Kas Math.random() võib kunagi tagastada väärtuse 0.0? 1. Jah 2. Ei 0% 0%

14 Kas Math.random() võib kunagi tagastada väärtuse 1.0? 1. Jah 2. Ei 0% 0%

15 Kui tahame juhuslikku täisarvu lõigust [10; 16] Kirjutage paberile, kuidas seda saada? 15

16 Milline järgnevatest annab juhusliku täisarvu lõigust [10; 16]? 1. Valik 1 2. Valik 2 3. Valik 3 4. Valik 4 5. Valik 5 0% 0% 0% 0% 0%

17 Millises piirkonnas annab väärtusi 6*Math.random()? 1. [0.0; 6.0] 2. [0.0; 6.0) 0% 0%

18 Kas 10+6*Math.random()annab väärtusi piirkonnas [10.0; 16.0)? 1. Jah 2. Ei 0% 0%

19 Mis ilmub ekraanile? System.out.println((int)-0.6); veateade 0% 0% 0%

20 Mis ilmub ekraanile? System.out.println(Math.round(-0.6)); veateade 0% 0% 0%

21 Mida võib öelda Math.round(10+6*Math.random()) puhul 10 ja 11 tuleku tõenäosuse kohta? 1. ligikaudu võrdse tõenäosusega tuleb ligikaudu kaks korda tihemini kui tuleb ligikaudu kaks korda harvemini kui midagi muud 0% 0% 0% 0%

22 Kas ühtlase jaotusega? 22

23 Klass Random util/random.html Random rand1 = new Random(); Random rand2 = new Random(20); nextboolean, nextdouble, nextgaussian, nextint Alati sama seeria 23

24 Klassi Random alamklass import java.util.random; public class Juhuslik extends Random { int juhusliktäisarv(int a, int b){ return a + this.nextint(b - a); Juhuslik juh = new Juhuslik(); System.out.println( juh.juhusliktäisarv(2, 4)); The serializable class Juhuslik does not declare a static final serialversionuid field of type long 24

25 Konstruktorid Alamklasside koostamisel võib tekkida vigu konstruktoritega seoses Seosed ülemklassi konstruktoritega Ei pärita Konstruktorite aheldamine (ingl. k. chaining). 25

26 Alamklassi konstruktor peab tagama ülemklassi konstruktori rakendamise et alamklassi isend oleks ka ülemklassi isend Konstruktor võib välja kutsuda üledefineeritud konstruktori (this(...)) vahetu ülemklassi konstruktori (super(...)). Kui kumbagi neist ei ole kasutatud, siis kompilaator lisab käsu super() konstruktori esimeseks lauseks. 26

27 super public A(){ sama public A(){ super(); public A(int i){ //laused sama public A(int i){ super(); //laused 27

28 Kas kompileerub? public class KlassA { int a; 1. Jah 2. Ei 0% 0%

29 Kas saab isendi luua? public class KlassA { int a; 1. Jah 2. Ei KlassA ka = new KlassA(); 0% 0%

30 Kas kompileerub? public class KlassA { int a; 1. Jah 2. Ei public class KlassB extends KlassA { int b; 0% 0%

31 Kas kompileerub? public class KlassA { int a; 1. Jah 2. Ei public class KlassB extends KlassA { int b; KlassB(){ a = 23; b = 12; 0% 0%

32 Kas kompileerub? public class KlassA { int a; 1. Jah 2. Ei public class KlassB extends KlassA { int b; KlassB(){ super(); a = 23; b = 12; 0% 0%

33 Kas kompileerub? public class KlassA { int a; KlassA(int arv){ 1. Jah 2. Ei public class KlassB extends KlassA { int b; KlassB(){ super(); a = 23; b = 12; 0% 0%

34 public class KlassA { int a; KlassA(int arv){ KlassA() { public class KlassB extends KlassA { int b; KlassB(){ super(); a = 23; b = 12; 34

35 Mida väljastatakse ekraanile? public class KlassA { int a; KlassA(int arv){ KlassA() { a = 45; public class KlassB extends KlassA { int b; KlassB(){ b = 12; Veateade KlassB kb = new KlassB(); System.out.println(kb.a); 0% 0% 0%

36 Kasutajaliidesega edasi Olid raamid, tahvlid, nupud jm. Olid sündmused 36

37 Sündmus ingl. Event Mis tekitab kasutaja tegevus hiire liigutamine, klahvi vajutamine operatsioonisüsteem aeg sai täis Sündmuse allikas (source) objekt, millega sündmus juhtus nupp, komponent, tekstiväli kui sündmus toimub, siis sellest teatatakse neile, kes on registreerunud kuulama Java mõttes sündmusklassi isend nende ülemklass on java.util.eventobject nt. ActionEvent, WindowEvent, KeyEvent, MouseEvent 37

38 Kuular ingl. k. Listener Kuular ootab sündmuse toimumist ja siis reageerib On valmis reageerima kuni programm töötab Peab olema klassist, mis realiseerib vastava kuulari liidese, nt. ActionListener, WindowListener, KeyListener,, MouseMotionListener 38

39 Sündmus toimus Sama sündmust võib kuulata mitu erinevat kuularit. Iga kuular, kes oli registreerunud antud allika juurde antud liiki sündmusi kuulama, saab oma koopia. Kuulari registreerimine nt. nupp1.addactionlistener(kuular1); Sündmuse isendi käest saab küsida, milline objekt selle tekitas e.getsource() millal sündmus toimus e.getwhen() 39

40 import java.awt.event.actionevent; import java.awt.event.actionlistener; public class NupuKuular implements ActionListener { public void actionperformed(actionevent e) { System.out.println("Nuppu " + e.getactioncommand() + " vajutati " + new java.util.date(e.getwhen())); 40

41 import java.awt.*; import javax.swing.*; import java.util.*; public class Kuularid { public static void main(string[] args) { JFrame raam = new JFrame("Meie raam"); raam.setdefaultcloseoperation(jframe.exit_on_close); raam.setsize(300, 200); raam.setlayout(new FlowLayout()); JButton nupp1 = new JButton("Olen nõus"); JButton nupp2 = new JButton("Ei ole nõus"); NupuKuular kuular1 = new NupuKuular(); nupp1.addactionlistener(kuular1); nupp2.addactionlistener(kuular1); raam.add(nupp1); raam.add(nupp2); raam.setvisible(true); 41

42 42

43 Sündmuste hierarhia 43

44 Kuularite tegemine Liidese kõik meetodid realiseerida nt. liidese WindowListener korral meetodid windowclosed, windowiconified, windowopened, windowclosing, windowdeiconified, windowactivated, windowdeactivated Luua vastava adapterklassi alamklass katta üle vaid need, mis meid huvitavad import java.awt.event.*; public class RaamiAdapter extends WindowAdapter { public void windowiconified (WindowEvent e) { System.out.println("Aken muutus ikooniks"); 44

45 Graafikakomponente 45

46 Eelmisel korral Raam ühes klassis JFrame raam = new JFrame("Raadio"); JRadioButton nupp1 = new JRadioButton("B",true); raam.add(nupp1); Kuulari jaoks teine klass class NupuKuular implements ActionListener void actionperformed(actionevent e) 46

47 Kas klassikirjelduses võib olla teise klassi kirjeldus? 1. Jah 2. Ei 0% 0%

48 Proovime teisiti Klassi JFrame alamklassina Siseklass kuulari jaoks 48

49 49

50 50

51 Sündmused, mida ei tekita kasutaja Klass Timer 51

52 Anonüümne Mõelge teistele ja endale Kuidas suhtute klikkerite kasutamisse üldküsimused alguses ja lõpus küsimused asjade kohta, mida pole veel täpsemalt käsitletud küsimused teadmiste kontrolliks Loengu punktide jaotus 12 punkti 6 jagatud (kohal või video) Kuidas edasi? Tunnikontrollid Eksamikorraldus 90 minutit ilma arvutita ilma materjalideta 36 punkti Tunnikontroll 52

53 Üldiselt on klikkerid üks suur põhjus, miks ma ennast iga esmaspäev loengusse vean. Ma usun, et klikkerite kasutamine annab võimaluse loengus aktiivselt kaasa lüüa ka neile tudengitele, kes muidu kardaksid kõva häälega küsimustele vastata. 53

54 Saad avaldada oma arvamust suud lahti tegemata ja anonüümselt. Nagu neti kommentaator :-) Klikkerid on huvitavad, peavad kindlasti jääma. Alati on hea teada, et sa pole ainuke loll. 54

55 Kui on näha, et küsimusele vastatakse, kas ebakindlalt või on läinud teatud variantide puhul "rebimiseks", algab diskussioon. See on mõnus ning siis saavad ka häbelikud isendid teada, miks nende vastusel just selline tõeväärtus on. 55

56 Teadmiste kontrollist Tunnikontrollid tulevad Eksam näidisülesanded tulevad 56

57 1. liiga kiire 2. paras 3. liiga aeglane Loengu tempo oli 1. paariline 0% 0% 0%

58 1. liiga lihtne 2. parajalt jõukohane 3. liiga keeruline Materjal tundus 1. paariline 0% 0% 0%

59 1. liiga kiire 2. paras 3. liiga aeglane Loengu tempo oli 2. paariline 0% 0% 0%

60 1. liiga lihtne 2. parajalt jõukohane 3. liiga keeruline Materjal tundus 2. paariline 0% 0% 0%

61 Suur tänu osalemast! Kohtumiseni! 61

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 7. loeng 25. märts Eno Tõnisson 1 Kasutatud H. Heina loengumaterjalid J. Kiho Väike Java leksikon Y. D. Liang Introduction to Java Programming 2 Eelmisel nädalal loeng

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 8. loeng, 2. aprill Marina Lepp 1 Eelmisel nädalal Loeng graafiline kasutajaliides tunnikontroll Praktikum 1. kontrolltöö Ülestõusmispühad Naljapäev 2 1. kontrolltöö

More information

Objektorienteeritud programmeerimine. 5. märts, 4. loeng Marina Lepp

Objektorienteeritud programmeerimine. 5. märts, 4. loeng Marina Lepp Objektorienteeritud programmeerimine 5. märts, 4. loeng Marina Lepp 1 Loeng Möödunud nädalal Klassid. Isendid. Konstruktorid. Sõned. Mähisklassid Praktikum Objektid ja klassid. Muutujate skoobid. Objektide

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 2. loeng 19. veebruar 2018 Marina Lepp 1 Möödunud nädalal Loeng Sissejuhatus Praktikum Paaristöö, algus Vastlapäev Sõbrapäev Hiina uusaasta 2 Umbes mitu tundi tegelesite

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 2. loeng 18. veebruar Eno Tõnisson kasutatud ka Helle Heina ja Jüri Kiho materjale 1 Eelmisel nädalal loeng sissejuhatus praktikum paaristööna Asteroid 2012 DA14 möödus

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 10. loeng 15. aprill Eno Tõnisson 1 Kasutatud H. Heina loengumaterjalid J. Kiho Väike Java leksikon J. Kiho Java Programmeerimise aabits Y. D. Liang Introduction to

More information

Objekt-orienteeritud programmeerimine MTAT (6 EAP) 7. Loeng. H e l l e H e i n h e l l e. h e i e e

Objekt-orienteeritud programmeerimine MTAT (6 EAP) 7. Loeng. H e l l e H e i n h e l l e. h e i e e Objekt-orienteeritud programmeerimine MTAT.03.130 (6 EAP) 7. Loeng H e l l e H e i n h e l l e. h e i n @ut. e e Täna loengus: Rakend (applet) Sündmuste töötlemine Sündmused Kuularid Üksteisesse sisestatud

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 9. loeng, 9. aprill Marina Lepp 1 Loeng Eelmisel nädalal sündmused, omadused Lisapraktikum Praktikum graafiline kasutajaliides 1. rühmatöö Rahvusvaheline spordipäev

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 10. loeng 9. aprill Eno Tõnisson 1 Kasutatud H. Heina loengumaterjalid J. Kiho Väike Java leksikon J. Kiho Java Programmeerimise aabits Y. D. Liang Introduction to

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 15. loeng 20. mai Eno Tõnisson 1 Kasutatud H. Heina loengumaterjalid J. Kiho Väike Java leksikon J. Kiho Java Programmeerimise aabits Y. D. Liang Introduction to Java

More information

Systems Programming Graphical User Interfaces

Systems Programming Graphical User Interfaces Systems Programming Graphical User Interfaces Julio Villena Román (LECTURER) CONTENTS ARE MOSTLY BASED ON THE WORK BY: José Jesús García Rueda Systems Programming GUIs based on Java

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 10. loeng, 16. aprill Marina Lepp 1 Eelmisel nädalal Loeng vood Lisapraktikum Praktikum sündmused Künnipäev (12.04) 2 Umbes mitu tundi tegelesite eelmisel nädalal selle

More information

Objekt-orienteeritud programmeerimine MTAT (6 EAP) 5. Loeng. H e l l e H e i n h e l l e. h e i e e

Objekt-orienteeritud programmeerimine MTAT (6 EAP) 5. Loeng. H e l l e H e i n h e l l e. h e i e e Objekt-orienteeritud programmeerimine MTAT.03.130 (6 EAP) 5. Loeng H e l l e H e i n h e l l e. h e i n @ut. e e Täna loengus: Abstraktsed klassid Liidesed Mähisklassid 2 Abstraktsed klassid Meetodit nimetatakse

More information

Puudub protseduur. Protseduuri nimi võib olla valesti kirjutatud. Protseduuri (või funktsiooni) poole pöördumisel on vähem argumente kui vaja.

Puudub protseduur. Protseduuri nimi võib olla valesti kirjutatud. Protseduuri (või funktsiooni) poole pöördumisel on vähem argumente kui vaja. Puudub protseduur. Protseduuri nimi võib olla valesti kirjutatud. Sub prog1() Msgox "Tere" Sub prog2() a = si(1) Protseduuri (või funktsiooni) poole pöördumisel on vähem argumente kui vaja. a = Sin() Protseduuri

More information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber GUI are event driven (i.e. when user interacts with a GUI component, the interaction (event) derives the program to perform a task). Event: click button, type in text field,

More information

MSDE Upgrade platvormile SQL 2005 Server Express SP4

MSDE Upgrade platvormile SQL 2005 Server Express SP4 MSDE Upgrade platvormile SQL 2005 Server Express SP4 NB! Windos XP puhul peab veenduma, et masinas oleks paigaldatud.net Framework vähemalt versioon 2.0!!! NB! Muutke oma SA parool turvaliseks ( minimaalne

More information

WD My Net N600 juhend:

WD My Net N600 juhend: WD My Net N600 juhend: 1) Kui WD My Net N600 seade on ühendatud näiteks Elioni Thomsoni ruuteriga (TG789vn või TG784) või Elioni Inteno DG301a ruuteriga, kus üldiselt on ruuteri Default Gateway sama, nagu

More information

Objektorienteeritud programmeerimine

Objektorienteeritud programmeerimine Objektorienteeritud programmeerimine 11. loeng, 23. aprill Marina Lepp 1 Eelmisel nädalal Loeng vood, erindid 1. kontrolltöö järeltöö Praktikum vood Ülemaailmne maapäev (22.04) 2 Umbes mitu tundi tegelesite

More information

Ülesannete tüüpide tutvustus! a kevad

Ülesannete tüüpide tutvustus! a kevad Ülesannete tüüpide tutvustus! Võimalike teemade ring hõlmab kogu kursust!!! 2018. a kevad Tegelikult on eksamitöös 4 ülesannet Ülesanne 1 (? punkti) Võib eeldada, et vajalikud asjad on imporditud ja klassi

More information

More Swing. CS180 Recitation 12/(04,05)/08

More Swing. CS180 Recitation 12/(04,05)/08 More Swing CS180 Recitation 12/(04,05)/08 Announcements No lecture/labs next week Recitations and evening consulting hours will be held as usual. Debbie's study group on tuesday and office hours on thursday

More information

Andmebaasid (6EAP) I praktikum

Andmebaasid (6EAP) I praktikum Andmebaasid (6EAP) I praktikum Mõisteid Server on arvutisüsteem või selles töötav tarkvara, mis pakub teatud infoteenust sellega ühenduvatele klientidele. Klient on tarkvara, mis võimaldab suhelda serveriga.

More information

Vea haldus ja logiraamat hajutatud süsteemides Enn Õunapuu.

Vea haldus ja logiraamat hajutatud süsteemides Enn Õunapuu. Vea haldus ja logiraamat hajutatud süsteemides Enn Õunapuu enn.ounapuu@ttu.ee Millest tuleb jutt? Kuidas ma näen, millises sammus erinevad protsessid parasjagu on? Kuidas ma aru saan, kas protsess töötab

More information

TP-Link TL-WR743ND Juhend

TP-Link TL-WR743ND Juhend TP-Link TL-WR743ND Juhend 1) Ühenda oma arvuti TP-Link ruuteriga üle kaabli (LAN). 2) Kui arvuti ja ruuter said omavahel ühendatud, siis võid minna seadme koduleheküljele (interneti brauseri otsingu reasse

More information

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User CSE3461 Control Flow Paradigms: Reacting to the User Control Flow: Overview Definition of control flow: The sequence of execution of instructions in a program. Control flow is determined at run time by

More information

Tabelid <TABLE> Koostanud: Merike Hein

Tabelid <TABLE> Koostanud: Merike Hein Tabelid Tabelite kasutusvõimalus on HTML'is olemas juba pikka aega. Tabelimärgendite esmaseks kasutusalaks oli muidugi mõista tabelkujul info kuvamine. tähendab siis tabelite joonistamist.

More information

CSE 8B Intro to CS: Java

CSE 8B Intro to CS: Java CSE 8B Intro to CS: Java Winter, 2006 February 23 (Day 14) Menus Swing Event Handling Inner classes Instructor: Neil Rhodes JMenuBar container for menus Menus associated with a JFrame via JFrame.setMenuBar

More information

Chapter 1 GUI Applications

Chapter 1 GUI Applications Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations

More information

MIT AITI Swing Event Model Lecture 17

MIT AITI Swing Event Model Lecture 17 MIT AITI 2004 Swing Event Model Lecture 17 The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the user. But how do GUIs interact with users? How do applications

More information

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/

More information

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline Sequential vs. Event-driven Programming Reacting to the user GUI Program Organization Let s digress briefly to examine the organization of our GUI programs We ll do this in stages, by examining three example

More information

Advanced Java Programming (17625) Event Handling. 20 Marks

Advanced Java Programming (17625) Event Handling. 20 Marks Advanced Java Programming (17625) Event Handling 20 Marks Specific Objectives To write event driven programs using the delegation event model. To write programs using adapter classes & the inner classes.

More information

SD Module-1 Advanced JAVA

SD Module-1 Advanced JAVA Assignment No. 4 SD Module-1 Advanced JAVA R C (4) V T Total (10) Dated Sign Title: Transform the above system from command line system to GUI based application Problem Definition: Write a Java program

More information

SD Module-1 Advanced JAVA. Assignment No. 4

SD Module-1 Advanced JAVA. Assignment No. 4 SD Module-1 Advanced JAVA Assignment No. 4 Title :- Transform the above system from command line system to GUI based application Problem Definition: Write a Java program with the help of GUI based Application

More information

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing. COSC User Interfaces Module 3 Sequential vs. Event-driven Programming Example Programs DemoLargestConsole.java DemoLargestGUI.java Demo programs will be available on the course web page. GUI Program Organization

More information

SQL Server 2005 Expressi paigaldamine

SQL Server 2005 Expressi paigaldamine SQL Server 2005 Expressi paigaldamine Laadige alla.net Framework 2.0 http://www.microsoft.com/downloads/details.aspx?familyid=0856eacb-4362-4b0d- 8edd-aab15c5e04f5 Avage http://www.microsoft.com/express/2005/sql/download/default.aspx

More information

Handling Mouse and Keyboard Events

Handling Mouse and Keyboard Events Handling Mouse and Keyboard Events 605.481 1 Java Event Delegation Model EventListener handleevent(eventobject handleevent(eventobject e); e); EventListenerObject source.addlistener(this);

More information

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals

More information

SINGLE EVENT HANDLING

SINGLE EVENT HANDLING SINGLE EVENT HANDLING Event handling is the process of responding to asynchronous events as they occur during the program run. An event is an action that occurs externally to your program and to which

More information

Graphical User Interfaces in Java - SWING

Graphical User Interfaces in Java - SWING Graphical User Interfaces in Java - SWING Graphical User Interfaces (GUI) Each graphical component that the user can see on the screen corresponds to an object of a class Component: Window Button Menu...

More information

NAS, IP-SAN, CAS. Loeng 4

NAS, IP-SAN, CAS. Loeng 4 NAS, IP-SAN, CAS Loeng 4 Tunniteemad Network Attached Storage IP Storage Attached Network Content Addressed Storage Network Attached Storage Tehnoloogia, kus andmed on jagatud üle võrgu Salvestusvahendile

More information

G51PRG: Introduction to Programming Second semester Applets and graphics

G51PRG: Introduction to Programming Second semester Applets and graphics G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting

More information

Graphical Interfaces

Graphical Interfaces Weeks 11&12 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The

More information

GUI Event Handling 11. GUI Event Handling. Objectives. What is an Event? Hierarchical Model (JDK1.0) Delegation Model (JDK1.1)

GUI Event Handling 11. GUI Event Handling. Objectives. What is an Event? Hierarchical Model (JDK1.0) Delegation Model (JDK1.1) Objectives Write code to handle events that occur in a GUI 11 GUI Event Handling Describe the concept of adapter classes, including how and when to use them Determine the user action that originated the

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,

More information

Graphical Interfaces

Graphical Interfaces Weeks 9&11 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The

More information

Swing from A to Z Some Simple Components. Preface

Swing from A to Z Some Simple Components. Preface By Richard G. Baldwin baldwin.richard@iname.com Java Programming, Lecture Notes # 1005 July 31, 2000 Swing from A to Z Some Simple Components Preface Introduction Sample Program Interesting Code Fragments

More information

IT infrastruktuuri teenused. Failiserver. Margus Ernits

IT infrastruktuuri teenused. Failiserver. Margus Ernits IT infrastruktuuri teenused Failiserver Margus Ernits margus.ernits@itcollege.ee 1 Failide hoidmine kasutaja arvutis pole tihti mõistlik, kuna Failiserver Arvuti kõvaketta hävimisega kaovad andmed ja nendest

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

EESTI STANDARD EVS-ISO 11620:2010

EESTI STANDARD EVS-ISO 11620:2010 EESTI STANDARD EVS-ISO INFORMATSIOON JA DOKUMENTATSIOON Raamatukogu tulemusindikaatorid Information and documentation Library performance indicators (ISO 11620:2008) EVS-ISO EESTI STANDARDI EESSÕNA NATIONAL

More information

Mis on tõene? Tsüklid, failihaldus. if - näited. unless - näited. unless. Merle Sibola. if ($arv > $suur) { #leitakse suurim arv $suur=$arv; } #if

Mis on tõene? Tsüklid, failihaldus. if - näited. unless - näited. unless. Merle Sibola. if ($arv > $suur) { #leitakse suurim arv $suur=$arv; } #if Mis on tõene? Tsüklid, failihaldus Merle Sibola iga string on tõene, välja arvatud "" ja "0" iga number on tõene, v.a. number 0 Iga viide (reference) on tõene Iga defineerimata muutuja on väär. if if (EXPR)

More information

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components CS112-Section2 Hakan Guldas Burcin Ozcan Meltem Kaya Muge Celiktas Notes of 6-8 May Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how

More information

IPv6 harjutused. Aadressi kuju, kirjaviis, osad, liigid Aadressi saamise viisid

IPv6 harjutused. Aadressi kuju, kirjaviis, osad, liigid Aadressi saamise viisid IPv6 harjutused Aadressi kuju, kirjaviis, osad, liigid Aadressi saamise viisid IPv6 aadressi kuju IPv4 32 bitti (4 baidi kaupa) Kuju kümnendarvud 4 kaupa punktidega eraldatud 192.168.252.200 IPv6 128 bitti

More information

Programming Language Concepts: Lecture 8

Programming Language Concepts: Lecture 8 Programming Language Concepts: Lecture 8 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 8, 11 February 2009 GUIs and event

More information

Making Orthophotomosaic about Tartu City with PHOTOMOD Program and Its Geometrical Quality

Making Orthophotomosaic about Tartu City with PHOTOMOD Program and Its Geometrical Quality Making Orthophotomosaic about Tartu City with PHOTOMOD Program and Its Geometrical Quality Natalja LIBA and Ina JÄRVE, Estonia Key words: orthophotomosaic, aerial triangulation, block of imagery, orientation,

More information

BM214E Object Oriented Programming Lecture 13

BM214E Object Oriented Programming Lecture 13 BM214E Object Oriented Programming Lecture 13 Events To understand how events work in Java, we have to look closely at how we use GUIs. When you interact with a GUI, there are many events taking place

More information

Programmeerimine. 3. loeng

Programmeerimine. 3. loeng Programmeerimine 3. loeng Tana loengus T~oevaartustuup ja loogilised avaldised Hargnemisdirektiivid { Lihtne if-lause { if-else-lause { Uldkujuline if-lause Tsuklidirektiivid { Eelkontrolliga tsukkel {

More information

Tsüklidirektiivid. Klass Math. Staatilised meetodid. Massiivid. Koostada programm, mis leiab positiivsete paarisarvude summat vahemikus 1 kuni 20.

Tsüklidirektiivid. Klass Math. Staatilised meetodid. Massiivid. Koostada programm, mis leiab positiivsete paarisarvude summat vahemikus 1 kuni 20. Harjutustund 3 Tsüklidirektiivid. Klass Math. Staatilised meetodid. Massiivid. Tsüklidirektiivid Vaadake teooriat eelmisest praktikumist. Ülesanne 1 Koostada programm, mis leiab esimeste 20 arvude summat

More information

OBJECT ORIENTED PROGRAMMING. Java GUI part 1 Loredana STANCIU Room B616

OBJECT ORIENTED PROGRAMMING. Java GUI part 1 Loredana STANCIU Room B616 OBJECT ORIENTED PROGRAMMING Java GUI part 1 Loredana STANCIU loredana.stanciu@upt.ro Room B616 What is a user interface That part of a program that interacts with the user of the program: simple command-line

More information

GUI in Java TalentHome Solutions

GUI in Java TalentHome Solutions GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator

More information

COMPSCI 230. Software Design and Construction. Swing

COMPSCI 230. Software Design and Construction. Swing COMPSCI 230 Software Design and Construction Swing 1 2013-04-17 Recap: SWING DESIGN PRINCIPLES 1. GUI is built as containment hierarchy of widgets (i.e. the parent-child nesting relation between them)

More information

Androidi rakenduste ligipääsu õigused

Androidi rakenduste ligipääsu õigused Tallinna Ülikool Digitehnoloogiate Instituut Androidi rakenduste ligipääsu õigused Seminaritöö Autor: Martin Kütt Juhendaja: Jaagup Kippar Autor:...... 2017 Juhendaja:...... 2017 Instituudi direktor:......

More information

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

JRadioButton account_type_radio_button2 = new JRadioButton(Current); ButtonGroup account_type_button_group = new ButtonGroup(); Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button

More information

The AWT Event Model 9

The AWT Event Model 9 The AWT Event Model 9 Course Map This module covers the event-based GUI user input mechanism. Getting Started The Java Programming Language Basics Identifiers, Keywords, and Types Expressions and Flow

More information

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Module 4 Multi threaded Programming, Event Handling OOC 4 th Sem, B Div 2017-18 Prof. Mouna M. Naravani Event Handling Complete Reference 7 th ed. Chapter No. 22 Event Handling Any program that uses a

More information

Graafikakomponendid Valmiskomponendid Aken Tekstiväli Valik

Graafikakomponendid Valmiskomponendid Aken Tekstiväli Valik Graafikakomponendid Graafikakomponendid aitavad programmeerijal hõlbustada programmi ja kasutaja suhtlemist. Samad võimalused saab luua ka joonistamisvahendite abil, kuid varem loodud komponentide puhul

More information

Introduction. Introduction

Introduction. Introduction Introduction Many Java application use a graphical user interface or GUI (pronounced gooey ). A GUI is a graphical window or windows that provide interaction with the user. GUI s accept input from: the

More information

2010 가을학기부산대학교정보컴퓨터공학부 OVERVIEW OF GUI PROGRAMMING

2010 가을학기부산대학교정보컴퓨터공학부 OVERVIEW OF GUI PROGRAMMING 2010 가을학기부산대학교정보컴퓨터공학부 OVERVIEW OF GUI PROGRAMMING Outline Graphic User Interface (GUI) Introduction AWT and Swing Graphics Programming Event Handling User Interface Components with Swing 2 Graphic User

More information

Mälu interfeisid Arvutikomponendid Ergo Nõmmiste

Mälu interfeisid Arvutikomponendid Ergo Nõmmiste Mälu interfeisid Arvutikomponendid Ergo Nõmmiste Mälu liigid Read-only memory (ROM) Flash memory (EEPROM) Static random access memory (SRAM) Dynamic random access memoty (DRAM) 1 kbaidine mälu vajab 10

More information

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 331 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic

More information

Method Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is

Method Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is INDEX Event Handling. Key Event. Methods Of Key Event. Example Of Key Event. Mouse Event. Method Of Mouse Event. Mouse Motion Listener. Example of Mouse Event. Event Handling One of the key concept in

More information

Graphical User Interfaces (GUIs)

Graphical User Interfaces (GUIs) CMSC 132: Object-Oriented Programming II Graphical User Interfaces (GUIs) Department of Computer Science University of Maryland, College Park Model-View-Controller (MVC) Model for GUI programming (Xerox

More information

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall (total 7 pages)

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall (total 7 pages) 1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 (total 7 pages) Name: TA s Name: Tutorial: For Graders Question 1 Question 2 Question 3 Total Problem 1 (20 points) True or

More information

Unit 7: Event driven programming

Unit 7: Event driven programming Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.

More information

Graafika ja muusika programmeerimine

Graafika ja muusika programmeerimine Tallinna Pedagoogikaülikool Informaatika osakond Graafika ja muusika programmeerimine Jaagup Kippar Tallinn 2003 1 Eessõna Käesolev konspekt sisaldab näiteid ja seletusi mitmete graafika ning muusika programmeerimisega

More information

Lühike paigaldusjuhend TK-V201S TK-V401S 1.01

Lühike paigaldusjuhend TK-V201S TK-V401S 1.01 Lühike paigaldusjuhend TK-V201S TK-V401S 1.01 Sisukord Eesti 1 1. Enne alustamist 1 2. Riistvara paigaldamine 2 Technical Specifications 8 Tõrkeotsing 9 Version 05.12.2010 1. Enne alustamist Eesti Pakendi

More information

XmlHttpRequest asemel võib olla vajalik objekt XDomainRequest

XmlHttpRequest asemel võib olla vajalik objekt XDomainRequest 1 2 3 XmlHttpRequest asemel võib olla vajalik objekt XDomainRequest 4 5 6 7 8 https://www.trustwave.com/global-security-report http://redmondmag.com/articles/2012/03/12/user-password-not-sophisticated.aspx

More information

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components

More information

Programming Languages and Techniques (CIS120e)

Programming Languages and Techniques (CIS120e) Programming Languages and Techniques (CIS120e) Lecture 29 Nov. 19, 2010 Swing I Event- driven programming Passive: ApplicaHon waits for an event to happen in the environment When an event occurs, the applicahon

More information

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn Java & Graphical User Interface II Wang Yang wyang AT njnet.edu.cn Outline Review of GUI (first part) What is Event Basic Elements of Event Programming Secret Weapon - Inner Class Full version of Event

More information

Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics

Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics 1 Collections (from the Java tutorial)* A collection (sometimes called a container) is simply an object that

More information

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4. 1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program

More information

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement

More information

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC). The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,

More information

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1 Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text

More information

Java põhikursuse konspekt

Java põhikursuse konspekt Tallinna Pedagoogikaülikool Informaatika osakond Jaagup Kippar Java põhikursuse konspekt Tallinn 2003 Sissejuhatus Käesolev kirjutis on mõeldud nii iseõppijatele kui abimaterjaliks õpilastele ja õpetajatele.

More information

University of Cape Town ~ Department of Computer Science. Computer Science 1016S / 1011H ~ November Exam

University of Cape Town ~ Department of Computer Science. Computer Science 1016S / 1011H ~ November Exam Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1016S / 1011H ~ 2009 November Exam Question

More information

1005ICT Object Oriented Programming Lecture Notes

1005ICT Object Oriented Programming Lecture Notes 1005ICT Object Oriented Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 20 GUI Components and Events This section develops a program

More information

Packages: Putting Classes Together

Packages: Putting Classes Together Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

II 12, JFileChooser. , 2. SolidEllipse ( 2), PolyLine.java ( 3). Draw.java

II 12, JFileChooser. , 2. SolidEllipse ( 2), PolyLine.java ( 3). Draw.java II 12, 13 (ono@isnagoya-uacjp) 2007 1 15, 17 2 : 1 2, JFileChooser, 2,,, Draw 1, SolidEllipse ( 2), PolyLinejava ( 3) 1 Drawjava 2 import javaxswing*; 3 import javaawtevent*; import javautil*; 5 import

More information

CS-259 Computer Programming Fundamentals Arrays

CS-259 Computer Programming Fundamentals Arrays CS-9 Computer Programming Fundamentals Arrays int a = new int[]; Instructor: Joel Castellanos e-mail: joel@unm.edu And in such indexes, although small pricks To their subsequent volumes, there is seen

More information

Together, the appearance and how user interacts with the program are known as the program look and feel.

Together, the appearance and how user interacts with the program are known as the program look and feel. Lecture 10 Graphical User Interfaces A graphical user interface is a visual interface to a program. GUIs are built from GUI components (buttons, menus, labels etc). A GUI component is an object with which

More information

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7 PROGRAMMING DESIGN USING JAVA (ITT 303) Graphical User Interface Unit 7 Learning Objectives At the end of this unit students should be able to: Build graphical user interfaces Create and manipulate buttons,

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

SampleApp.java. Page 1

SampleApp.java. Page 1 SampleApp.java 1 package msoe.se2030.sequence; 2 3 /** 4 * This app creates a UI and processes data 5 * @author hornick 6 */ 7 public class SampleApp { 8 private UserInterface ui; // the UI for this program

More information

CSCI 201L Midterm Written Summer % of course grade

CSCI 201L Midterm Written Summer % of course grade CSCI 201L Summer 2016 10% of course grade 1. Abstract Classes and Interfaces Give two differences between an interface and an abstract class in which all of the methods are abstract. (0.5% + 0.5%) 2. Serialization

More information

Building Graphical User Interfaces. GUI Principles

Building Graphical User Interfaces. GUI Principles Building Graphical User Interfaces 4.1 GUI Principles Components: GUI building blocks Buttons, menus, sliders, etc. Layout: arranging components to form a usable GUI Using layout managers. Events: reacting

More information

13 (ono@is.nagoya-u.ac.jp) 2008 1 15 1 factory., factory,. 2 2.,, JFileChooser. 1. Java,,, Serializable *1., FigBase ( 1). FigBase.java 3 5. 1 import java. lang.*; 2 import java. awt.*; 3 import java.

More information