There are three kinds of actuaries: those who can count, and those who can't.
My think was that if the user clicked on a button and with the button still held down they could change their mind by sliding the cursor off of the button and then releasing it
Pressing the mouse on top of a button makes the model both armed and pressed. As long as the mouse remains down, the model remains pressed, even if the mouse moves outside the button. On the contrary, the model is only armed while the mouse remains pressed within the bounds of the button (it can move in or out of the button, but the model is only armed during the portion of time spent within the button). A button is triggered, and an ActionEvent is fired, when the mouse is released while the model is armed - meaning when it is released over top of the button after the mouse has previously been pressed on that button (and not already released).
Often the most important part of the news is what they didn't tell.
By the time "ActionListener" was mentioned I already had something working. I'm living with my code for now just to see how I feel about the behavior. If anything doesn't feel right out it goes and in goes ActionListener which would probably be cleaner anyway. Thanks.Matthew Bendford wrote:Although a month late to the party just using ActionListener was what was in my head while reading the OP - as I used it back when java7-ea came out (a few before final java7.0 release) for my battle ships games. I also used mouse events for the initial positioning before the start of the game - but that was rather bad code which I don't really know how I would had improved even today all these years later.
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|