Specifically, I’m trying to find out what makes popup boxes and drop down menus hide or continue showing depending on where you clicked in java.
I tried looking at the API but I didn’t see what I was looking for.
-
How can I tell if the next click is a desired element or not? (hopefully I can work up from there)
-
Is there an easy way to get the properties of the next item clicked?
For instance, want to get the properties of Object B for a method of Object A. So when I click Object A I almost want an open method (not really of course) like
public void checkObject(Object object){
System.out.println(Object.getName());
}
When I click Object A I could run something like
...scanNextMouseClick()
which would return the next item clicked then
...if('item clicked' != Object B) return;
I could do something like this to make sure I pass in the right type of parameter, if not, scanNextMouseClick would still be satisfied and my program would continue normally
...checkObject('item clicked') //to finally run the method.
If you’re talking about swing then I think you are looking for a focusListener. Basically if your Object/component gains focus your focusListener performs the desired actions. So if you click object A (if object A is say a JPanel), object A gains focus. Having said that there is also an actionListener class which listens for things like button clicks and such.