I am trying to figure out a interesting visual incongruity with awt
buttons.
The below code will open a window with a button. If you click on that button rapidly without moving your mouse you will see the button presses and depresses slower than your clicks. However if you move your mouse around while rapidly clicking on the button it will press and depress as quick as you click.
I cant seam to find anything about this visual difference online. Mostly just post saying "don't use awt and use swift instead". I am not interesting in what the "better" GUI library is but rather what is causing this visual difference.
Can someone explain to me why the button appears to behave differently when them mouse is not moving verses when it is moving?
import java.awt.*;
import java.awt.event.*;
public class TestApp extends Frame implements WindowListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private Button btn1;
public TestApp () {
setLayout(new FlowLayout());
btn1 = new Button("Click ME!");
add(btn1);
setSize(80, 80);
setVisible(true);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
}
public static void main(String[] args) {
new TestApp();
}
}