mouseclick-event

Can't filter MouseEvent.MOUSE_CLICKED in AWT EventQueue

无人久伴 提交于 2019-12-11 20:12:09
问题 I need in my own AWT EventQueue filtering mouse double clicks, so I do: public class AppEventQueue extends EventQueue { @Override protected void dispatchEvent(AWTEvent event) { super.dispatchEvent(event); if(event instanceof MouseEvent) { MouseEvent mouseEvent = (MouseEvent) event; if(mouseEvent.getModifiers() == MouseEvent.MOUSE_CLICKED) { //do something } } } } Problem I have is that it looks that click with mouse is generating int value 16, MouseEvent.MOUSE_CLICKED has value 500. Am I

Move a ball on mouse click in Java

亡梦爱人 提交于 2019-12-11 14:42:54
问题 I'm trying to create the classic Breakout game as part of my programming assignment. I have to start moving the ball on a mouse click from the user. So I'm using a mouselistener to achieve that. The code below is just a smaller, simpler version of what I'm trying to do. But it does not move the ball in gradual steps. It just displays the ball at it's final position after the while loop is done executing. import acm.graphics.*; import acm.program.*; import acm.util.*; import java.applet.*;

add mouseclick event to panel

半腔热情 提交于 2019-12-11 09:37:05
问题 I want to assign mouseclick event to asp.net panel : protected void Page_Load(object sender, EventArgs e) { Panel p = new Panel(); p.Click += new EventHandler(b_Click);//but, this doesn't compiles correctly } protected void b_Click(object sender, EventArgs e) { //C#code } Is there any way to add click event to panel? 回答1: Here is what you can do to make your panel clickable and handle the event at server side. Place panel in your web form <asp:Panel runat="server" ClientIDMode="Static" ID=

How to fix Slick Slider (Slick.JS) if it breaks on click event within the div?

牧云@^-^@ 提交于 2019-12-11 08:04:16
问题 I added Slick slider for any device under 1024px, however every time a button within the div is clicked and the page is refreshed, the slider is gone and it leaves a mess. It fixes itself if I change the device width from the console. I tried adding a function to reinitialize it every time a button is clicked, but for some reason 'reInit' does not work. I can't provide Jsfiddle, if someone could help based on my description, I would appreciate it. function slickify(){ event.preventDefault();

Passing control's MouseClick event to its container

痞子三分冷 提交于 2019-12-11 07:54:27
问题 I'll try to be concise but comrehensible. I have a dynamic 2-dimensional array of PictureBox elements, and they're all added to the same form via: this.Controls.Add(PictureBoxArray[i,j]); Now I've designed an algorithm that would determine which of these PBs are clicked, but I've placed it in the ParentForm_MouseClick method. And now I've reached a paradox. The algorithm I've created returns the proper output, but the ParentForm_MouseClick method is called only when I click on the empty space

HTML5 Multiple Canvases event listener - how to determine which canvas experienced the event?

天涯浪子 提交于 2019-12-11 03:09:18
问题 I'm new to JS. I'm not using jQuery, and I have a question. I've created a variable number of canvases on a page, all have an eventlistener like so: for (i=0; i<numberOfCanvases; i++){ var canv = document.createElement("canvas"); canv.addEventListener('click', clickReporter, false); document.body.appendChild(canv); } Given the listener function clickReporter: function clickReporter(e){...} I am trying to use this function to tell me the mouse position of the click event relative to the canvas

d3 got slow all of a sudden

本小妞迷上赌 提交于 2019-12-11 00:47:32
问题 Unfortunately, by 'all of a sudden', I mean between versions 3.1.1.10 and 3.2.0. I have a scatterplot with about 3000 points in it, and we are trying to make a mouse click based tooltip work since tooltips based on mouseover events don't really work for us. So, while testing our initial attempt, we saw that it took a full 2 or 3 seconds before anything happened. I thought that was a little odd. I mean sure, we're doing a nearest-neighbor calculation, but it's only 3000 points, so what gives?

How to wait for a mouse click

拜拜、爱过 提交于 2019-12-11 00:32:15
问题 class GameFrameClass extends javax.swing.JFrame { public void MyFunc() { UserButton.setText(Str); UserButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { UserButtonActionPerformed(evt); } }); getContentPane().add(UserButton); } private void UserButtonActionPerformed(java.awt.event.ActionEvent evt) { //print some stuff after mouse click } } In someother class i define this function void functionAdd() { GameFrameClass gfc

Image did not fresh in Frame on Mouse Click In Java

狂风中的少年 提交于 2019-12-10 12:19:02
问题 First Time three random images shown on Jframe from three diffrent arrays. even MouseClicked Method triggered but images does not refresh in Frame. I want to refresh three random images each time i click on Frame. Please help import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Random; import javax.swing.*; public class Cards extends JFrame implements MouseListener { public static void main(String[] args

handling click event of web browser control

前提是你 提交于 2019-12-10 11:29:56
问题 I want to add click event of webBrowser control. This is my code. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication2 { public partial class Form1 : Form { HtmlDocument htmlDoc; public Form1() { InitializeComponent(); OpenFileDialog open = new OpenFileDialog(); open.ShowDialog(); this.webBrowser1.Navigate(open.FileName); } private void webBrowser1