mouseevent

which JLabel has been clicked?

寵の児 提交于 2019-12-06 15:07:59
问题 I have 6 JLabel and each is having a different instance of a mouselistener class attached. How to know which JLabel has been clicked ? These JLabel form a two dimentional array. 回答1: You use getSource to get a refrence to the object which is clicked on: label1.addActionListener(new yourListener()); label2.addActionListener(new yourListener()); public class yourListener extends MouseAdapter{ public void mouseClicked(MouseEvent e){ JLabel labelReference=(JLabel)e.getSource(); labelReference

Disappearing Problems Using a Released MouseEvent In Java

人盡茶涼 提交于 2019-12-06 14:27:48
Currently I have a game that I am building in Netbeans, and have been able to create a board, place the pieces and allow them to be moved anywhere using mouseveent's But now I have ran into a problem when trying to code the pieces on the board to only do allowed actions. The problem I am having is that every piece is still allowed to be moved but now when it is moved the selected piece disappears from the board completely ingorning all the new function in the mouse release event The code I am trying to add is for the WhitePawn which is the only piece that should be allowed to move right now

C# Winforms Transparent Control allowing Clickthrough

谁说我不能喝 提交于 2019-12-06 09:24:45
I have a problem, a bit related to: C# Winforms Transparent Control allowing Clickthrough Contrary to him I would like to capture mouse events on my program, while still retaining a "window" to whats behind my program. color.transparent doesn't work, and transparency key just delivers mouse events to whatever is underneath. Using a panel with transparent BackColor or with a BackColor equal to transparency key does not give the desired effect. If you need to capture the mouse events, and that's include the MouseClick , then simply use transparency, but don't set it to 0 set it to 1 . It will be

WPF RepeatButton MouseUp

痞子三分冷 提交于 2019-12-06 08:26:39
问题 Is there a way to get the MouseUpevent on the repeatbutton to fire when the button is not pressed anymore? I am trying to use the MouseMove event to track the position of the mouse while the button is pressed, but neither MouseDown nor MouseUp fire an event for the left mouse button. Any ideas or advice as to what can be done? Thank you 回答1: It appears that the repeat button is marking the event as handled internally. You can use the PreviewMouseLeftButtonUp tunneling event to catch the event

Adding a Vue.js v-on event to D3 SVG element

笑着哭i 提交于 2019-12-06 08:15:57
问题 Is it possible to add a VueJS v-on event to an SVG element in D3? I want to use the v-on.mouseover functionality to each rectangle element of an SVG. I am trying to do so by adding v-on:mouseover="active = !active" as an attribute in D3, as in the following snippet: h.selectAll('.bar') .data(myCSVdata) .enter() .append('g') .attr('v-on:mouseover', 'active = !active') .attr('class', 'bars') .append('rect') but D3 seems to strip out the v-on: and I am left with <g mouseover="active = !active"

Listening to system mouse clicks from Java

三世轮回 提交于 2019-12-06 08:01:04
问题 My main aim is to count the number of mouse clicks on a particular application. Imagine I have opened Microsoft Word and a web browser on my PC. My Java code should tell me how many times I clicked on Word and on the web browser. I need the application name and the number of clicks. How can I do this? Any solution must work for MAC, Linux and Windows. 回答1: You could try a library such as jnativehook: http://code.google.com/p/jnativehook/. Check out their examples on this page. This library

JFreeChart interactive chart editing handling ChartMouseEvent

自作多情 提交于 2019-12-06 07:54:40
I'm trying to intercept ChartMouseEvent in order to modify an XYSeries of a JFreeChart object created with ChartFactory.createXYLineChart method (and displayed using a JDialog). I retrieve successfully the coordinate of the mouse event this way: public void chartMouseMoved(ChartMouseEvent arg0) { int x = arg0.getTrigger().getX(); int y = arg0.getTrigger().getY(); The origin of the coordinate system (0,0) is located at the red square in the picture. Now, I would like to calculate in which interval is the mouse in. In order to do this I need: the top-left coordinate of the grey chart (green

JavaFx Transparent window - yes please. Mouse transparent - no thanks

蓝咒 提交于 2019-12-06 07:48:27
问题 I would like to create a simple JavaFx class that shows the user a translucent rectangle (say an arbitrary 50% transparency) covering the users screen. It should simply allow me to get the Point of a mouse click event. This sounds trivial, but when I create transparent windows they always seem to be transparent to mouse events rather than just my requirement of semi-transparent visibility. The mouse event is never triggered. I've used setMouseTransparent(false) on the rectangle and the root

How to simulate mouse move and mouse click on Mac using C or C++

。_饼干妹妹 提交于 2019-12-06 07:36:34
问题 I am trying to simulate mouse move and mouse click on Mac using C or C++. But unfortunately I don't find any Libraries for the same. I have seen windows.h (works only for Windows) and also swinput (works for linux) Is there anything like that for Mac? 回答1: CGPostMouseEvent has been deprecated in SnowLeopard. You can replace it with something like CGEventRef mouseDownEv = CGEventCreateMouseEvent (NULL,kCGEventLeftMouseDown,pt,kCGMouseButtonLeft); CGEventPost (kCGHIDEventTap, mouseDownEv);

How to get mouse events from outside of program window

时光毁灭记忆、已成空白 提交于 2019-12-06 07:33:07
I want to drag this character. Image : so i use this method to get mouse position: WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { ... switch (message){ case WM_LBUTTONDOWN: case WM_MOUSEMOVE: GetCursorPos(&mousePosition); break; } ... } The program seems to be running well, but if the mouse is out of the characters location, it wouldn't follow the mouse cursor anymore. How can I fix this problem? See SetCapture on MSDN: Sets the mouse capture to the specified window belonging to the current thread. SetCapture captures mouse input either when the mouse is over the capturing