Professional Documents
Culture Documents
GUI Programming PDF
GUI Programming PDF
2/10/18
John Roberts
2
Overview
• Swing
• Layouts
• Calculator Example
• Paint Example
3
Overview
5
Overview
• Swing
• Layouts
• Calculator Example
• Paint Example
6
Event Driven Programming
8
Overview
• Swing
• Layouts
• Calculator Example
• Paint Example
9
Layouts
• Default layout
11
BorderLayout
12
GridLayout
14
Reference
• https://docs.oracle.com/javase/tutorial/uiswing/layout/
visual.html
15
Overview
• Swing
• Layouts
• Calculator Example
• Paint Example
16
Calculator
17
Layout
18
Layout
PAGE_START
CENTER
19 This is your assignment
Implementation It’s bad because repetition and the UI is doing all the calculations (not SRP)
• Github Calculator.java
• The code in this example only works for add - let’s talk
about what needs to change in order to make it work for
all of the operations…
20
Overview
• Swing
• Layouts
• Calculator Example
• Paint Example
21
Basic Paint
• Github Paint
22
Handling Mouse Events
• MouseListener interface (javadocs)
23
Handling Mouse Events
24
Paint Implementation