导航:首页 > 编程语言 > java实现连续点击事件

java实现连续点击事件

发布时间:2022-11-27 17:10:23

A. 怎么样用java实现鼠标的多次点击事件

int
getClickCount()
Returns the number of mouse clicks associated with this event.

B. JAVA 怎么实现多次点击一个按钮触发不同的事件

可以设置计数器,每点击一次计数然后根据点击的次数判断所要执行的操作

C. java的div的click多个事件怎么写,想要的效果是点击div,从左边跳到右边,来回五次。求大神指导!

<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">

<title>RunJS演示代码</title>
<style>
body{
overflow-x:hidden;
}
#content{
text-align:center;
line-height:100px;
background-color:red;
width:100px;
height:100px;
position:absolute;
left:0;
}
</style>
<script>
varinter=null,count=0,dir=1,gap=30;
vargo=function(){
inter=setInterval(function(){
varle=parseFloat(content.style.left)||content.offsetLeft;
varb=document.documentElement.clientWidth||document.body.clientWidth;
varmax_width=b-content.offsetWidth;
le+=gap*dir;
if(le>=max_width){
dir=-1;
count++;
le=max_width;
}
elseif(le<=0){
dir=1;
count++;
le=0;
}
content.style.left=le+"px";
if(count==5){
clearInterval(inter);
}
},30);
}
</script>
</head>
<body>
<inputtype="button"value="GO"onclick="go()"/>
<divid='content'>
content
</div>
</body>
</html>

D. JAVA 怎么实现多次点击一个按钮触发不同的事件

直接构建一个actionevent,然后调用另一个按钮的fireevent方法

E. 用Java编写实现程序,在窗口North上布置三个按钮,并完成按钮点击事件

代码如下:

importjava.awt.BorderLayout;
importjava.awt.Color;
importjava.awt.FlowLayout;
importjava.awt.Graphics;
importjava.awt.Polygon;

importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JPanel;

publicclassAppextendsJFrame{

publicApp(){

this.setSize(300,300);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPaneltopBar=newJPanel();
topBar.setLayout(newFlowLayout());
this.add(topBar,BorderLayout.NORTH);

JPanelcanvas=newJPanel();
this.add(canvas,BorderLayout.CENTER);

JButtonbtnTriangle=newJButton("三角形");
btnTriangle.addActionListener(e->{

Graphicsg=canvas.getGraphics();

g.setColor(Color.RED);

Polygonpolygon=newPolygon();
polygon.addPoint(10,10);
polygon.addPoint(10,50);
polygon.addPoint(100,50);

g.fillPolygon(polygon);
});
topBar.add(btnTriangle);

JButtonbtnRectangle=newJButton("矩形");
btnRectangle.addActionListener(e->{

Graphicsg=canvas.getGraphics();

g.setColor(Color.RED);

g.fillRect(150,10,100,50);
});
topBar.add(btnRectangle);

JButtonbtnCircle=newJButton("椭圆");
btnCircle.addActionListener(e->{

Graphicsg=canvas.getGraphics();

g.setColor(Color.GREEN);

g.fillOval(10,100,250,90);
});
topBar.add(btnCircle);
}

publicstaticvoidmain(String[]args){
newApp().setVisible(true);
}
}

运行结果:

F. JAVA编程中如何自动调用按钮的点击事件

直接创建一个SelectionEvent类型的对象,然后直接调用监听器里面的方法,比如
SelectionEvent se=new SelectionEvent(...); //...为构造函数的参数,内具体内容就得参考API文档容了。
SelectionListener sl=new SelectionListener();
sl.widgetSelected(se);
就这样。

G. Java 程序实现鼠标点击 键盘等事件

用 Robot 类的如下方法:
void keyPress(int keycode)
按下给定的键。
void keyRelease(int keycode)
释放给定的键。
void mouseMove(int x, int y)
将鼠标指版针移动到给定屏幕坐权标。
void mousePress(int buttons)
按下一个或多个鼠标按钮。
void mouseRelease(int buttons)
释放一个或多个鼠标按钮。
void mouseWheel(int wheelAmt)
在配有滚轮的鼠标上旋转滚轮。

H. JAVA中如何设置多次点击一个按钮但有不同的事件响应,类似于一般安装软件时“下一步”按钮

将按钮上边绑定的事件换掉,或者在同一个事件响应方法中加参数辨别也行.

I. java鼠标点击事件

给你一个例子,太难讲了
我自己写的
package guidemo;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
* <p>Title: 图形用户界面</p>
*
* <p>Description: 简单的图形界面编程</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author vic
* @version 1.0
*/
public class ColorFrame extends Frame implements MouseListener {
Label L; //标签
TextField T; //文本域
Button B1, B2; //按钮
public ColorFrame() {
this.setLayout(null); //想要手动指定各组件的的位置
L = new Label("输入学号:"); //设定标签L内容
L.setBounds(60, 50, 50, 25); //设定标签L外观
this.add(L); //将标签L添加到窗口中
T = new TextField("请在这里输入"); //设定文本域T的内容
T.setBounds(125, 50, 90, 25); //设定文本域T的外观
this.add(T); //将文本域T添加到窗口中
B1 = new Button("变红!"); //设定按钮B1的内容
B1.setBounds(25, 90, 90, 25); //设定按钮B1的外观
B1.addMouseListener(this);//在B1上注册鼠标监听器
this.add(B1); //将按钮B1添加到窗口中
B2 = new Button("变绿!");
B2.setBounds(125, 90, 90, 25);
B2.addMouseListener(this);
this.add(B2);
WindowDestroyer Listener = new WindowDestroyer(); //创建关闭窗口监听器
this.addWindowListener(Listener); //将监听器添加到窗口中
this.setBackground(Color.yellow); //设定窗口背景颜色
this.setTitle("This is Frame!"); //设定窗口标题文字
this.setBounds(0, 0, 250, 220); //设定窗口位置和大小
this.setVisible(true); //显示窗口
}

public void mouseClicked(MouseEvent e) {
if (e.getComponent() == B1) {//getComponent返回按钮上面的字符串
this.setBackground(Color.red);
}
if (e.getComponent() == B2) {
this.setBackground(Color.green);
}
}

public void mouseExited(MouseEvent e) {}

public void mouseEntered(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e) {}

public static void main(String[] args) {
new ColorFrame();
}
}
希望能解决您的问题。

J. 用java在文本框实现鼠标点击事件,一点文本框直接跳出新对话框

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class Exec1 extends JFrame {

public Exec1() {
JTextField txt = new JTextField();
txt.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
new A().setVisible(true);
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
});
add(txt);
setSize(100, 65);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main(String [] args) {
new Exec1().setVisible(true);
}
}

class A extends JFrame {
public A() {
setSize(400, 400);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}

阅读全文

与java实现连续点击事件相关的资料

热点内容
免费看sf小说的网站 浏览:145
有小说 图片 视频的网站 浏览:124
360大数据中心副总裁 浏览:507
微信影院有哪些 浏览:824
男人不知道小电影的网址 浏览:978
noteexpress样式文件夹 浏览:854
外国电影女子自慰家人来给过生日 浏览:788
带颜色的系统爽文 浏览:934
大胖二愣三柱四猴的电影 浏览:2
哪里可以看上影没多久的电影 浏览:774
四轴联动编程软件哪个好 浏览:268
看客电影在线观看 浏览:467
详细写肉的都市小说 浏览:580
看那种片的网址 浏览:727
大尺度的同性电影 浏览:447
网站在线播放视频国语 浏览:667
台湾伤痕les剧 浏览:426
两个数据库实时同步 浏览:67
微信支付宝账单怎么看 浏览:448
眼镜看见老师内衣 浏览:322

友情链接