爱问知识人 爱问教育 医院库

java 实现 简单画图功能(简单点的)

首页

java 实现 简单画图功能(简单点的)


        

提交回答

全部答案

    2008-12-01 19:55:00
  • 呵呵 兄弟 要代码 太直接了吧 最好自己先好好研究下子实在解决不了 具体问题具体对待嘛

    l***

    2008-12-01 19:55:00

  • 2008-12-01 15:29:00
  •   import javax。swing。*;import  t。*;import  t。event。*;public class HuaTu extends JPanel implements MouseListener, MouseMotionListener, ActionListener{ private JFrame f; private int xBegin=0,yBegin=0,xEnd=0,yEnd=0;//开始和结束点坐标 private JButton butLine,butRect,butOval,butPen,butEraser;//线,方,圆,笔,橡皮 private JToolBar tb; public HuaTu() {  f   = new JFrame("画图板");  butLine  = new JButton("\");  butRect  = new JButton("□");  butOval  = new JButton("○");  butPen  = new JButton("Pen");  butEraser = new JButton("Eraser");  tb   = new JToolBar();   d(butLine);   d(butRect);   d(butOval);   d(butPen);   d(butEraser);   dActionListener(this);   dActionListener(this);   dActionListener(this);   dActionListener(this);   dActionListener(this);   tLayout(new BorderLayout());   d(tb,BorderLayout。
      NORTH); dMouseListener(this); dMouseMotionListener(this); d(this); tBounds(100,100,600,500); tVisible(true); } public void paintComponent(Graphics g) { //手工强制清空面板 intComponent(g); g。
      drawLine(xBegin,yBegin,xEnd,yEnd); } public static void main(String args[]) { new HuaTu(); } public void mouseClicked(MouseEvent e) { } public void mousePressed(MouseEvent e) {//按下鼠标的时候,记录开始点的坐标 this。
      xBegin = tX(); this。yBegin = tY(); } public void mouseReleased(MouseEvent e) { } public void mouseDragged(MouseEvent e) {//记录拖动的时候的结束点 this。
      xEnd = tX(); this。yEnd = e。
      getY(); //每次拖动,都需要重绘面板,显示最的图形 paint(); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseMoved(MouseEvent e) { } /** * Method actionPerformed * * * @param e * */ public void actionPerformed(ActionEvent e) { // TODO: Add your code here }}。

    l***

    2008-12-01 15:29:00

  • 互联网 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):