Why JScrollPane does not react to mouse wheel events?

Walter beat me to analysing the issue 🙂 Adding a bit of detail: It’s correct that a JScrollPane supports mouseWheelHandling. According to the rules of mouseEvent dispatching, the top-most (in z-order) component gets the event, and that’s the scrollPane around the textArea. So if wheeling the textarea is not required, a simple solution might be … Read more

How to detect if the mouse is inside the whole form and child controls?

You can hook the main message loop and preprocess/postprocess any (WM_MOUSEMOVE) message what you want. public class Form1 : Form { private MouseMoveMessageFilter mouseMessageFilter; protected override void OnLoad(EventArgs e) { base.OnLoad( e ); this.mouseMessageFilter = new MouseMoveMessageFilter(); this.mouseMessageFilter.TargetForm = this; Application.AddMessageFilter(this.mouseMessageFilter); } protected override void OnClosed(EventArgs e) { base.OnClosed(e); Application.RemoveMessageFilter(this.mouseMessageFilter); } private class MouseMoveMessageFilter : … Read more

Java mouse motion anywhere on screen

java.awt.event.MouseMotionListener is only going to give you information about mouse movement inside your application window. For events that occur outside that window, there is no way around MouseInfo.getPointerInfo. However, you could write a (potentially singleton) class that polls the pointer info in regular intervals and allows MouseMotionListeners to be added: import java.awt.Component; import java.awt.MouseInfo; import … Read more

How to display picture and get mouse click coordinate on it [closed]

Yes it is possible and pretty easy once you understand tkinter, here’s a quick script: from Tkinter import * from tkFileDialog import askopenfilename import Image, ImageTk if __name__ == “__main__”: root = Tk() #setting up a tkinter canvas with scrollbars frame = Frame(root, bd=2, relief=SUNKEN) frame.grid_rowconfigure(0, weight=1) frame.grid_columnconfigure(0, weight=1) xscroll = Scrollbar(frame, orient=HORIZONTAL) xscroll.grid(row=1, column=0, … Read more

Angular 2 how to keep event from triggering digest loop/detection cycle?

1) One interesting solution might be overriding EventManager custom-event-manager.ts import { Injectable, Inject, NgZone } from ‘@angular/core’; import { EVENT_MANAGER_PLUGINS, EventManager } from ‘@angular/platform-browser’; @Injectable() export class CustomEventManager extends EventManager { constructor(@Inject(EVENT_MANAGER_PLUGINS) plugins: any[], private zone: NgZone) { super(plugins, zone); } addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { if(eventName.endsWith(‘out-zone’)) { eventName = eventName.split(‘.’)[0]; return … Read more

How do you disable MouseOver effects on a Button in WPF?

Look what your control template boils down to: <ControlTemplate TargetType=”{x:Type Button}”> <Button> <ContentPresenter/> </Button> </ControlTemplate> You’re saying, “I want to replace the look of my button with… a button.” The usage of the ControlTemplate is to replace the visual tree of a control. So you are replacing the visual tree of the existing button with … Read more

Drag and Resize undecorated JFrame

You can check out mr Rob Camick’s ComponentResizer class. Pretty simple and straight forward to use. Just instantiate the ComponentResizer and register the frame with something like: JFrame frame = new JFrame(); ComponentResizer cr = new ComponentResizer(); cr.registerComponent(frame); cr.setSnapSize(new Dimension(10, 10)); cr.setMaximumSize(new Dimension(…)); cr.setMinimumSize(new Dimension(…)); Here’s a complete example of using the class import java.awt.*; … Read more