mouseevent

Change mouseListener while mouse is pressed

你离开我真会死。 提交于 2019-12-18 09:28:41
问题 I'm working on a game in Java and have the following challenge. I have 2 JPanels and need to visually drag shapes from one JPanel to another. I've got this working using the GlassPane from the JFrame . When I press the mouse to drag a shape, the GlassPane activates and transfers the shape to the glassPane. Because of this you need to transfer the mousePressed state from the JPanels mouseAdapter to the glassPanes mouseAdapter . I solved this by using the Robot Class which simulates another

Can't get mouse event from any other javafx 8 node after getting MOUSE_PRESSED event from one node

拥有回忆 提交于 2019-12-18 09:00:57
问题 I'm creating rich text component with selection capabilities for JavaFX project and facing some difficulties. I'm trying to catch on which TextFlow object user presses mouse button and on which another TextFlow he releases it. But after MOUSE_PRESSED event i can interact only with that TextFlow, who fired it, until i release the mouse. Here is similar example with Labels: package sample; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label;

Enable other event while dragging an object

流过昼夜 提交于 2019-12-18 07:14:33
问题 I'm developing a console where I want to drag a button to a grid: To drag the button, I use the following procedure: Public drag As Boolean = False Public ptX As Integer = 0 Public ptY As Integer = 0 Public btn As Button Private Sub MoveButton_MouseDown(sender As Object, e As MouseEventArgs) Handles MoveButton.MouseDown drag = True btn = CType(sender, Button) ptX = e.X : ptY = e.Y End Sub Private Sub MoveButton_MouseMove(sender As Object, e As MouseEventArgs) Handles MoveButton.MouseMove If

Mouse event with double click in java

狂风中的少年 提交于 2019-12-18 05:39:06
问题 By default MouseClicked event starts with one click. I have one in a JTextPane but I want to start with double click. Is it possible? 回答1: I believe you can extract the click count from the MouseEvent (assuming its called e) Try this if (e.getClickCount() == 2 && !e.isConsumed()) { e.consume(); //handle double click event. } 回答2: I don't think there will be a solution to this, since Java can run on non-pc devices. Most portable devices don't support double-click. You may keep track of the

Java MouseEvent, check if pressed down

可紊 提交于 2019-12-18 05:00:44
问题 I have a class that implements MouseListener (JPanel). When I click on the panel something happens. What I want is some kind of while-loop that loops as long as left mousebutton is pressed down. @Override public void mousePressed(MouseEvent e) { while(e.isPressedDownD) { // <-- //DO SOMETHING } } This obviously doesn't work, but I hope you understand what I'm trying to achieve. The whole class for those that are interested: package control; import java.awt.event.MouseEvent; import java.awt

Prevent mouse from leaving my form

浪尽此生 提交于 2019-12-18 04:52:36
问题 I've attached some MouseMove and MouseClick events to my program and next up is one of these: Get "global" mouse movement, so that I can read the mouse location even outside the form. Prevent my mouse from leaving the form in the first place. My project is a game so it'd be awesome to prevent the mouse leaving my form like most other games do (ofc. you can move it out if you switch focus with alt+tab fe.) and taking a look at answers to other questions asking for global mosue movement, they

Microsoft Edge: onclick event stops working?

主宰稳场 提交于 2019-12-18 03:55:23
问题 I have strange problems with my (ASP.NET) web application in Microsoft Edge. At a certain point the onclick event stops working. All buttons on the page that respond to the onclick event stop working. On the same page I have some buttons that respond to the onmousedown event and they keep working. If I refresh the page, the problem is gone. There are no errors in the console. I do not have this problem with other browsers (including IE11 under Windows 10). Did any of you experience similar

Catching event when following a link

好久不见. 提交于 2019-12-18 03:35:58
问题 I am trying to track clicks on an external link (without using a "redirect page"). How can I capture an event when a user follows a link, regardless of whether the user: Left clicks on the link Right clicks on the link and open it in a new window Use the keyboard to activate the link Is there other ways to activate a link? The onClick event only applies to the first. If setting href="javascript:fireEventAndFollowLink()" the user will not be able to open the link in a new window (2), so this

MouseLeftButtonUp does not fire

家住魔仙堡 提交于 2019-12-17 21:04:45
问题 I have a Button <Button> <Button.Template> <ControlTemplate> <StackPanel> <Image Source="share.png" MouseLeftButtonUp="Image_MouseLeftButtonUp" MouseLeftButtonDown="Image_MouseLeftButtonDown" /> </StackPanel> </ControlTemplate> </Button.Template> </Button> But the problem is that, unlike MouseLeftButtonDown, the event MouseLeftButtonUp does not fire. Why? How can I solve it? Thanks. 回答1: Probably because the Button is handling the event already, so it doesn't filter down to the Image control.

Asking for some clarification in java about jlabel and parent

假如想象 提交于 2019-12-17 20:33:59
问题 Found this code in the internet, it was posted years ago, so I just decided to ask here for some clarifications for some lines I don't quite understand. In the mousePressed method, what does he mean by: chessPiece = null is he saying that if the JLabel chessPiece has a image in it then it should be changed to null ? Is chessBoard.findComponentAt(e.getX(), e.getY()) returns the JPanel square? and lastly, when Component c gets its parent, who is the parent? The whole code is below: public class