- 1、本文档共30页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
一个利用GUI方法实现简单绘图功能的应用程序
目 录
1. 程序设计内容概论··········································1
1.1程序设计的目的·········································1
1.2程序设计的任务·········································1
2 设计思想··················································1
2.1需求分析···············································1
2.2总体设计···············································1
2.2.1面板布局 ·········································1
2.2.2实现绘画图形······································2
2.2.3填充功能··········································2
2.2.4画笔的粗细及画笔的颜色变更························2
2.2.5实现鼠标单击和鼠标拖拽进行绘图····················2
2.3编程环境···············································3
2.4.工具说明··············································3
3 系统流程···················································4
4 设计UML类图··············································5
5 设计层次结构树············································6
6 运行结果与分析············································7
7 设计总结··················································12
8.参考文献··················································13
9.附录·····················································14
1 程序设计内容概论
1.1程序设计的目的
本程序是一个利用GUI方法实现简单绘图功能的应用程序。
1.2程序设计的任务
程序主要创建了5个JRadioButton, 1个JCheckBox,2个JButton以及一个JSlider用于选择绘画功能操作。接着创建三个面板用于设计绘图的整体画板,并利用按钮监听器,滑动条和鼠标操作实现在面板上绘图的简单功能。在程序中,利用创建JRadioButton实现多选一绘画功能,创建JCheckBox实现填充功能,而2个JButton则分别实现颜色更变和清除画板。同时本程序使用了鼠标点击,鼠标释放和鼠标拖拽来进行画板绘画,利用鼠标点击实现初点坐标获取,在绘画曲线时,主要通过鼠标拖拽实现在画板上不断绘制(不断进行末点坐标赋值初点);在绘画直线时,主要通过鼠标拖拽达到动态效果,并通过鼠标释放最终描绘出直线;在绘画矩形和圆时,主要通过鼠标拖拽达到动态效果,并通过鼠标释放最终描绘出矩形和圆;在绘画粗线时,主要通过不断重画实心圆来实现。
2 设计思想
2.1需求分析
2.1.1面板布局
2.1.2实现绘画图形(曲线,直线,圆,椭圆,矩形)
3.1.3填充功能(其中包括圆的填充,椭圆圆的填充,矩形圆的填充)
3.1.4画笔的粗细及画笔的颜色变更
3.1.5实现鼠标单击和鼠标拖拽进行绘图
2.2总体设计
2.2.1面板布局
主要创建5个JRadioButton, 1个JCheckBox,2个JButton以及一个JSlider,同时创建三个面板(一个面板用于绘图,一个面板用于把所有按钮及滑动条等添加进去,一个面板用于把已经添加了按钮和滑动条的面板添加进去,用于区分绘图面板和按钮面板的位置),利用盒式布局管理器将所有的组件(包括5个JRadioButton, 1个JCheckBox,2个JButton以及一个JSlider)进行布局,再利用边界布局管理器对面板进行位置编排,绘图面板在中间,另一个在西边。最终完成了画板的布局。
2.2.2实现绘画图形(曲线,直线,圆,椭圆,矩形)
在实现绘画的功能,主要通过创建ButtonGroup从而把所有的JRa
文档评论(0)