题目内容

本题程序的功能是监听键盘敲击事件,并将敲击的字符显示在标签上。开始时文字标签提示“Please press your keyboard!”,当按下键盘上的字符键时,文字标签就变为“’X’is pressed!”(X代表用户按下的键所代表的字符)。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class simple extends Frame ______ public static void main(String args[]) simple f = new simple("simple"); Panel pan = new Panel(); f.init(); public simple(String str) super (str); public void init() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit (0); ); setSize(200,200); setLayout(new FlowLayout()); lab = new Label("Please press your keyboard!"); add(lab); addKeyListener(this); setVisible(true); public void keyTyped(KeyEvent e) lab.setText("\’"+______+"\’ is pressed!"); repaint(); public void keyPressed(KeyEvent e) public void keyReleased(KeyEvent e) private Label lab;

查看答案
更多问题

Briefly introduce Blake’s Songs of Innocence and Songs of Experience.

What are the factors that gave rise to American naturalism

This is my letter to the World That never wrote to Me— The simple News that Nature told— With tender Majesty Questions: A. Identify the poet. B. What idea does the poem express C. Why does the poet use dashes and capital letters in the poem

Wherefore, Bees of England, forgeMany a weapon, chain, and scourge,That these stingless drones may spoilThe forced produce of your toilQuestions:A. Identify the poet and the poem from which the lines are taken.B. What do you know about the poem’s writing backgroundC. What do you think the poet intends to say in the poem

答案查题题库