基于Java的画图板具体要解决什么
的有关信息介绍如下:另一个我回答了,加了运行截图没有显示。看看下面代码,新建类T拷进去,看看是不是你要的。packagetest;importjava.awt.*;importjava.awt.event.*;importjava.util.*;importjavax.swing.*;importjava.awt.geom.*;importjava.io.*;@SuppressWarnings({"serial","unused"})classPointimplementsSerializable{intx,y;Colorcol;inttool;intboarder;Point(intx,inty,Colorcol,inttool,intboarder){this.x=x;this.y=y;this.col=col;this.tool=tool;this.boarder=boarder;}}@SuppressWarnings({"serial","unused"})classpaintboardextendsFrameimplementsActionListener,MouseMotionListener,MouseListener,ItemListener{intx=-1,y=-1;intcon=1;//画笔大小intEcon=5;//橡皮大小inttoolFlag=0;//toolFlag:工具标记//toolFlag工具对应表://(0--画笔);(1--橡皮);(2--清除);//(3--直线);(4--圆);(5--矩形);Colorc=newColor(0,0,0);//画笔颜色BasicStrokesize=newBasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);//画笔粗细Pointcutflag=newPoint(-1,-1,c,6,con);//截断标志@SuppressWarnings("unchecked")VectorpaintInfo=null;//点信息向量组intn=1;FileInputStreampicIn=null;FileOutputStreampicOut=null;ObjectInputStreamVIn=null;ObjectOutputStreamVOut=null;//*工具面板--画笔,直线,圆,矩形,多边形,橡皮,清除*/PaneltoolPanel;Buttoneraser,drLine,drCircle,drRect;Buttonclear,pen;ChoiceColChoice,SizeChoice,EraserChoice;Buttoncolchooser;Label颜色,大小B,大小E;//保存功能//ButtonopenPic,savePic;FileDialogopenPicture,savePicture;@SuppressWarnings("unchecked")paintboard(Strings){super(s);addMouseMotionListener(this);addMouseListener(this);paintInfo=newVector();/*各工具按钮及选择项*///颜色选择ColChoice=newChoice();ColChoice.add("black");ColChoice.add("red");ColChoice.add("blue");ColChoice.add("green");ColChoice.addItemListener(this);//画笔大小选择SizeChoice=newChoice();SizeChoice.add("1");SizeChoice.add("3");SizeChoice.add("5");SizeChoice.add("7");SizeChoice.add("9");SizeChoice.addItemListener(this);//橡皮大小选择EraserChoice=newChoice();EraserChoice.add("5");EraserChoice.add("9");EraserChoice.add("13");EraserChoice.add("17");EraserChoice.addItemListener(this);////////////////////////////////////////////////////toolPanel=newPanel();clear=newButton("清除");eraser=newButton("橡皮");pen=newButton("画笔");drLine=newButton("画直线");drCircle=newButton("画圆形");drRect=newButton("画矩形");colchooser=newButton("显示调色板");clear.setBackground(Color.GREEN);drRect.setBackground(Color.GREEN);pen.setBackground(Color.GREEN);eraser.setBackground(Color.GREEN);drLine.setBackground(Color.GREEN);drCircle.setBackground(Color.GREEN);colchooser.setBackground(Color.GREEN);//各组件事件监听clear.addActionListener(this);eraser.addActionListener(this);pen.addActionListener(this);drLine.addActionListener(this);drCircle.addActionListener(this);drRect.addActionListener(this);colchooser.addActionListener(this);颜色=newLabel("画笔颜色",Label.CENTER);大小B=newLabel("画笔大小",Label.CENTER);大小E=newLabel("橡皮大小",Label.CENTER);颜色.setBackground(Color.gray);大小B.setBackground(Color.gray);大小E.setBackground(Color.gray);//面板添加组件toolPanel.add(pen);toolPanel.add(drLine);toolPanel.add(drCircle);toolPanel.add(drRect);toolPanel.add(颜色);toolPanel.add(ColChoice);toolPanel.add(大小B);toolPanel.add(SizeChoice);toolPanel.add(colchooser);toolPanel.add(eraser);toolPanel.add(大小E);toolPanel.add(EraserChoice);toolPanel.add(clear);//工具面板到APPLET面板add(toolPanel,BorderLayout.NORTH);setBounds(60,60,900,600);setVisible(true);validate();//dialogforsaveandloadopenPicture=newFileDialog(this,"打开图画",FileDialog.LOAD);openPicture.setVisible(false);savePicture=newFileDialog(this,"保存图画",FileDialog.SAVE);savePicture.setVisible(false);openPicture.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){openPicture.setVisible(false);}});savePicture.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){savePicture.setVisible(false);}});addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});}publicvoidpaint(Graphicsg){Graphics2Dg2d=(Graphics2D)g;Pointp1,p2;n=paintInfo.size();if(toolFlag==2)g.clearRect(0,0,getSize().width,getSize().height);//清除for(inti=1;i