java画图板java写的画图板保存图片是怎么实现的

java画图板  时间:2021-01-16  阅读:()

跪求------java画图板设计(菜单方式) 急,急,急

看看你要的是不是这个

我只是用了一个菜单而已,只有清屏功能

import javax.swing.*; import java.awt.*; import java.awt.event.*;

public class PlantPanel extends JFrame{ private JMenuBar jmb; private JMenu jmu1; private JPopupMenu jpm1; private JMenuItem item1; private Plant jpl; public PlantPanel(){ super("画图"); item1 = new JMenuItem("清屏"); jmu1 =new JMenu("功能"); jmb = new JMenuBar(); jmu1.add(item1); jmb.add(jmu1); jpl=new Plant(); item1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ clear(); } }); add(jmb,BorderLayout.NORTH); add(jpl,BorderLayout.CENTER); setLocation(400,300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400,300); setVisible(true); } public void clear(){ this.remove(jpl); jpl =new Plant(); this.add(jpl,BorderLayout.CENTER); validate(); } public class Plant extends JPanel implements MouseMotionListener{ public Plant(){ addMouseMotionListener(this); } public void mouseDragged(MouseEvent e){ Point p=new Point(); Graphics g1= getGraphics(); paint(g1,p,e); } public void mouseMoved(MouseEvent e){ } public void paint(Graphics g,Point p,MouseEvent e){ p=e.getPoint();

g.setColor(Color.black);

g.fillOval(p.x,p.y,7,7);

}

}

public static void main(String arg[]){ new PlantPanel(); } }

简单的JAVA画板程序

import java.awt.*; class Draw{ public static void main(String[] args){ Frame f=new Frame(); f.setSize(300,300); f.add(new Canvas(){ public void paint(Graphics g){ g.setColor(Color.red); g.fillOval(0,0,80,80); } }); f.show(); } }

简单到我用匿名类了呵呵

求好心人帮找或做个JAVA画板程序 代码,主要能实现简单的画板功能!

取个叫pb.java的文件拷贝进去(pb类为main入口),直接运行 —————————————— 楼主, 不好意思我是学j2ee的,GUI不会,你看我以前的回答一个awt和swing都没有的,这是我们项目组一个牛人的代码,我在我的新系统中嵌入的,我实在无能为力,你觉的好就用不好我也没办法的, 楼主你可以等等看,应该还有牛人有解决方法 ———————————————— import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import java.awt.geom.*; import java.io.*; class Point implements Serializable { int x,y; Color col; int tool; int boarder; Point(int x, int y, Color col, int tool, int boarder) { this.x = x; this.y = y; this.col = col; this.tool = tool; this.boarder = boarder; } } class paintboard extends Frame implements ActionListener,MouseMotionListener,MouseListener,ItemListener { int x = -1, y = -1; int con = 1;//画笔大小 int Econ = 5;//橡皮大小 int toolFlag = 0;//toolFlag:工具标记 //toolFlag工具对应表: //(0--画笔);(1--橡皮);(2--清除); //(3--直线);(4--圆);(5--矩形); Color c = new Color(0,0,0); //画笔颜色 BasicStroke size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);//画笔粗细 Point cutflag = new Point(-1, -1, c, 6, con);//截断标志 Vector paintInfo = null;//点信息向量组 int n = 1; FileInputStream picIn = null; FileOutputStream picOut = null; ObjectInputStream VIn = null; ObjectOutputStream VOut = null; // *工具面板--画笔,直线,圆,矩形,多边形,橡皮,清除*/ Panel toolPanel; Button eraser, drLine,drCircle,drRect; Button clear ,pen; Choice ColChoice,SizeChoice,EraserChoice; Button colchooser; Label 颜色,大小B,大小E; //保存功能 Button openPic,savePic; FileDialog openPicture,savePicture; paintboard(String s) { super(s); addMouseMotionListener(this); addMouseListener(this); paintInfo = new Vector(); /*各工具按钮及选择项*/ //颜色选择 ColChoice = new Choice(); ColChoice.add("black"); ColChoice.add("red"); ColChoice.add("blue"); ColChoice.add("green"); ColChoice.addItemListener(this); //画笔大小选择

求一个用JAVA写的最简单的画图工具;能画直线就行,其他不需要。

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import java.awt.geom.Line2D; import java.util.Vector; import javax.swing.JFrame; import javax.swing.JPanel; class LinePanel extends JPanel{ private static final long serialVersionUID = 1L; private Vector lines = new Vector ();//存储画板上所有的直线 private Line2D line = new Line2D.Double() ; private Line2D cur = new Line2D.Double() ;//起点到当前光标的直线 public LinePanel(){ super(); this.setBackground(new Color(255,255,255)); } public void setLines(Vector lines){ this.lines = lines; } public void setCur(Line2D cur){ this.cur =cur; } @Override public void paint(Graphics g){ super.paint(g); Graphics2D g2d = (Graphics2D) g; for(Line2D l2d:lines){ line = l2d; g2d.draw(line); } if(cur!=null){ g2d.draw(cur); } } } public class DrawLine extends JFrame{ private static final long serialVersionUID = 1L; private LinePanel panel; private Vector lines; private Point start; public DrawLine(){ panel= new LinePanel(); lines = new Vector(); this.setBounds(100, 200, 400, 400); this.setLayout(new BorderLayout()); this.add(panel,BorderLayout.CENTER); this.setPanelListener(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } private void setPanelListener() { panel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { start = new Point(e.getX(),e.getY()); } @Override public void mouseReleased(MouseEvent e) { Line2D line = new Line2D.Double(start.x,start.y,e.getX(),e.getY()); lines.add(line); panel.setLines(lines); line = null; } }); panel.addMouseMotionListener(new MouseMotionAdapter(){ @Override public void mouseDragged(MouseEvent e) { panel.setCur(new Line2D.Double(start.x,start.y,e.getX(),e.getY())); panel.repaint(); } }); } public static void main(String[] args) { new DrawLine(); } }

急求一个java绘图小程序

写一个panel,里面重载一个ponent()方法,在里面用 public void paint(Graphics g){ Graphics2D g2 = (Graphics2D)g g2.draw... 具体什么的就查api吧...主要是写着麻烦。





java写的画图板保存图片是怎么实现的

首先是得到图片的保存路径, 然后截取图片的路径。



然后再用文件的输入输出流。



把文件读入数级组中。



再它其写到指定的文件夹中。



这样就实现了文件的保存…… 祝你早日成功!

ParkInHost - 俄罗斯VPS主机 抗投诉 55折,月付2.75欧元起

ParkInHost主机商是首次介绍到的主机商,这个商家是2013年的印度主机商,隶属于印度DiggDigital公司,主营业务有俄罗斯、荷兰、德国等机房的抗投诉虚拟主机、VPS主机和独立服务器。也看到商家的数据中心还有中国香港和美国、法国等,不过香港机房肯定不是直连的。根据曾经对于抗投诉外贸主机的了解,虽然ParkInHost以无视DMCA的抗投诉VPS和抗投诉服务器,但是,我们还是要做好数据备...

ShineServers(5美元/月)荷兰VPS、阿联酋VPS首月五折/1核1G/50GB硬盘/3TB流量/1Gbps带宽

优惠码50SSDOFF 首月5折50WHTSSD 年付5折15OFF 85折优惠,可循环使用荷兰VPSCPU内存SSD带宽IPv4价格购买1核1G50G1Gbps/3TB1个$ 9.10/月链接2核2G80G1Gbps/5TB1个$ 12.70/月链接2核3G100G1Gbps/7TB1个$ 16.30/月链接3核4G150G1Gbps/10TB1个$ 18.10/月链接阿联酋VPSCPU内存SS...

ParkinHost:俄罗斯离岸主机,抗投诉VPS,200Mbps带宽/莫斯科CN2线路/不限流量/无视DMCA/55折促销26.4欧元 /年起

外贸主机哪家好?抗投诉VPS哪家好?无视DMCA。ParkinHost今年还没有搞过促销,这次parkinhost俄罗斯机房上新服务器,母机采用2个E5-2680v3处理器、128G内存、RAID10硬盘、2Gbps上行线路。具体到VPS全部200Mbps带宽,除了最便宜的套餐限制流量之外,其他的全部是无限流量VPS。ParkinHost,成立于 2013 年,印度主机商,隶属于 DiggDigi...

java画图板为你推荐
百度k站百度k站的原因是什么yy频道中心YY频道管理中心怎么登录?博客外链请问怎么利用博客做外链呢湖南商标注册在湖南搞商标注册是代理好还是自己去好一点?湖南商标注册的流程又是什么样的呢?二叉树遍历写出二叉树的先序遍历、中序遍历、后序遍历。显卡温度多少正常显卡温度多少算正常?ps抠图技巧请教PS抠图技巧!!!ps抠图技巧photoshop抠图技巧安卓应用平台安卓系统支持的软件并不是那么多,为什么这么多人推崇?如何建立一个网站要建立一个网站怎么弄啊?
域名购买 域名服务器上存放着internet主机的 注册cn域名 淘宝抢红包攻略 cpanel主机 香港托管 vmsnap3 流媒体服务器 谷歌香港 监控宝 服务器cpu性能排行 绍兴高防 域名转接 免费全能主机 php空间购买 常州联通宽带 360云服务 net空间 阿里云邮箱登陆地址 服务器硬件配置 更多