现在我有:
panel.getZoomButton().addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ACtionEvent e)
{
zoom();
}
}
每次按下缩放按钮时都会调用它。zoom()
如果按住缩放按钮,如何更改它以便连续调用?
现在我有:
panel.getZoomButton().addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ACtionEvent e)
{
zoom();
}
}
每次按下缩放按钮时都会调用它。zoom()
如果按住缩放按钮,如何更改它以便连续调用?
You will need to use a MouseListener
and override the mousePressed()
method. There you can use a Timer or something similar to measure the time, the button has been pressed, in order to calculate your zoom.
Perhaps this question helps you with that: Java MouseEvent, check if pressed down
使用Swing Action(最可扩展的抽象)而不是ActionListener,您可以设置isEnabled,切换到false value
直到所有事件完成
或添加Swing TimerBoolean
以重置true value
有可能setMultiClickThreshhold(long threshhold),但仅适用于 MouseEvents,此方法不会对键盘触发KeyBindings
(ENTER
和) 做出反应TAB