Hi,
I need a tool which tells the classname of the UI control on which my mouse pointer is. My GUI is in Swing. Does such a tool exist?
Hi,
I need a tool which tells the classname of the UI control on which my mouse pointer is. My GUI is in Swing. Does such a tool exist?
If you need to discover this within the program itself, you can use a MouseListener and the sequence:
Event.getSource()
Object.getClass()
Class.getName()
You can get the current location of the mouse pointer by doing:
Point location = MousePointer.getPointerInfo().getLocation();
Once you have the location, you can convert it to your parent containers coordinate system by doing:
Point relativeLocation = SwingUtilities.convertPointFromScreen(location, parentComponent);
Finally, you can lookup a component at a location by doing:
Component myComponent = parentComponent.getComponentAt(relativeLocation);
Check out Swing Explorer. It allows you to explore the internals of your Swing app.