I am writing an application where the flow of the execution would go like
- User selects menu item
Based on which menu item
- User is prompted for input in the form of a mouse click on a separate transparent window (JFrame)
- Code is implemented based on user input
- (2) and (3) are repeated set number of times
The user prompt seems simple - I attach a mouse Listener to the window as
class Trainer extends MouseAdapter {
Point p;
public Trainer() {
p = new Point(0,0);
}
public void mouseClicked(MouseEvent e) {
p = MouseInfo.getPointerInfo().getLocation();
output.append("test" + newline);
output.setCaretPosition(output.getDocument().getLength());
glass.setVisible(false);
}
}
The last line in the mouseClicked method basically hides the transparent window and needs to be reshown for the next user prompt (not so important)
I have tried 1) using 1,3,5, etc as an event triggered by the menu select but this results in having an event within an event which I don't think is allowed/possible (?) 2) Sequencing each as a separate event - cumbersome but I am still faced with - how do 3, 5, etc know when 2, 4 etc have been triggered 3) Possibly I am supposed to be using a new Thread. I am new to Java and tutorial on this subject are pretty confusing - a good source for a clear discussion/tutorial on this would be great.
To be clear the user, selects a menu item. Based on this choice, there is a back and forth exchange with the user being prompted for a mouse click and a response based on this click (updating variables, deciding on the next task, etc). The user is prompted to click on a part of the screen outside the application - think of asking the user to select a red part on the desktop background. This requires a temporary transparent window to catch this event - I dont think dialog windows cuts it. ALL discussions and examples given on the use of transparent windows are flawed IMO not a single one works. If I could make a Window (JFrame, or any other construct) with menu items, a section that can have text and the rest of the window being (semi)-transparent so I could see the desktop backdrop, things would be greatly simplified.