java语言程序设计 基础篇原书第八版课件 PPT(第十五章).ppt
《java语言程序设计 基础篇原书第八版课件 PPT(第十五章).ppt》由会员分享,可在线阅读,更多相关《java语言程序设计 基础篇原书第八版课件 PPT(第十五章).ppt(32页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Chapter15Graphics1MotivationsIfyouwanttodrawshapessuchasabarchart,aclock,orastopsign,howdoyoudoit?2ObjectivesFTodescribeJavacoordinatesystemsinaGUIcomponent(15.2).FTodrawthingsusingthemethodsintheGraphicsclass(15.3).FTooverridethepaintComponentmethodtodrawthingsonaGUIcomponent(15.3).FTouseapanelasac
2、anvastodrawthings(15.3).FTodrawstrings,lines,rectangles,ovals,arcs,andpolygons(15.4,15.6-15.7).FToobtainfontpropertiesusingFontMetricsandknowhowtocenteramessage(15.8).FTodisplayanimageinaGUIcomponent(15.11).FTodevelopreusableGUIcomponentsFigurePanel,MessagePanel,StillClock,andImageViewer(15.5,15.9,1
3、5.10,15.12).3JavaCoordinateSystem4EachGUIComponentHasitsOwnCoordinateSystem5TheGraphicsClassYoucandrawstrings,lines,rectangles,ovals,arcs,polygons,andpolylines,usingthemethodsintheGraphicsclass.6paintComponentExampleInordertodrawthingsonacomponent,youneedtodefineaclassthatextendsJPanelandoverridesit
4、spaintComponentmethodtospecifywhattodraw.ThefirstprograminthischaptercanberewrittenusingpaintComponent.TestPaintComponentRun7DrawingGeometricFiguresFDrawingStringsFDrawingLinesFDrawingRectanglesFDrawingOvalsFDrawingArcsFDrawingPolygons8DrawingStringsdrawLine(intx1,inty1,intx2,inty2);drawString(Strin
5、gs,intx,inty);9DrawingRectanglesdrawRect(intx,inty,intw,inth);fillRect(intx,inty,intw,inth);10DrawingRoundedRectanglesdrawRoundRect(intx,inty,intw,inth,intaw,intah);fillRoundRect(intx,inty,intw,inth,intaw,intah);11DrawingOvalsdrawOval(intx,inty,intw,inth);fillOval(intx,inty,intw,inth);12CaseStudy:Th
6、eFigurePanelClassThisexampledevelopsausefulclassfordisplayingvariousfigures.Theclassenablestheusertosetthefiguretypeandspecifywhetherthefigureisfilled,anddisplaysthefigureonapanel.FigurePanel13TestFigurePanelThisexampledevelopsausefulclassfordisplayingvariousfigures.Theclassenablestheusertosetthefig
7、uretypeandspecifywhetherthefigureisfilled,anddisplaysthefigureonapanel.TestFigurePanelRun14DrawingArcsdrawArc(intx,inty,intw,inth,intangle1,intangle2);fillArc(intx,inty,intw,inth,intangle1,intangle2);Anglesareindegree15DrawingArcsExampleDrawArcsRun16DrawingPolygonsandPolylinesintx=40,70,60,45,20;int
8、y=20,40,80,45,60;g.drawPolygon(x,y,x.length);g.drawPolyline(x,y,x.length);17DrawingPolygonsUsingthePolygonClassPolygonpolygon=newPolygon();polygon.addPoint(40,59);polygon.addPoint(40,100);polygon.addPoint(10,100);g.drawPolygon(polygon);18DrawingPolygonsExampleDrawPolygonRun19CenteringDisplayUsingthe
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java语言程序设计 基础篇 原书第八版 课件 PPT第十五章 java 语言程序设计 基础 第八 PPT 第十五
限制150内