更多"下面ChangeTitle( )中对b1和b2按键构造监听器,实现当按"的相关试题:
[填空题]下面ChangeTitle( )中对b1和b2按键构造监听器,实现当按下b1键时标题变为Students,当按下b2键时标题变为Teachers。添加空缺的语句。
...
public ChangeTitle( )
super("Title Bar");
b1.addActionListener(this);
【11】 ;
Jpanel pane = new Jpane1( );
Pane.add(b1);
Pane.add(b2);
SetContentPane(pane);
public void actionPerformed(ActionEvent evt)
Object sourve = evt.getSource( );
if (sourve ==b1)
setTitle("Students");
else if (source == b2)
setTitle("Teachers");
repaint( );
...
[填空题]下面ChangeTitle( )中对b1和b2按钮构造监听器,实现当单击b1按钮时标题变为students,当单击b2按钮时标题变为teachen。请将程序补充完整。
public ChangeTitle( )
super("Title Bar");
b1. addActionListener(this); 【15】
Jpanel pane = new Jpanel( );
Pane.add(b1);
Pane.add(b2);
SetContentPane(pane);public void actionPefformed(ActionEvent evt)
Object sourve = evt. getSource( );
if (sourve ==b1)
setTitle("Students");
else if (source == b2)
setTitle("Teachers ");
repaint( );
[填空题]下面ChangeTitle( )中对b1和b2按钮构造监听器,实现当单击b1按钮时标题变为 students,当单击b2按钮时标题变为teachers。请将程序补充完整。
public ChangeTitle( )
super("Title Bar");
b1.addActionListener(this);
______
Jpanel pane=new Jpanel( );
Pane.add(b1);
Pane.add(b2);
SetContentPane(pane);
public void actionPerformed(ActionEvent evt)
Object sourve=evt.getSource( );
if (sourve==b1)
setTitle("Students");
else if (source==b2)
setTitle("Teachers");
repaint( );
[填空题]请在下面代码中加入监听器语句。
importjava.awt.*;
importjava.applet.Applet;
publicclassSimpleextendsAppleimplementsMouseListener
{
StringBuffer;
publicvoidinit( )
{
//监听器语句
buffer=newStringBuffer( );
addltem(“initializing…”);
}
publicvoidmoseEntered(MouseEventevent)
{}
publicvoidmoseExited(MouseEventevent)
{}
publicvoidmosePressed(MouseEventevent)
{}
publicvoidmoseReleased(MouseEventevent)
{}
publicvoidmoseClicked(MouseEventevent)
{
addltem(“click!…”);
}
}
[填空题]请在下面代码中加入监听器语句 【15】 。
import java.awt.*;
import java.applet.Applet;
public class Simple extends Applet implements MouseListener
StringBuffer;
Public void init( )
______//加监听器语句
buffer=new StringBuffer( );
addItem("initializing.....");
Public void moseEntered(MouseEvent event)
Public void moseExited(MouseEvent event)
Public void mosePressed(MouseEvent event)
Public void moseReleased(MouseEvent event)
Public void moseClicked(MouseEvent event)
addItem("click!...");
[单项选择]下列事件监听器中,无法对TextField对象进行事件监听和处理的是( )。
A. ActionListener
B. FocusListener
C. MouseMotionListener
D. ChangeListener
[填空题]JTextField的事件监听器接口是 【13】 。
[填空题]MouseEvent事件可以实现监听器接口的是MouseListener和 【14】 。
[单项选择]下列内部类的正确用途是
btnn.addActionListener(new //注册监听器
ActionListener( )
public void actionPerformed(ActionEvent event)
String s=input.getText( );
output.setText("Hello"+s+",Welcome You!");
);
A. 用于访问外部类的数据
B. 用于进行事件处理
C. 隐藏起来不被同一包中的其他类所见
D. 生成事件适配器
[填空题]下列程序中,实例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);
[填空题]下列程序中,实例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);
}
=