/**
* キー押しっぱなしなのにkeyReleasedが呼ばれる問題
*
* {} <- こうなってほしい
* {{{{{{{{{} <- ぐぐった所こうなるのが正常らしい
* {}{}{}{}{}{}{}{}{}{}{}{}{}{}{} <- なぜかこうなる
* */
import javax.swing .JFrame ;
import javax.swing .JPanel ;
import java.awt .event .KeyEvent ;
import java.awt .event .KeyListener ;
public class Main extends JFrame {
public Main( ) {
JPanel panel = new KLPanel( ) ;
getContentPane( ) .add ( panel) ;
}
public static void main( String[ ] args) {
Main frame = new Main( ) ;
frame.setVisible ( true ) ;
}
}
class KLPanel extends JPanel implements KeyListener {
public KLPanel( ) {
setFocusable( true ) ;
addKeyListener( this ) ;
}
public void keyPressed( KeyEvent e) {
System.out .print ( "{" /*+e.getKeyCode()*/ ) ;
}
public void keyReleased( KeyEvent e) {
System.out .print ( /*" "+e.getKeyCode()+*/ "}" ) ;
}
public void keyTyped( KeyEvent e) { }
}
LyoqCiAqIOOCreODvOaKvOOBl+OBo+OBseOBquOBl+OBquOBruOBq2tleVJlbGVhc2Vk44GM5ZG844Gw44KM44KL5ZWP6aGMCiAqCiAqIHt9IDwtIOOBk+OBhuOBquOBo+OBpuOBu+OBl+OBhAogKiB7e3t7e3t7e3t9IDwtIOOBkOOBkOOBo+OBn+aJgOOBk+OBhuOBquOCi+OBruOBjOato+W4uOOCieOBl+OBhAogKiB7fXt9e317fXt9e317fXt9e317fXt9e317fXt9e30gPC0g44Gq44Gc44GL44GT44GG44Gq44KLCiAqICovCgppbXBvcnQgamF2YXguc3dpbmcuSkZyYW1lOwppbXBvcnQgamF2YXguc3dpbmcuSlBhbmVsOwoKaW1wb3J0IGphdmEuYXd0LmV2ZW50LktleUV2ZW50OwppbXBvcnQgamF2YS5hd3QuZXZlbnQuS2V5TGlzdGVuZXI7CgpwdWJsaWMgY2xhc3MgTWFpbiBleHRlbmRzIEpGcmFtZSB7CiAgICBwdWJsaWMgTWFpbigpIHsKICAgICAgICBKUGFuZWwgcGFuZWwgPSBuZXcgS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