ImageVerifierCode 换一换
格式:DOCX , 页数:18 ,大小:18.09KB ,
资源ID:26146751      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/26146751.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java作业java作业.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java作业java作业.docx

1、java作业java作业java作业(java作业)软件工程 r1141 宋洋 16 java 作业public class qingdrawpad extends jframe private objectinputstream input;private objectoutputstream output;private jbutton choices ; private string names= newopen.save.pencil by,line,rect ,frect ,oval,foval ,circle,fcircle ,roundrect ,frrect ,rubber.c

2、olor.stroke.the word;private string = stylenames宋体, 隶书, 华文彩云, 仿宋 _ gb2312, 华文行楷 ,方正舒体, times new roman, serif, monospaced ,sonsserif, garamond.;private icon items ;jtoolbar buttonpanel;private jlabel statusbar;private drawpanel drawingarea;private int width = 850, height = 550;drawings itemlist = ne

3、w drawings 5;private int currentchoice = 3;int index = 0;private color color = color.black;int r, g, b;int f1, f2;the string style1;private float stroke = 1.0f;jcheckbox bold, italic;jcombobox styles;public qingdrawpad ()super (卿乐绘图画板 (中国风);jmenubar bar = new jmenubar ();jmenu filemenu = new jmenu (

4、文件);/ / filemenu.setmnemonic (f);jmenuitem newitem = new jmenuitem (新建);newitem.addactionlistener (new actionlistener () public void actionperformed (actionevent (e)newfile (););filemenu.add (newitem);jmenuitem saveitem = new jmenuitem (保存);saveitem.addactionlistener (new actionlistener () public vo

5、id actionperformed (actionevent (e)savefile (); /);filemenu.add (saveitem);jmenuitem loaditem = new jmenuitem (打开);loaditem.addactionlistener (new actionlistener () public void actionperformed (actionevent (e)loadfile (););filemenu.add (loaditem);filemenu.addseparator ();jmenuitem exititem = new jme

6、nuitem (退出);exititem.addactionlistener (new actionlistener () public void actionperformed (actionevent (e)system.exit (0););filemenu.add (exititem);bar.add (filemenu);jmenu colormenu = new jmenu (颜色);jmenuitem coloritem = new jmenuitem (选择颜色);coloritem.addactionlistener (new actionlistener () public

7、 void actionperformed (actionevent (e)choosecolor (););colormenu.add (coloritem);bar.add (colormenu);jmenu strokemenu = new jmenu (线条粗细);jmenuitem strokeitem = new jmenuitem (设置线条粗细);strokeitem.addactionlistener (new actionlistener () public void actionperformed (actionevent (e)setstroke (););stroke

8、menu.add (strokeitem);bar.add (strokemenu);jmenu helpmenu = new jmenu (帮助);jmenuitem aboutitem = new jmenuitem (关于画板);aboutitem.addactionlistener (new actionlistener () public void actionperformed (actionevent (e)joptionpane.showmessagedialog (null,画图板说明joptionpane.information _ message););helpmenu.

9、add (aboutitem);bar.add (helpmenu);items = new imageicon names.length;drawingarea = new drawpanel ();choices = new jbutton names.length;buttonpanel = new jtoolbar (jtoolbar.vertical);buttonpanel = new jtoolbar (jtoolbar.horizontal);buttonhandler is = new buttonhandler ();buttonhandler1 handler1 = ne

10、w buttonhandler1 ();for (int i = 0; i choices.length; i + +)items in = new imageicon (names in + .gif);choices in = new jbutton (, items in);choices in.settooltiptext (tiptext in);buttonpanel.add (choices in);for (int i = 3; in choices.length-3; i + +)choices in.addactionlistener (is);choices 0.adda

11、ctionlistener (new actionlistener () public void actionperformed (actionevent (e)newfile(););选择 1 。addactionlistener(新的actionlistener() public void actionPerformed(ActionEvent e)loadfile(););选择 2 。addactionlistener(新的actionlistener() public void actionPerformed(ActionEvent e)savefile(););选择选择,长度为3 a

12、ddactionlistener(handler1);选择选择,长度为2 addactionlistener(handler1);选择选择。length-1 addactionlistener(handler1);风格=新的JComboBox(stylenames);(8)setmaximumrowcount风格;additemlistener(风格。新的itemlistener() 公共无效itemstatechanged(itemevent E)style1 = stylenames getselectedindex() 风格;);大胆=新的复选框(“粗体”);斜体=新的复选框(“斜体”)

13、;checkboxhandler钱德勒=新checkboxhandler();大胆additemlistener(Chandler);斜体。additemlistener(钱德勒);JPanel wordpanel =新jpanel();buttonpanel添加(粗体);buttonpanel添加(斜体);buttonpanel添加(风格);风格。setminimumsize(新的维度(50, 20);风格。setmaximumsize(新的维度(100, 20);容器C = getcontentpane();超级setjmenubar(杆);(buttonpanel,总和4. Border

14、Layout。北);(drawingarea,总和4. BorderLayout。中心);状态=新jlabel();总和4.(StatusBar BorderLayout。南);状态栏设置(“欢迎使用卿乐绘图画板O(_)O”);createnewitem();setsize(宽度,高度);show();公共课buttonhandler实现ActionListenerpublic void actionPerformed(ActionEvent e)为(j = 3;J 选择。长度为3;j+)如果(如getsource() = =选择 J ) currentchoice = J;createnew

15、item();repaint();公共课buttonhandler1实现ActionListenerpublic void actionPerformed(ActionEvent e)如果(如getsource() = =选择选择,长度为3) choosecolor();如果(如getsource() = =选择选择,长度为2) setstroke();如果(如getsource() = =选择选择。length-1) JOptionPane。ShowMessageDialog (null),Please click the drawing board to select the locati

16、on of the input text,Hint, JOptionPane.INFORMATION_MESSAGE);CurrentChoice=14;CreateNewItem ();Repaint ();If (e.getSource () =bold)If (e.getStateChange () =ItemEvent.SELECTED)F1=Font.BOLD;ElseF1=Font.PLAIN;If (e.getSource () =italic)If (e.getStateChange () =ItemEvent.SELECTED)F2=Font.ITALIC;ElseF2=Fo

17、nt.PLAIN;Class DrawPanel extends JPanelPublic DrawPanel ()SetCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR);SetBackground (Color.white);AddMouseListener (New mouseA ();AddMouseMotionListener (New mouseB ();Public void paintComponent (Graphics g)Super.paintComponent (g);Graphics2D g2d=

18、(Graphics2D) g;Int j=0;While (j 0)”);行程=浮parseFloat(输入);索引自行设计行程=行程;公共无效savefile()档案选择程式=新jfilechooser() JFileChooser;然后在fileChooser. setfileselectionmode(文件对话框。files_only);int结果=然后在fileChooser. showsavedialog(本);如果(结果= =文件对话框。cancel_option)返回;文件的文件名,然后在fileChooser. getselectedfile();canwrite()文件名;如

19、果(文件名= = null | |文件名。getname()。等于(“”)JOptionPane。showmessagedialog(档案选择程式,“文件名无效”,“文件名无效”,JOptionPane error_message);别的尝试delete()文件名;FileOutputStream FOS =新的输出(文件名);输出为新的对象(FOS);图纸的记录;输出writeint(指数);对于(int = i 0;i 索引;i + +)图P = itemlist 我;输出的writeObject(P);输出。flush();()输出;FOS。();赶上(IOException IOE)p

20、rintstacktrace() IOE;公共无效loadfile()档案选择程式=新jfilechooser() JFileChooser;然后在fileChooser. setfileselectionmode(文件对话框。files_only);int结果=然后在fileChooser. showMessageDialog(本);如果(结果= =文件对话框。cancel_option)返回;文件的文件名,然后在fileChooser. getselectedfile();canread()文件名;如果(文件名= = null | |文件名。getname()。等于(“”)JOptionP

21、ane。showmessagedialog(档案选择程式,“文件名无效”,“文件名无效”,JOptionPane error_message);别的尝试FileInputStream FIS =新的输入(文件名);输入=新对象输入流(FIS);图inputrecord;国际countnumber = 0;countnumber =输入。readint();为(指数= 0;指数小于countnumber;指数+ +)inputrecord =(图)readobject()输入;索引 = inputrecord自行设计;createnewitem();()输入;repaint();赶上(个endo

22、ffileexception)JOptionPane。ShowMessageDialog (this, theres no more records in the file,JOptionPane.ERROR_MESSAGE;Catch (ClassNotFoundException classNotFoundException) JOptionPane.showMessageDialog (this, cannot create objects),JOptionPane.ERROR_MESSAGE;Catch (IOException ioException) JOptionPane.sho

23、wMessageDialog (this) error reading data from file,JOptionPane.ERROR_MESSAGE;Public void newFile ()Index=0;CurrentChoice=3;Color=Color.black;Stroke=1.0f;CreateNewItem ();Repaint ();Public static void main (String args)tryUIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ();Catch (Exception E) QingDrawPad newPad=new QingDrawPad ();NewPad.addWindowListenerNew WindowAdapter () Public void windowClosing (WindowEvent E)System.exit (0););

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1