欢迎来到天天文库
浏览记录
ID:31344548
大小:181.50 KB
页数:9页
时间:2019-01-08
《java实现简单地绘图软件》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用标准文案项目效果图:项目源代码:importjava.awt.*;importjava.awt.event.*;importjava.awt.geom.Ellipse2D;importjava.awt.geom.Line2D;importjava.awt.geom.Rectangle2D;importjava.awt.image.BufferedImage;importjava.io.File;importjava.io.IOException;importjavax.imageio.ImageIO;impo
2、rtjavax.swing.*;importjavax.swing.filechooser.FileNameExtensionFilter;/*author:蒋冰*/publicclassImageDraw{privateinttypeFlag=1;privateintendFlag=1;privateintstrokeTemp=1;privateColorcolor=Color.black;精彩文档实用标准文案privateBasicStrokestroke=newBasicStroke();privatefl
3、oatpre_x=0;privatefloatpre_y=0;privatefloatstart_x=0;privatefloatstart_y=0;privatefloatstart_X=0;privatefloatstart_Y=0;privatefloatend_x=0;privatefloatend_y=0;privatefloatwidth=0;privatefloatheight=0;privatefinalintAREA_WIDTH=700;privatefinalintAREA_HEIGHT=40
4、0;privateLine2D.Floatline;privateRectangle2D.Floatrect;privateEllipse2D.Floatellipse;privateFileimageFile;BufferedImageimage=newBufferedImage(AREA_WIDTH,AREA_HEIGHT,BufferedImage.TYPE_INT_RGB);Graphics2Dg2=(Graphics2D)image.getGraphics();privateJFrameframe=ne
5、wJFrame("简单手绘程序");privateDrawPaneldrawArea=newDrawPanel();JButtonbuttonShowColor=newJButton("");publicvoidinit(){g2.fillRect(0,0,AREA_WIDTH,AREA_HEIGHT);g2.setColor(Color.black);drawArea.setPreferredSize(newDimension(AREA_WIDTH,AREA_HEIGHT));drawArea.addMouse
6、MotionListener(newMouseMotionAdapter(){publicvoidmouseDragged(MouseEvente){do_mouseDragged(e);}});drawArea.addMouseListener(newMouseAdapter(){publicvoidmousePressed(MouseEvente1){do_mousePressed(e1);精彩文档实用标准文案}publicvoidmouseReleased(MouseEvente){g2.setColor(
7、color);g2.setStroke(stroke);endFlag=typeFlag;drawArea.repaint();}publicvoidmouseEntered(MouseEvente){frame.setCursor(newCursor(Cursor.CROSSHAIR_CURSOR));}publicvoidmouseExited(MouseEvente){frame.setCursor(null);}});frame.add(drawArea);JMenuBarmb=newJMenuBar()
8、;JMenumenuFile=newJMenu("文件");JMenuItemmenuItemSave=newJMenuItem("保存");menuItemSave.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventarg0){do_save_actionPerforme
此文档下载收益归作者所有