13

In doClick() when it calls doClick(pressTime) does it send 68 milliseconds? Why did they decide on 68 instead of a more round number? Is it a completely arbitrary number?

From Java AbstractButton:

public void doClick() {
    doClick(68);
}
mKorbel
  • 109,525
  • 20
  • 134
  • 319
Ian
  • 354
  • 4
  • 13
  • 1
    This is an interesting question, although I'm not sure it's necessarily answerable (because it is an apparent arbitrary decision without a comment left in the source code). I'm not familiar with AWT's internals though, so there might be a reason someone more familiar with it can provide that I'm not seeing. – nanofarad Jun 15 '16 at 15:32
  • I would not be surprised if it is arbitrary, but if there is a reason that'd be nice to know! – Ian Jun 15 '16 at 15:37
  • I am interested as well--The internals and design decisions behind the Java API and JVM are a great personal interest to me. – nanofarad Jun 15 '16 at 15:41

2 Answers2

6

It might have to do with how fast a human can click on average.

If you look at this timer, with a bit of excersise it's possible to reach the 68ms on average.

They might have simply made a setup like below, had a go at it to get on a nice average click duration and then used that for the default value.

var timer = 0;
var results = [];
$('#clicktest').on('mousedown',function() {
    timer = window.performance.now();
});
$('#clicktest').on('mouseup',function() {
    results.push(window.performance.now()-timer);
    var total = 0;
    for(c=0;c<results.length;c++) {
        total+= results[c];
    }
    $('#output').text('Average click duration '+ Math.round(total/results.length)+'ms');
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="clicktest">Click me</button>
<div id="output">Average click duration N/A</div>
Tschallacka
  • 27,901
  • 14
  • 88
  • 133
1
  • note most of painting artefacts are valid for Metal L&F just and only as a defaults, f.e. Windows L&F totally ignores that, it hasn't this method as peer or returns for programing languages thats runs from Win session,

  • doClick is programatically to simulating the JButton press e.g. from mouse or key event (TAB , ENTER)

  • doClick(int pressTime) to visually paints action as information to user, painting isPressed to the screen, miliseconds from JVM returns me very closely number (1999 - 2001 for doClick(2000))

  • very low number at 68miliseconds haven't any screen effect, because isn't catchable by humans eyes, maybe most of LCD / LED monitors can't repaint this painting artefact correctly,

  • answer by @Michael Dibbets is closer to setMultiClickThreshhold(long threshhold),

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319