Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!

Theodore Norvell

Greenhorn
+ Follow
since Aug 09, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Theodore Norvell

The python solution used "yield". So not so java friendly.  Here's a Java solution.  Totally untested.



Now the you can compute all permutations made from the items of list xs as follows



--

The algorithm above is recursive, but after writing the algorithm, I realized that the recursion can be replaced with a loop like this

2 days ago
Rob: Thanks for mentioning the crossposting on stack overflow. The specific requirements were mentioned in my first post: I need the component that would be the source for a mouse event. There are a lot of ways that don't work, I'm looking for one that does.

Below is my current approach. (Developed after I posted the original question.) I'd like to find one that is simpler and that deals correctly with the event mask. For anyone who is tempted to use the following code, I'd caution that it is not thoroughly tested.


5 years ago
Container.getComponentAt is not sufficient for two reasons. First the actual component that should be the source may be many layers deep. I could use findCompoentAt instead to solve that. The second problem is that the component returned by getComponentAt or findComponentAt may not be prepared to handle the event. Consider this hierarchy

JPanel A contains JPanel B contains JButton C contains JLabel D

where only C is prepared to handle mouse events. (x,y) is contained in D. getComponentAt gives B while findComponentAt returns D. The one I want is C.
5 years ago
Mouse events work just fine in a headless environment.
5 years ago
Thanks. I should have mentioned that I'd like to be able to do this in a headless environment. That rules out Robot, I think.
5 years ago
Suppose I have a container c and an (x,y) point relative to that container. I'd like to send a mouse event (say mouse pressed) to the right component within c. Which is the right component? It is the one that would get the event if the mouse had actually at location (x,y) and pressed.

My outline is


Is there an easy way to find the right subcomponent?

So far I've constructed a recursive search based on the nonpublic method Container.getMouseEventTarget.
5 years ago
It is so you can write matches without mentioning y. E.g., e match {case X(x) => ... }.
7 years ago