更多"下列程序中,实例tat是监听器,fr是事件源,fr上发生的事件委托ta"的相关试题:
[填空题]下列程序中,实例tat是监听器,fr是事件源,fr上发生的事件委托tat进行处理。程序的执行结果是显示一个粉红色的窗口,单击关闭按钮,可关闭窗口。请填完整程序。
import java.awt.*;
importjava.awt.event.*;
public class Testppp
{
public static void main(String args[ ])
{
Frame fr=new Frame("The Adapter!”);
TheAdapterTest tat=new TheAdapterTest( );
fr 【 】
fr.setSize(200,200);
fr.setBackground(Color.pink);
fr.setVisible(true);
}
}
class TheAdapterTest extends WindowAdapter
=
public void windowClosing(WindowEvent e)
{
System.exit(1);
}
=
[填空题]下列程序中,实例tat 是监听器,fr是事件源,fr上发生的事件委托tat进行处理。程序的执行结果是显示一个粉红色的窗口,单击关闭按钮,可关闭窗口。请将程序补充完整。
import java. awt.*;
import java. awt.event.*
public class Testppppublic static void main ( String args [])Frame fr = new Frame ("The Adapter !" );
TheAdapterTest tat=new TheAdpterTest ( ):
fr. 【14】
fr. setSize (200, 200):
fr. setBackground (Color. pink);
fr. setVisble (true):
class TheAdapterTest extends WindowAdapterpublic voidWindowClosing (WindowEvent e)System.exit ( 1);
[简答题]请完成下列Java程序。实例listener是监听器,frm是事件源,fr上发生的事件委托tat进行处理。程序的执行结果是显示一个蓝色的窗口,单击关闭按钮,可关闭窗口。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在下划线处填入适当的语句。
源程序文件代码清单如下:
import java.awt.*;
import java.awt.event.*;
public class BlueWindow
public static void main(String args[])
Frame frm=new Frame ("欢迎参加Java考试!");
TheAdapterTest listener=new TheAdapterTest( );
frm. ______;
frm.setSize(200,200);
frm.setBackground(Color.blue);
frm. ______;
class TheAdapterTest extends WindowAdapter
public void windowClosing(WindowEvent e)
System.exit(1);
[填空题]小应用程序有一个按钮和一个文本区,按钮作为发生键盘事件的事件源,并对键盘事件实施监视。程序运行时,先点击按钮,让按钮激活。以后输入英文字母时,在文本区显示输入的字母。
import java. applet.*;import javax. swing.*;
import Java. awt. event.*;
public class Test29 extends Applet implements______
JButton button=new JButton( );
JTextArea text=new JTextArea(5,20);
public void init( )
button. addKeyListener(this);add(button);add(text);
public void keyPressed(KeyEvent e)
int t=e.______;
if(t>=KeyEvent. VK_A&&t<=KeyEvent. VK_Z)
text. append((char)t+" ");
public void keyTyped(KeyEvent e)
public void keyReleased(KeyEvent e)
[单项选择]下列程序实现了2个监听器接口:ActionListener和W1ndowListener。 import java.awt.*; import java.awt.event.*; public class ex39______ { public static void main(String[] args) { ex39 obj = new ex39( ); obj .go( ); } public void go( ) { Frame f = new Frame("ex39"); f.addWindowListener(this); Button b = new Button("Button"); b.addActionListener(this); f.add(b); f.pack( ); f.setVisible(true); } public void actionPerformed(ActionEvent e) { System.out.println("Button pressed!"); } public void windowActivated(WindowEvent e){} public void windowDeactivated(WindowEvent e){} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e){System.exit(1); public void windowIconified(WindowEvent e){} public void windowDeiconified(WindowEvent e) {} public void windowOpened(WindowEvent e){} } 请选择正确的语句填入横线处。
A. extends ActionListener, WindowListener
B. implements ActionListener, WindowListener
C. implements ActionListener; WindowListener
D. extends ActionListener; WindowListener
[填空题]JDBC驱动程序实例将应用程序中基于______的Java方法转换为数据库实例能够理解的命令。
[单项选择]下列事件监听器中,无法对TextField对象进行事件监听和处理的是( )。
A. ActionListener
B. FocusListener
C. MouseMotionListener
D. ChangeListener