在事件jian听的处理模型中,主要涉及如下3类对象,事件源(EventSource)、事件(Event)、以及()
第1题
注意:不改动程序的结构,不得增行或删行。
程序运行结果如下:
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ex28_3 extends JApplet implements ActionListener {
ButtonURL[] btnURL = new ButtonURL[3];
public void init() {
btnURL[0] = new ButtonURL("新浪网","http://www.sina.com.cn/");
btnURL[1] = new ButtonURL("163","http://www.163.com/");
btnURL[2] = new ButtonURL("搜狐","http://www.sohu.com/");
GridLayout gl = new GridLayout(1,3);
getContentPane().setLayout(gl);
for (int i = 0; i < btnURL.length; i++) {
btnURL[i].addActionListener(this);
getContentPane().add(btnURL[i]);
}
}
public void actionPerformed(ActionEvent ae) {
ButtonURL btnClick =ae.getSource();//获取发生事件的对象
try {
URL load = new URL(btnClick.strAddr);
getAppletContext().showDocument(strAddr);
} catch (MalformedURLException e) {
showStatus("Bad URL:" + btnClick.strAddr);
}
}
}
class ButtonURL extends JButton {
String strAddr;
ButtonURL(String strLabel, String strAddress) {
super(strLabel);
strAddr = strAddress;
}
}
ex28_3, html
<HTML>
<HEAD>
<TITLE>ex28_3</TITLE>
</HEAD>
<BODY>
<applet code="ex28_3.class" width=800 height=400 >
</applet>
</BODY>
</HTML>
第2题
A.在事件处理类的actionPerformed函数中,调用主框架的对应函数进行处理
B.事件处理类实现了ActionListener接口
C.主框架作为事件处理类的一部分,包括在事件处理类中
D.在事件处理类的构造函数中将主框架的引用变量传递给事件处理类
E.在事件处理类的构构造函数中,创建一个主框架对象,并显示该对象
第3题
A.extra violent
B.extra violet
C.ultraviolet
D.ultravirus
第4题
A.没有区别,都能对事件进行监听
B.设置为true时只能在移动时获得一次监听事件,false则可以多次
C.返回true表示这个消息已经被处理结束,后续的handler不再接收到这个消息
D.设置为false是,在处理一次监听事件后,系统将抛弃该次事件
第5题
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
源程序文件代码清单如下:
import java.awt.*;
import java.awt.event.*;
public class ex12_2
extends Frame. implements MouseMotionListener, ActionListener
private Label 1;
private String str=" ";
public static void main(String args[])
{
new ex12_2();
}
ex12_2( )
{
______;
setSize(200,200);
Button btn=new Button("exit");
btn.addActionListener (this);
add (btn, "North" );
l=new Label(str);
add (l, "South" );
show ();
}
public void mouseMoved(MouseEvent event)
{
str="Move: "+
l. setText (str);
}
public void mouseDragged(MouseEvent event)
{
}
public void actionPerformed(ActionEvent event)
{
if(event.getActionCommand().equals("exit"))
{
System.exit(0);
}
}
}
第6题
【单选题】Search and Rescue In the unlikely event that an aircraft crashes, a pilot should be very aware of search and rescue procedures, and what pilots do can improve survival odds(生存概率). What does the term “search and rescue” mean? After a crash, how can pilots best utilize the resources available to accomplish the survival goal? We need to distinguish between these two key words: search and rescue. If rescue personnel don’t know where crashed aircraft is, it’s a search. If they do know where it is, then it’s a rescue. We will discuss what pilots can do to help in the search phase. The key to survival is to shorten the time from the crash to rescue. Obviously, if the rescue team doesn’t know the location, then it will take a lot longer for them to find it. How much longer? The average time from the last known position (LKP) to rescue is 31 hours. Since this is an average, one could be a survivor for a few hours or a few days. To assure that the LKP is known, as a pilot, the key survival effort begins by filing a flight plan. It is a road map of the inflight movements and is the cheapest insurance available. How cheap? It’s free. The types of flight plans filed will greatly affect the time pilots may have to survive during a search phase. It’s important to understand how the rescue personnel are put into action. When an aircraft is overdue, missing, or sends a radio distress call, the National Search and Rescue Plan is activated. There are many organizations and volunteers associated with Search and Rescue (SAR), but the Federal Government assumes overall responsibility. The National SAR plan designates the U.S. Coast Guard as responsible for maritime SAR and the U.S. Air Force for inland SAR. All SAR activities in the contiguous 48 states are coordinated through the full-time Air Force Rescue Coordination Center (AFRCC) at Scott Air Force Base, Illinois. When a call on a missing or overdue aircraft is received by the Center, the National SAR Plan is activated. (348 words) QUESTION 1: What are the differences between search and rescue
A、A
B、B
C、C
D、D
第7题
A.Timer
B.ActionListener
C.1istener
D.匿名
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!