1楼:匿名用户
类似的,自己改改就好了:
package ziliao;
//鼠标画图1
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//鼠标事件处理
//事件接口: mouselistener, mousemotionlistener
//使用鼠标画图
//使用jpanel面板绘图
class co13 extends jframe
public int getjrb() //判断判断并返回选择的是哪个单选按钮
}class mypanel extends jpanel implements mouselistener, mousemotionlistener
//覆盖 paint***ponent 方法
public void paint***ponent(graphics g)
g.setcolor(color.blue);
g.drawstring(s, 10, 10);
}public void mousepressed(mouseevent e)
public void mousereleased(mouseevent e)
public void mouseentered(mouseevent e)
public void mouseexited(mouseevent e)
public void mouseclicked(mouseevent e)
public void mousedragged(mouseevent e)
public void mousemoved(mouseevent e)
}public class e6_13 }
java设计一个可以根据鼠标的拖曳画直线,矩形,圆的画图程序
2楼:匿名用户
你是画在jpanel上吗?如果是画完你要调用一下paint***ponent()来刷新面板才会显示你画的东西。
java 求助 就是如何用鼠标监听事件调用graphics 画的线条和矩形 接着画 ? 不会画完 20
3楼:匿名用户
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class test
}class myframe extends jframe implements actionlistener
public void actionperformed(actionevent e)
public static final int w = 400;
public static final int h = 400;
}class mypanel extends jpanel implements mouselistener
public void mousepressed(mouseevent e)
public void mousereleased(mouseevent e)
public void mouseclicked(mouseevent e)
public void mousemoved(mouseevent e)
public void mouseentered(mouseevent e)
public void mouseexited(mouseevent e)
public void paint***ponent(graphics g) }}}
用java实现画线,不是直线,而是点住鼠标左键划到****就画线,就
4楼:匿名用户
importjava.awt.basicstroke;
importjava.awt.borderlayout;
importjava.awt.color;
importjava.awt.flowlayout;
importjava.awt.frame;
importjava.awt.graphics;
importjava.awt.graphics2d;
importjava.awt.label;
importjava.awt.panel;
importjava.awt.event.mouseadapter;
importjava.awt.event.mouseevent;
importjava.awt.event.mousemotionlistener;
importjava.awt.event.windowadapter;
importjava.awt.event.windowevent;
publicclassmousedrawpanelextendsframe
});}
@override
publicvoidpaint***ponents(graphicsg)
publicstaticvoidmain(stringargs)
}@override
publicvoidmousedragged(mouseevente)
}});
mdp.addmouselistener(newmouseadapter()
else
}@override
publicvoidmousereleased(mouseevente)
}});
mdp.setvisible(true);}}
5楼:莪湜仩偙
github 搜 java paint
如何在画布实现用鼠标拖动画直线,只要直线就行了,尽量简单
6楼:匿名用户
给你程序,已经尽量简化了。不懂再问吧。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class drawline extends jpanel implements mouselistener
@override
public void mousepressed(mouseevent e)
@override
public void mousereleased(mouseevent e)
@override
public void mouseentered(mouseevent e){}
@override
public void mouseexited(mouseevent e){}
@override
public void mouseclicked(mouseevent e){}
@override
public void paint***ponent(graphics g)
public static void main(string args)
private class paintthread extends thread
catch(interruptedexception ex){}}}}}
java的画图问题,怎么实现和windos只带的那个画图工具一样的功能,比如选择直线按钮,就可以在
7楼:雪飞潇潇
swing 配合鼠标事件 可以完成啊
思路手选点击直线按钮后,准备画直线,
点击画布得到直线的第一个点p1。然后鼠标移动,此时可以一直绘制p1到鼠标的直线。
当鼠标再次点击画布,得到第二个点p2,那么就可以绘制画好的直线了建议,熟练掌握各种事件和swing绘制图形的参数就可以了
实现java程序,要求单击鼠标画线,双击鼠标擦除所有画的线。
8楼:匿名用户
packagezhidao;
importjava.awt.borderlayout;
importjava.awt.color;
importjava.awt.flowlayout;
importjava.awt.frame;
importjava.awt.graphics;
importjava.awt.label;
importjava.awt.panel;
importjava.awt.event.mouseadapter;
importjava.awt.event.mouseevent;
importjava.awt.event.mousemotionlistener;
importjava.awt.event.windowadapter;
importjava.awt.event.windowevent;
publicclassmousedrawpanelextendsframe
});}
@override
publicvoidpaint***ponents(graphicsg)
publicstaticvoidmain(stringargs)
@override
publicvoidmousedragged(mouseevente)
});mdp.addmouselistener(newmouseadapter()
@override
publicvoidmousereleased(mouseevente)
});mdp.setvisible(true);}}
用java编写如下图形程序,响应鼠标事件,能在该框架上实现画直线和矩形的功能:
9楼:匿名用户
我倒是有一个类似画图的,不过财富太少了
10楼:匿名用户
这个 你可以先画好,,,然后发生鼠标事件的时候显示图形,