java语言程序设计基础篇课后答案-机械工业出版社

java语言程序设计基础篇课后答案-机械工业出版社

ID:12806768

大小:541.50 KB

页数:77页

时间:2018-07-19

java语言程序设计基础篇课后答案-机械工业出版社_第1页
java语言程序设计基础篇课后答案-机械工业出版社_第2页
java语言程序设计基础篇课后答案-机械工业出版社_第3页
java语言程序设计基础篇课后答案-机械工业出版社_第4页
java语言程序设计基础篇课后答案-机械工业出版社_第5页
资源描述:

《java语言程序设计基础篇课后答案-机械工业出版社》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Java语言程序设计1/81&[编程练习题答案]Java语言程序设计(基础篇)(进阶篇)第13、14、15、24、25、26、28、29、30、31章部分习题答案,奇数题和部分双数题是我自己做的,在此和大家分享(^_^~Chapter13Exercise13.2/13.8/13.11importjavax.swing.*;importjava.awt.*;publicclassExercise13_2extendsJFrame{//CreatetwobuttonsprivateOvalButtonjbtOk=newOvalButton("OK");priva

2、teOvalButtonjbtCancel=newOvalButton("Cancel");/**Defaultconstructor*/publicExercise13_2(){//SetthewindowtitlesetTitle("Exercise13_2");//SetFlowLayoutmanagertoarrangethecomponentsJava语言程序设计2/81//insidetheframegetContentPane().setLayout(newFlowLayout());//AddbuttonstotheframegetConte

3、ntPane().add(jbtOk);getContentPane().add(jbtCancel);}/**Mainmethod*/publicstaticvoidmain(String[]args){Exercise13_2frame=newExercise13_2();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setVisible(true);}}classOvalButtonextendsJButton{publicOvalButton(){}pu

4、blicOvalButton(Stringtext){super(text);}protectedvoidpaintComponent(Graphicsg){//Drawanovalsuper.paintComponent(g);g.drawOval(5,5,getWidth()-10,getHeight()-10);}/**OverridegetmethodforpreferredSize*/publicDimensiongetPreferredSize(){returnnewDimension(100,50);}/**Overridegetmethodf

5、orminimumSize*/publicDimensiongetMinimumSize(){returnnewDimension(100,50);}}Java语言程序设计3/81importjava.awt.*;importjavax.swing.*;publicclassExercise13_8extendsJFrame{publicstaticvoidmain(String[]args){JFrameframe=newExercise13_8();frame.setSize(300,300);frame.setTitle("Exercise13_8")

6、;frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);}publicExercise13_8(){getContentPane().add(newOctagonPanel());}}classOctagonPanelextendsJPanel{protectedvoidpaintComponent(Graphicsg){super.paintComponent(g);intxCenter=getWidth()/2;intyCenter=getHeight()/

7、2;intradius=(int)(Math.min(getWidth(),getHeight())*0.4);//CreateaPolygonobjectPolygonpolygon=newPolygon();//Addpointstothepolygonpolygon.addPoint(xCenter+radius,yCenter);polygon.addPoint((int)(xCenter+radius*Math.cos(2*Math.PI/8)),(int)(yCenter-radius*Math.sin(2*Math.PI/8)));polygo

8、n.addPoint((int)(xCenter+r

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。