ECE 462 Object-Oriented Programming using C++ and Java. Graphical User Interface

Size: px
Start display at page:

Download "ECE 462 Object-Oriented Programming using C++ and Java. Graphical User Interface"

Transcription

1 ECE 462 Object-Oriented Programming using C++ and Java Graphical User Interface Yung-Hsiang Lu YHL Graphical User Interface 1

2 GUI using C++ / Qt YHL Graphical User Interface 2

3 Qt + Eclipse YHL Graphical User Interface 3

4 YHL Graphical User Interface 4

5 YHL Graphical User Interface 5

6 YHL Graphical User Interface 6

7 YHL Graphical User Interface 7

8 YHL Graphical User Interface 8

9 YHL Graphical User Interface 9

10 YHL Graphical User Interface 10

11 YHL Graphical User Interface 11

12 YHL Graphical User Interface 12

13 YHL Graphical User Interface 13

14 Path Setting (if there are problems) YHL Graphical User Interface 14

15 YHL Graphical User Interface 15

16 YHL Graphical User Interface 16

17 YHL Graphical User Interface 17

18 Qt\bin and MinGW\bin should be in the path YHL Graphical User Interface 18

19 YHL Graphical User Interface 19

20 YHL Graphical User Interface 20

21 YHL Graphical User Interface 21

22 YHL Graphical User Interface 22

23 Qt Widget Box YHL Graphical User Interface 23

24 YHL Graphical User Interface 24

25 YHL Graphical User Interface 25

26 YHL Graphical User Interface 26

27 YHL Graphical User Interface 27

28 YHL Graphical User Interface 28

29 YHL Graphical User Interface 29

30 YHL Graphical User Interface 30

31 YHL Graphical User Interface 31

32 YHL Graphical User Interface 32

33 YHL Graphical User Interface 33

34 YHL Graphical User Interface 34

35 Signals and Slots i.e. events and handlers YHL Graphical User Interface 35

36 YHL Graphical User Interface 36

37 YHL Graphical User Interface 37

38 YHL Graphical User Interface 38

39 YHL Graphical User Interface 39

40 YHL Graphical User Interface 40

41 YHL Graphical User Interface 41

42 YHL Graphical User Interface 42

43 YHL Graphical User Interface 43

44 YHL Graphical User Interface 44

45 YHL Graphical User Interface 45

46 YHL Graphical User Interface 46

47 YHL Graphical User Interface 47

48 YHL Graphical User Interface 48

49 YHL Graphical User Interface 49

50 YHL Graphical User Interface 50

51 YHL Graphical User Interface 51

52 YHL Graphical User Interface 52

53 YHL Graphical User Interface 53

54 YHL Graphical User Interface 54

55 Default Parameter Values YHL Graphical User Interface 55

56 Default Parameter Values in C++ always start from the last parameter func1(int x, int y, int z = 0)... func1(int x, int y = 1, int z = 0)... func1(int x = 2, int y = 1, int z = 0)... func1(1,2,3) means x = 1, y = 2, z = 3 func1(4, 5) means x = 4, y = 5, z = 0 func1(6) means x = 6, y = 1, z = 0 func1() means x = 2, y = 1, z = 0 cannot skip any parameter (otherwise, ambiguous) func1(int x = 2, int y, int z = 0)... what does func1(3, 4) mean? YHL Graphical User Interface 56

57 Graphical User Interface (GUI) Most GUIs are built using OOP because OOP is a natural way to support GUI. GUI has "containers", such as QWidget, that can include buttons, labels, scrollbars... When the widget is redrawn (restore from minimized, maximized, or content update), the frame asks each component to redraw itself. Each object knows how to redraw itself because paintevent(c++ / Qt) or paintcomponent (Java) is overridden. YHL Graphical User Interface 57

58 GUI using Java YHL Graphical User Interface 58

59 JFrame is a derived class of Container YHL Graphical User Interface 59

60 YHL Graphical User Interface 60

61 many derived classes YHL Graphical User Interface 61

62 Derived classes override paintcomponent YHL Graphical User Interface 62

63 JFrame similar to QWidget YHL Graphical User Interface 63

64 add components from the palette A frame may contain many objects, such as buttons, labels, scrollbar... YHL Graphical User Interface 64

65 The objects are contained in the NewJFrame class YHL Graphical User Interface 65

66 The objects are created by using new. Netbeans creates initcomponent. Do not modify it. YHL Graphical User Interface 66

67 Handle User Actions YHL Graphical User Interface 67

68 Handle Button Click Events Action Action Performed YHL Graphical User Interface 68

69 YHL Graphical User Interface 69

70 YHL Graphical User Interface 70

71 Handle Scrollbar Events Events Change State Changed YHL Graphical User Interface 71

72 YHL Graphical User Interface 72

73 YHL Graphical User Interface 73

74 YHL Graphical User Interface 74

75 YHL Graphical User Interface 75

76 JSlider default range is YHL Graphical User Interface 76

77 Handle Mouse Motion Events Mouse Motion MouseMoved YHL Graphical User Interface 77

78 YHL Graphical User Interface 78

79 YHL Graphical User Interface 79

80 Self Test YHL Graphical User Interface 80

81 ECE 462 Object-Oriented Programming using C++ and Java Qt Signals and Slots Yung-Hsiang Lu YHL Qt Signals and Slots 1

82 Write Qt Programs without Eclipse (still Eclipse for version control) A better way to know how it works. Many examples are obtained by modified Qt samples. Copyright Trolltech. YHL Qt Signals and Slots 2

83 Qt Examples YHL Qt Signals and Slots 3

84 YHL Qt Signals and Slots 4

85 YHL Qt Signals and Slots 5

86 YHL Qt Signals and Slots 6

87 Simple Example Vertical Layout YHL Qt Signals and Slots 7

88 YHL Qt Signals and Slots 8

89 YHL Qt Signals and Slots 9

90 YHL Qt Signals and Slots 10

91 YHL Qt Signals and Slots 11

92 Create Qt Executable 1. qmake -project 2. qmake 3. make This works for both Linux and Windows. YHL Qt Signals and Slots 12

93 YHL Qt Signals and Slots 13

94 YHL Qt Signals and Slots 14

95 YHL Qt Signals and Slots 15

96 YHL Qt Signals and Slots 16

97 YHL Qt Signals and Slots 17

98 derived class of QWidget macro to enable signals and slots default value of the parent widget YHL Qt Signals and Slots 18

99 this includes many Qt classes window's title vertical layout add a button add a label add a slider YHL Qt Signals and Slots 19

100 GUI and OOP vbox->addwidget(button1); vbox->addwidget(label1); vbox->addwidget(edit1); vbox->addwidget(slider1); These are objects of different classes. These classes are derived class of QWidget. If a function requires an object of QWidget, the function can be called with an object of QLabel. Any QLabel object is also a QWidget object (wrong in the other direction). YHL Qt Signals and Slots 20

101 YHL Qt Signals and Slots 21

102 YHL Qt Signals and Slots 22

103 YHL Qt Signals and Slots 23

104 YHL Qt Signals and Slots 24

105 QPushButton, QLineEdit, and QSlider all inherit QWidget YHL Qt Signals and Slots 25

106 YHL Qt Signals and Slots 26

107 YHL Qt Signals and Slots 27

108 YHL Qt Signals and Slots 28

109 YHL Qt Signals and Slots 29

110 YHL Qt Signals and Slots 30

111 Now, you should understand why GUI is often built with OOP. YHL Qt Signals and Slots 31

112 Eclipse + Emacs use the version control in Eclipse edit code using Emacs YHL Qt Signals and Slots 32

113 YHL Qt Signals and Slots 33

114 YHL Qt Signals and Slots 34

115 not the default workspace YHL Qt Signals and Slots 35

116 do not build automatically YHL Qt Signals and Slots 36

117 YHL Qt Signals and Slots 37

118 YHL Qt Signals and Slots 38

119 YHL Qt Signals and Slots 39

120 do not commit Makefile YHL Qt Signals and Slots 40

121 Add Slots and Connect Signals YHL Qt Signals and Slots 41

122 add private functions (slots) make the objects attributes because they are used in multiple functions CVS version number shown in emacs YHL Qt Signals and Slots 42

123 objects YHL Qt Signals and Slots 43

124 YHL Qt Signals and Slots 44

125 YHL Qt Signals and Slots 45

126 YHL Qt Signals and Slots 46

127 YHL Qt Signals and Slots 47

128 YHL Qt Signals and Slots 48

129 YHL Qt Signals and Slots 49

130 YHL Qt Signals and Slots 50

131 YHL Qt Signals and Slots 51

132 Draw Geometric Shapes YHL Qt Signals and Slots 52

133 new object YHL Qt Signals and Slots 53

134 new object YHL Qt Signals and Slots 54

135 YHL Qt Signals and Slots 55

136 YHL Qt Signals and Slots 56

137 draw rectangle YHL Qt Signals and Slots 57

138 draw circle YHL Qt Signals and Slots 58

139 draw text YHL Qt Signals and Slots 59

140 YHL Qt Signals and Slots 60

141 Handle Mouse Event YHL Qt Signals and Slots 61

142 called when mouse moves does not have to use connect function YHL Qt Signals and Slots 62

143 YHL Qt Signals and Slots 63

144 YHL Qt Signals and Slots 64

145 Collision Detection YHL Qt Signals and Slots 65

146 detect collision with the boundary (static values) YHL Qt Signals and Slots 66

147 Timer Update YHL Qt Signals and Slots 67

148 YHL Qt Signals and Slots 68

149 YHL Qt Signals and Slots 69

150 Memory Management What is created by new should be destroyed by delete. YHL Qt Signals and Slots 70

151 YHL Qt Signals and Slots 71

152 YHL Qt Signals and Slots 72

153 Qt and Valgrind Valgrind and Qt do not work well together. Fortunately, we can follow a simple rule for memory management. YHL Qt Signals and Slots 73

154 Delete every object that is created by new. YHL Qt Signals and Slots 74

155 Self Test YHL Qt Signals and Slots 75

156 ECE 462 Object-Oriented Programming using C++ and Java Java Events and Handlers Yung-Hsiang Lu YHL Java Events and Handlers 1

157 YHL Java Events and Handlers 2

158 YHL Java Events and Handlers 3

159 YHL Java Events and Handlers 4

160 YHL Java Events and Handlers 5

161 YHL Java Events and Handlers 6

162 add one button and two labels YHL Java Events and Handlers 7

163 change the text YHL Java Events and Handlers 8

164 Add a Derived Class of JPanel YHL Java Events and Handlers 9

165 YHL Java Events and Handlers 10

166 YHL Java Events and Handlers 11

167 YHL Java Events and Handlers 12

168 YHL Java Events and Handlers 13

169 Handle Mouse Event YHL Java Events and Handlers 14

170 YHL Java Events and Handlers 15

171 YHL Java Events and Handlers 16

172 YHL Java Events and Handlers 17

173 YHL Java Events and Handlers 18

174 YHL Java Events and Handlers 19

175 YHL Java Events and Handlers 20

176 YHL Java Events and Handlers 21

177 YHL Java Events and Handlers 22

178 YHL Java Events and Handlers 23

179 YHL Java Events and Handlers 24

180 Shrink the Panel YHL Java Events and Handlers 25

181 YHL Java Events and Handlers 26

182 YHL Java Events and Handlers 27

183 YHL Java Events and Handlers 28

184 Add Timer YHL Java Events and Handlers 29

185 YHL Java Events and Handlers 30

186 YHL Java Events and Handlers 31

187 YHL Java Events and Handlers 32

188 Format String YHL Java Events and Handlers 33

189 YHL Java Events and Handlers 34

190 YHL Java Events and Handlers 35

191 Start and Pause YHL Java Events and Handlers 36

192 YHL Java Events and Handlers 37

193 YHL Java Events and Handlers 38

194 YHL Java Events and Handlers 39

195 Add JPanel to Contain Button and Labels YHL Java Events and Handlers 40

196 YHL Java Events and Handlers 41

197 YHL Java Events and Handlers 42

198 Self Test YHL Java Events and Handlers 43

199 ECE 462 Object-Oriented Programming using C++ and Java Array Yung-Hsiang Lu YHL Array 1

200 Array Java C++ int [] dataarray = new int[4]; dataarray[2] = 7; // Java uses garbage collection // start from [0] User [] usrlist = new User[10]; // int dataarray[8] error // Java arrays know their lengths dataarray.length; int * dataarray = new int[4]; dataarray[2] = 7; delete [] dataarray; // use [] // same User * usrlist = new User[10]; int dataarray[8]; // not for C++ YHL Array 2

201 Java Array YHL Array 3

202 Array of int YHL Array 4

203 YHL Array 5

204 Array of Objects YHL Array 6

205 YHL Array 7

206 YHL Array 8

207 Person [] personarray = new Person[8]; personarray[index] = new Person (...) Peter, 5 personarray[index] = new Person (...) Lisa, 12 YHL Array 9

208 C++ Array YHL Array 10

209 Array of int YHL Array 11

210 YHL Array 12

211 Array of Objects YHL Array 13

212 YHL Array 14

213 YHL Array 15

214 YHL Array 16

215 YHL Array 17

216 Person * * personarray = new Person* [arraysize]; personarray[index] = new Person (...) Peter, 5 personarray[index] = new Person (...) Lisa, 12 YHL Array 18

217 Objects Contain Arrays YHL Array 19

218 Java YHL Array 20

219 YHL Array 21

220 YHL Array 22

221 C++ YHL Array 23

222 need another attribute to store the number of elements in the array YHL Array 24

223 YHL Array 25

224 YHL Array 26

225 delete without [] (because it is not an array) YHL Array 27

226 Self Test YHL Array 28

ECE 462 Object-Oriented Programming using C++ and Java. Key Inputs in Java Games

ECE 462 Object-Oriented Programming using C++ and Java. Key Inputs in Java Games ECE 462 Object-Oriented Programming g using C++ and Java Key Inputs in Java Games Yung-Hsiang Lu yunglu@purdue.edu d YHL Java Key Input 1 Handle Key Events have the focus of the keyboard inputs by calling

More information

ECE 462 Object-Oriented Programming using C++ and Java. Scheduling and Critical Section

ECE 462 Object-Oriented Programming using C++ and Java. Scheduling and Critical Section ECE 462 Object-Oriented Programming g using C++ and Java Scheduling and Critical Section Yung-Hsiang Lu yunglu@purdue.edu d YHL Scheduling and Critical Section 1 Thread States born terminated ready running

More information

Object-Oriented Programming

Object-Oriented Programming iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 33 Overview 1 2 3 4 5 6 2 / 33 I Qt is a cross-platform application and UI framework in C++. Using Qt, one can write GUI applications once and deploy

More information

ECE 462 Object-Oriented Programming using C++ and Java. Multi-Player Game using Network

ECE 462 Object-Oriented Programming using C++ and Java. Multi-Player Game using Network ECE 462 Object-Oriented Programming g using C++ and Java Multi-Player Game using Network Yung-Hsiang Lu yunglu@purdue.edu d YHL Multi-Player Game 1 Demonstration YHL Multi-Player Game 2 YHL Multi-Player

More information

C++ GUI Programming with Qt 3

C++ GUI Programming with Qt 3 Welcome from Budapest Welcome from ELTE University 1 Rozália Szabó Nacsa Eötvös Loránd University, Budapest Faculty of Informatics nacsa@inf.elte.hu 2 Qt Overview Qt is a complete C++ application development

More information

2. The quiz screen showing the question, text field (QLineEdit in QT) for the answer and the Next Question button

2. The quiz screen showing the question, text field (QLineEdit in QT) for the answer and the Next Question button SFDV4001 OOP with C++ and UI Part 2 of the Quiz System project implementing the user interface In this part of the project use will use QT to build the GUI for the project you have done in part 1. Instead

More information

Object Orientated Programming in Java. Benjamin Kenwright

Object Orientated Programming in Java. Benjamin Kenwright Graphics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Graphical Principals JFrame Window (Popup Windows) Extending JFrame Drawing from paintcomponent Drawing images/text/graphics

More information

ECE 462 Object-Oriented Programming using C++ and Java. Parallelism

ECE 462 Object-Oriented Programming using C++ and Java. Parallelism ECE 462 Object-Oriented Programming g using C++ and Java Parallelism Yung-Hsiang Lu yunglu@purdue.edu d YHL Parallelism 1 Parallelism parallel: several activities occurring simultaneously Parallelism is

More information

2IS45 Programming

2IS45 Programming Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.

More information

Lab 12: GUI programming with Qt

Lab 12: GUI programming with Qt Lab 12: GUI programming with Comp Sci 1585 Data Structures Lab: Tools for Computer Scientists Outline 1 Outline 1 (Pronounced cute ) https://www.qt.io/what-is-qt/ https://showroom.qt.io/ https://en.wikipedia.org/wiki/_(software)

More information

Qt Essentials - Objects Module

Qt Essentials - Objects Module Qt Essentials - Objects Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. Module: Signals & Slots Event Handling

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Kevin Zatloukal Summer 2017 Java Graphics and GUIs (Based on slides by Mike Ernst, Dan Grossman, David Notkin, Hal Perkins, Zach Tatlock) Review: how to create

More information

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology:

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology: Inheritance 1 Inheritance One class inherits from another if it describes a specialized subset of objects Terminology: the class that inherits is called a child class or subclass the class that is inherited

More information

ECE 462 Object-Oriented Programming using C++ and Java. Flickering and Double Buffering

ECE 462 Object-Oriented Programming using C++ and Java. Flickering and Double Buffering ECE 462 Object-Oriented Programming g using C++ and Java Flickering and Double Buffering Yung-Hsiang Lu yunglu@purdue.edu d YHL Double Buffering 1 Flickering YHL Double Buffering 2 No Flickering YHL Double

More information

ECE 462 Object-Oriented Programming using C++ and Java. Testing

ECE 462 Object-Oriented Programming using C++ and Java. Testing ECE 462 Object-Oriented Programming g using C++ and Java Testing Yung-Hsiang Lu yunglu@purdue.edu YHL Testing 1 Unreachable Code If a, b, and c are zeros or positive numbers (a + c) < b a > b is impossible

More information

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I Electrical and Computer Engineering Object-Oriented Topic : Graphics GUI Part I Maj Joel Young Joel.Young@afit.edu 15-Sep-03 Maj Joel Young A Brief History Lesson AWT Abstract Window Toolkit Implemented

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

ECE 3574: Dynamic Polymorphism using Inheritance

ECE 3574: Dynamic Polymorphism using Inheritance 1 ECE 3574: Dynamic Polymorphism using Inheritance Changwoo Min 2 Administrivia Survey on class will be out tonight or tomorrow night Please, let me share your idea to improve the class! 3 Meeting 10:

More information

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms. Java GUI Windows Events Drawing 1 Java GUI Toolkits Toolkit AWT Description Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

UI Software Organization

UI Software Organization UI Software Organization The user interface From previous class: Generally want to think of the UI as only one component of the system Deals with the user Separate from the functional core (AKA, the app

More information

Widgets. Widgets Widget Toolkits. User Interface Widget

Widgets. Widgets Widget Toolkits. User Interface Widget Widgets Widgets Widget Toolkits 2.3 Widgets 1 User Interface Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, drop-down menus, spinners, file dialog boxes,

More information

5. In JAVA, is exception handling implicit or explicit or both. Explain with the help of example java programs. [16]

5. In JAVA, is exception handling implicit or explicit or both. Explain with the help of example java programs. [16] Code No: R05220402 Set No. 1 1. (a) java is freeform language. Comment (b) Describe in detail the steps involved in implementing a stand-alone program. (c) What are command line arguments? How are they

More information

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons CompSci 125 Lecture 17 GUI: Graphics, Check Boxes, Radio Buttons Announcements GUI Review Review: Inheritance Subclass is a Parent class Includes parent s features May Extend May Modify extends! Parent

More information

CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1

CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1 P a g e 1 CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1 Q1 Describe some Characteristics/Advantages of Java Language? (P#12, 13, 14) 1. Java

More information

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. Event Architecture. A pipeline: Event Capture

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. Event Architecture. A pipeline: Event Capture Event Dispatch Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch 2.4 Event Dispatch 1 Event Architecture A pipeline: - Capture and Queue low-level hardware events - Dispatch

More information

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. 2.4 Event Dispatch 1

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. 2.4 Event Dispatch 1 Event Dispatch Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch 2.4 Event Dispatch 1 Event Architecture A pipeline: - Capture and Queue low-level hardware events - Dispatch

More information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

Java Programming. Computer Science 112

Java Programming. Computer Science 112 Java Programming Computer Science 112 Recap: Swing You use Window Builder to put Widgets together on a Layout. User interacts with Widgets to produce Events. Code in the Client Listens for Events to know

More information

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

More information

Laying Out Components. What is Widget Layout?

Laying Out Components. What is Widget Layout? Laying Out Components Interior Design for GUIs What is Widget Layout? Positioning widgets in their container (typically a JPanel or a JFrame s content pane) Basic idea: each widget has a size and position

More information

2. (True/False) All methods in an interface must be declared public.

2. (True/False) All methods in an interface must be declared public. Object and Classes 1. Create a class Rectangle that represents a rectangular region of the plane. A rectangle should be described using four integers: two represent the coordinates of the upper left corner

More information

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs What is Widget Layout? Laying Out Components Positioning widgets in their container (typically a JPanel or a JFrame s content pane) Basic idea: each widget has a size and position Main problem: what if

More information

Control Statements: Part Pearson Education, Inc. All rights reserved.

Control Statements: Part Pearson Education, Inc. All rights reserved. 1 5 Control Statements: Part 2 5.2 Essentials of Counter-Controlled Repetition 2 Counter-controlled repetition requires: Control variable (loop counter) Initial value of the control variable Increment/decrement

More information

What is Widget Layout? COSC 3461 User Interfaces. Hierarchical Widget Layout. Resizing a Window. Module 5 Laying Out Components

What is Widget Layout? COSC 3461 User Interfaces. Hierarchical Widget Layout. Resizing a Window. Module 5 Laying Out Components COSC User Interfaces Module 5 Laying Out Components What is Widget Layout? Positioning widgets in their container (typically a JPanel or a JFrame s content pane) Basic idea: each widget has a size and

More information

This page intentionally left blank

This page intentionally left blank This page intentionally left blank arting Out with Java: From Control Structures through Objects International Edition - PDF - PDF - PDF Cover Contents Preface Chapter 1 Introduction to Computers and Java

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

Event-driven Programming: GUIs

Event-driven Programming: GUIs Dr. Sarah Abraham University of Texas at Austin Computer Science Department Event-driven Programming: GUIs Elements of Graphics CS324e Spring 2018 Event-driven Programming Programming model where code

More information

Software Construction

Software Construction Lecture 11: Command Design Pattern Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering & Technology

More information

Qt Essentials - Widgets Module

Qt Essentials - Widgets Module Qt Essentials - Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. Module: Common Layout Management Guidelines

More information

Qt Essentials - Fundamentals of Qt Module

Qt Essentials - Fundamentals of Qt Module Qt Essentials - Fundamentals of Qt Module Qt Essentials - Training Course Produced by Nokia, Qt Development Frameworks Material based on Qt 4.7, created on December 15, 2010 http://qt.nokia.com 1/28 Module:

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

I.1 Introduction Matisse GUI designer I.2 GroupLayout Basics Sequential and Parallel Arrangements sequential horizontal orientation

I.1 Introduction Matisse GUI designer I.2 GroupLayout Basics Sequential and Parallel Arrangements sequential horizontal orientation I GroupLayout I.1 Introduction Java SE 6 includes a powerful layout manager called GroupLayout, which is the default layout manager in the NetBeans IDE (www.netbeans.org). In this appendix, we overview

More information

CS 11 java track: lecture 3

CS 11 java track: lecture 3 CS 11 java track: lecture 3 This week: documentation (javadoc) exception handling more on object-oriented programming (OOP) inheritance and polymorphism abstract classes and interfaces graphical user interfaces

More information

Qt Quick From bottom to top

Qt Quick From bottom to top SERIOUS ABOUT SOFTWARE Qt Quick From bottom to top Timo Strömmer, Feb 11, 2011 1 Contents Day 2 Qt core features Shared data objects Object model, signals and slots, properties Hybrid programming QML fluid

More information

Exercises Lecture 3 Layouts and widgets

Exercises Lecture 3 Layouts and widgets Exercises Lecture 3 Layouts and widgets Aim: Duration: This exercise will help you explore and understand Qt's widgets and the layout approach to designing user interfaces. 2h The enclosed Qt Materials

More information

Lecture 18 Java Graphics and GUIs

Lecture 18 Java Graphics and GUIs CSE 331 Software Design and Implementation The plan Today: introduction to Java graphics and Swing/AWT libraries Then: event-driven programming and user interaction Lecture 18 Java Graphics and GUIs None

More information

CSC207 Week 4. Larry Zhang

CSC207 Week 4. Larry Zhang CSC207 Week 4 Larry Zhang 1 Logistics A1 Part 1, read Arnold s emails. Follow the submission schedule. Read the Q&A session in the handout. Ask questions on the discussion board. Submit on time! Don t

More information

Lecture 7 A First Graphic Program And Data Structures & Drawing

Lecture 7 A First Graphic Program And Data Structures & Drawing Lecture 7 A First Graphic Program And Data Structures & Drawing Objective The objective is that you will understand: How to program the generation of 2D and 3D images. How to manipulate those images through

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

INSTRUCTIONS: GOOD LUCK! [TURN OVER]

INSTRUCTIONS: GOOD LUCK! [TURN OVER] INSTRUCTIONS: 1. This examination paper consists of 6 pages. 2. This is a closed book examination. 3. The mark for each question is given in brackets next to the question. 4. Answer all five questions

More information

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN CSSE 220 Event Based Programming Check out EventBasedProgramming from SVN Interfaces are contracts Interfaces - Review Any class that implements an interface MUST provide an implementation for all methods

More information

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain

More information

Windows and Events. created originally by Brian Bailey

Windows and Events. created originally by Brian Bailey Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating

More information

Inheritance, Polymorphism and the Object Memory Model

Inheritance, Polymorphism and the Object Memory Model Inheritance, Polymorphism and the Object Memory Model 1 how objects are stored in memory at runtime? compiler - operations such as access to a member of an object are compiled runtime - implementation

More information

Mobile Development Workshop DAY 2: INTRODUCTION TO JAVA

Mobile Development Workshop DAY 2: INTRODUCTION TO JAVA Mobile Development Workshop DAY 2: INTRODUCTION TO JAVA Overview Morning session For loops Strings and collections Graphical User Interfaces Recap Last time we covered Java the programming language and

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Parts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions.

Parts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions. Parts of a Contract Syntax - Method signature Method name Parameter list Return type Semantics - Comments Preconditions: requirements placed on the caller Postconditions: what the method modifies and/or

More information

Qt Essentials - Fundamentals of Qt Module

Qt Essentials - Fundamentals of Qt Module Qt Essentials - Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. The Story of Qt Developing a Hello World

More information

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo Widgets Overview Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, progress

More information

Qt-Based Implementation of Low Level ROOT Graphical Layer

Qt-Based Implementation of Low Level ROOT Graphical Layer Qt-Based Implementation of Low Level ROOT Graphical Layer By V.Fine ROOT Low Level Graphics Level It is well-known that ROOT package has been ported to many different platforms which include the various

More information

Inheritance, and Polymorphism.

Inheritance, and Polymorphism. Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to

More information

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1 Widgets Widgets Widget Toolkits 2.3 Widgets 1 User Interface Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, drop-down menus, spinners, file dialog boxes,

More information

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout.

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout. COSC 3461: Module 5B Resizing a Window Widgets II What has changed? scrollbar added menu has wrapped toolbar modified (buttons lost) 2 What is Widget Layout? Size State Transitions Recall: each widget

More information

Summary Chapter 25 GUI Components: Part 2

Summary Chapter 25 GUI Components: Part 2 1040 Chapter 25 GUI Components: Part 2 ponent on the line. TheJTextField is added to the content pane with a call to our utility method addcomponent (declared at lines 79 83). MethodaddComponent takes

More information

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled

More information

Polymorphism and Interfaces. CGS 3416 Spring 2018

Polymorphism and Interfaces. CGS 3416 Spring 2018 Polymorphism and Interfaces CGS 3416 Spring 2018 Polymorphism and Dynamic Binding If a piece of code is designed to work with an object of type X, it will also work with an object of a class type that

More information

Exercises Lecture 6 The Graphics View Canvas

Exercises Lecture 6 The Graphics View Canvas Exercises Lecture 6 The Graphics View Canvas Aim: Duration: This exercise will take you through the process of using the Graphics View framework as well as extending it with custom items. 1h The enclosed

More information

Whether to Include Java 8 Features in Introductory CS Courses

Whether to Include Java 8 Features in Introductory CS Courses CCSC Eastern Conference 2015 Tutorial Whether to Include Java 8 Features in Introductory CS Courses James Heliotis Computer Science Rochester Inst. of Technology jeh@cs.rit.edu 1 Our History in Java Education

More information

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development CSCI 053 Introduction to Software Development Rhys Price Jones Week 5 Java is like Alice not based on Joel Adams you may want to take notes Objectives Learn to use the Eclipse IDE Integrated Development

More information

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26, SERIOUS ABOUT SOFTWARE Qt Core features Timo Strömmer, May 26, 2010 1 Contents C++ refresher Core features Object model Signals & slots Event loop Shared data Strings Containers Private implementation

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming

More information

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in Lab 4 D0010E Object-Oriented Programming and Design Lecture 9 Lab 4: You will implement a game that can be played over the Internet. The networking part has already been written. Among other things, the

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Hal Perkins Winter 2018 Java Graphics and GUIs 1 The plan Today: introduction to Java graphics and Swing/AWT libraries Then: event-driven programming and user interaction

More information

OVERRIDING. 7/11/2015 Budditha Hettige 82

OVERRIDING. 7/11/2015 Budditha Hettige 82 OVERRIDING 7/11/2015 (budditha@yahoo.com) 82 What is Overriding Is a language feature Allows a subclass or child class to provide a specific implementation of a method that is already provided by one of

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

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

Qt Essentials - Graphics View Module

Qt Essentials - Graphics View Module Qt Essentials - Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. Using GraphicsView Classes Coordinate Systems

More information

Praktische Aspekte der Informatik

Praktische Aspekte der Informatik Praktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor https://graphics.tu-bs.de/teaching/ws1718/padi/ 1 Your Proposal It s due 17.11.2017! https://graphics.tu-bs.de/teaching/ws1718/padi/

More information

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008 Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object

More information

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1 Block I Unit 2 Basic Constructs in Java M301 Block I, unit 2 1 Developing a Simple Java Program Objectives: Create a simple object using a constructor. Create and display a window frame. Paint a message

More information

Object Oriented Programming. Week 1 Part 3 Writing Java with Eclipse and JUnit

Object Oriented Programming. Week 1 Part 3 Writing Java with Eclipse and JUnit Object Oriented Programming Part 3 Writing Java with Eclipse and JUnit Today's Lecture Test Driven Development Review (TDD) Building up a class using TDD Adding a Class using Test Driven Development in

More information

Acknowledgments...xvii. Introduction... Chapter 1: Getting Started Chapter 2: Build a Hi-Lo Guessing Game App!... 19

Acknowledgments...xvii. Introduction... Chapter 1: Getting Started Chapter 2: Build a Hi-Lo Guessing Game App!... 19 Brief Contents Acknowledgments...xvii Introduction... xix Chapter 1: Getting Started... 1 Chapter 2: Build a Hi-Lo Guessing Game App!... 19 Chapter 3: Creating a GUI for Our Guessing Game... 43 Chapter

More information

Events. Dispatch, event-to-code binding. Review: Events Defined 1/17/2014. occurrence.

Events. Dispatch, event-to-code binding. Review: Events Defined 1/17/2014. occurrence. Events Dispatch, event-to-code binding Review: Events Defined 1. An observable occurrence, phenomenon, or an extraordinary occurrence. 2. A message to notify an application that something happened. Examples:

More information

Document Revision No.: 1 Revised: 03/12/09 RIT KGCOE MSD Program. P09027 Upper Extremity Motion Capture System. Software Manual

Document Revision No.: 1 Revised: 03/12/09 RIT KGCOE MSD Program. P09027 Upper Extremity Motion Capture System. Software Manual P09027 Upper Extremity Motion Capture System Software Manual By: Melissa Gilbert, Dan Chapman, Adey Gebregiorgis, Pooja Nanda, Alan Smith and J.J Guerrette Table of contents 1 GUI USER MANUAL... 2 1.1

More information

Part I: Learn Common Graphics Components

Part I: Learn Common Graphics Components OOP GUI Components and Event Handling Page 1 Objectives 1. Practice creating and using graphical components. 2. Practice adding Event Listeners to handle the events and do something. 3. Learn how to connect

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"

More information

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun! Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques

More information

Chapter 12 Advanced GUIs and Graphics

Chapter 12 Advanced GUIs and Graphics Chapter 12 Advanced GUIs and Graphics Chapter Objectives Learn about applets Explore the class Graphics Learn about the classfont Explore the classcolor Java Programming: From Problem Analysis to Program

More information

Data Structures and Other Objects Using C++

Data Structures and Other Objects Using C++ Inheritance Chapter 14 discuss Derived classes, Inheritance, and Polymorphism Inheritance Basics Inheritance Details Data Structures and Other Objects Using C++ Polymorphism Virtual Functions Inheritance

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 26 March 23, 2016 Inheritance and Dynamic Dispatch Chapter 24 Inheritance Example public class { private int x; public () { x = 0; } public void incby(int

More information

Internship Report - Trondheim, April D Model Programming. Students : Tutors :

Internship Report - Trondheim, April D Model Programming. Students : Tutors : Internship Report - Trondheim, April 2016 3D Model Programming Students : Tutors : Raphaël FITOUSSI Matthias POTTIEZ M. Tomas HOLT M. Jan H. NILSEN 1 Acknowledgements We would like to sincerely thank Mr.

More information

First Name: AITI 2004: Exam 2 July 19, 2004

First Name: AITI 2004: Exam 2 July 19, 2004 First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: Standard Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand

More information

Event Dispatch. Dispatching events to windows and widgets.

Event Dispatch. Dispatching events to windows and widgets. Event Dispatch Dispatching events to windows and widgets. Review: Event Architecture 2 Event capture, processing and dispatch. Event Capture Hardware events (interrupts) Event Dispatch Software events

More information

Testing Object-Oriented Software. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Testing Object-Oriented Software. COMP 4004 Fall Notes Adapted from Dr. A. Williams Testing Object-Oriented Software COMP 4004 Fall 2008 Notes Adapted from Dr. A. Williams Dr. A. Williams, Fall 2008 Software Quality Assurance Lec 9 1 Testing Object-Oriented Software Relevant characteristics

More information

Object Oriented Programming. Java-Lecture 11 Polymorphism

Object Oriented Programming. Java-Lecture 11 Polymorphism Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class

More information

Quick Multitouch Apps using kivy and Python

Quick Multitouch Apps using kivy and Python Quick Multitouch Apps using kivy and Python About Me! Python and Kivy + Setting up Kivy... 1) in Linux 2) in Windows 3) Mac OSX Hello World in Kivy :) Controlling the Environment Many environment variables

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