计算与软件工程I15GUI
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
48
2020/11/27
Dong Shao, Nanjing Unviersity
49
2020/11/27
Dong Shao, Nanjing Unviersity
50
2020/11/27
Dong Shao, Nanjing Unviersity
51
19
2020/11/27
Dong Shao, Nanjing Unviersity
20
Make your own drawing widget
2020/11/27
• Make a subclass of JPanel and override one method, paintComponet().
44
2020/11/27
Dong Shao, Nanjing Unviersity
45
2020/11/27
Dong Shao, Nanjing Unviersity
46
2020/11/27
Dong Shao, Nanjing Unviersity
47
2020/11/27
Dong Shao, Nanjing Unviersity
2020/11/27
15 GUI
Dong Shao, Nanjing Unviersity
1
2020/11/27
Dong Shao, Nanjing Unviersity
2
2020/11/27
Dong Shao, Nanjing Unviersity
3
2020/11/27
Dong Shao, Nanjing Unviersity
• Any time the JVM thinks the display needs refreshing, your pintComponent() method will be called.
Dong Shao, Nanjing Unviersity
21
2020/11/27
Dong Shao, Nanjing Unviersity
38
2020/11/27
Dong Shao, Nanjing Unviersity
39
Inner class
2020/11/27
Dong Shao, Nanjing Unviersity
40
2020/11/27
Dong Shao, Nanjing Unviersity
41
Inner object must be tied to a specific outer object on heap
26
2020/11/27
Dong Shao, Nanjing Unviersity
27
2020/11/27
Dong Shao, Nanjing Unviersity
28
2020/11/27
Dong Shao, Nanjing Unviersity
29
2020/11/27
Dong Shao, Nanjing Unviersity
34
2020/11/27
Dong Shao, Nanjing Unviersity
35
2020/11/27
Dong Shao, Nanjing Unviersity
36
2020/11/27
Dong Shao, Nanjing Unviersity
37
2020/11/27
Dong Shao, Nanjing Unviersity
22
2020/11/27
Dong Shao, Nanjing Unviersity
23
2020/11/27
Dong Shao, Nanjing Unviersity
24
2020/11/27
Dong Shao, Nanjing Unviersity
25
2020/11/27
Dong Shao, Nanjing Unviersity
• Think of the paintComponent() method as the method called by the system to say, “Hey widget, time to paint yourself.”
• When the frame holding your drawing panel is displayer, paintComponet() is called and your circle appears. If the user iconifies/minimizes the window, the JVM knows the frame need “repair” when it gets de-iconified, so it calls paintcomponent() again.
11
2020/11/27
Dong Shao, Nanjing Unviersity
12
2020/11/27
Dong Shao, Nanjing Unviersity
13
2020/11/27
Dong Shao, Nanjing Unviersity
14
2020/11/27
Dong Shao, Nanjing Unviersity
15
2020/11/27
Dong Shao, Nanjing Unviersity
16
2020/11/27
Dong Shao, Nanjing Unviersity
17
2020/11/27
Dong Shao, Nanjing Unviersity
18
Graphics
2020/11/27
Dong Shao, Nanjing Unviersity
2020/11/27
Dong Shao, Nanjing Unviersity
42
How to make an instance of an inner class
2020/11/27
Dong Shao, Nanjing Unviersity
43
2020/11/27
Dong Shao, Nanjing Unviersity
Dong Shao, Nanjing Unviersity
8
2020/11/27
Dong Shao, Nanjing Unviersity
9
2020/11/27
Dong Shao, Nanjing Unviersity
10
2020/11/27
Dong Shao, Nanjing Unviersity
30
2020/11/27
Dong Shao, Nanjing Unviersity
31
2020/11/27
Dong Shao, Nanjing Unviersity
32
2020/11/27
Dong Shao, Nanjing Unviersity
Hale Waihona Puke Baidu33
2020/11/27
Dong Shao, Nanjing Unviersity
4
2020/11/27
Dong Shao, Nanjing Unviersity
5
2020/11/27
Dong Shao, Nanjing Unviersity
6
2020/11/27
Dong Shao, Nanjing Unviersity
7
Getting a user event
2020/11/27