import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Sample7
extends JApplet {
public void init()
{
lb1
= new JLabel("矢印キーで選びなさい");
addKeyListener(new SampleKeyListener());
}
{
@Override
{
int k = e.getKeyCode();
switch(k){
str = "上"; break;
str = "下"; break;
str = "左"; break;
str = "右"; break;
default:
str = "他のキー";
}
lb2.setText(str + "ですね");
}
}
}
aW1wb3J0IGphdmEuYXd0Lio7CmltcG9ydCBqYXZhLmF3dC5ldmVudC4qOwppbXBvcnQgamF2YXguc3dpbmcuKjsKCnB1YmxpYyBjbGFzcyBTYW1wbGU3IGV4dGVuZHMgSkFwcGxldAp7CiAgIHByaXZhdGUgSkxhYmVsIGxiMSwgbGIyOwoKICAgcHVibGljIHZvaWQgaW5pdCgpCiAgIHsKICAgICAgbGIxID0gbmV3IEpMYWJlbCgi55+i5Y2w44Kt44O844Gn6YG444Gz44Gq44GV44GEIik7CiAgICAgIGxiMiA9IG5ldyBKTGFiZWwoKTsKCiAgICAgIGFkZChsYjEsIEJvcmRlckxheW91dC5OT1JUSCk7CiAgICAgIGFkZChsYjIsIEJvcmRlckxheW91dC5TT1VUSCk7CgogICAgICBhZGRLZXlMaXN0ZW5lcihuZXcgU2FtcGxlS2V5TGlzdGVuZXIoKSk7CiAgIH0KCiAgIGNsYXNzIFNhbXBsZUtleUxpc3RlbmVyIGV4dGVuZHMgS2V5QWRhcHRlcgogICB7CiAgICAgICBAT3ZlcnJpZGUKICAgICAgcHVibGljIHZvaWQga2V5UHJlc3NlZChLZXlFdmVudCBlKQogICAgICB7CiAgICAgICAgIFN0cmluZyBzdHI7CiAgICAgICAgIGludCBrID0gZS5nZXRLZXlDb2RlKCk7CiAgICAgICAgIHN3aXRjaChrKXsKICAgICAgICAgICAgY2FzZSBLZXlFdmVudC5WS19VUDoKICAgICAgICAgICAgICBzdHIgPSAi5LiKIjsgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgS2V5RXZlbnQuVktfRE9XTjoKICAgICAgICAgICAgICBzdHIgPSAi5LiLIjsgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgS2V5RXZlbnQuVktfTEVGVDoKICAgICAgICAgICAgICBzdHIgPSAi5bemIjsgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgS2V5RXZlbnQuVktfUklHSFQ6CiAgICAgICAgICAgICAgc3RyID0gIuWPsyI7IGJyZWFrOwogICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgIHN0ciA9ICLku5bjga7jgq3jg7wiOwogICAgICAgICB9CiAgICAgICAgIGxiMi5zZXRUZXh0KHN0ciArICLjgafjgZnjga0iKTsKICAgICAgfQogICB9Cn0=