试题查看

首页 > 计算机二级考试 > 试题查看
【分析解答题】

下面程序是一个计时器,从1000秒开始倒计时,直到为0结束。在界面上有两个按钮,一个可以暂停计时,另一个可以继续已经暂停的计时。请更正题中带下划线的部分。 注意:不改动程序的结构,不得增行或删行 import jav

A、awt.*; import jav
A、awt.event.*; import jav
A、applet.Applet; public classExample3_4 extendsApplet { publicColor color =Color.red; private int num= 1000; publicCounter theCounter; privateButton stop; privateButton start; public void init() { stop = newButton("暂停"); start = newButton ("继续"); theCounter = newCounter(this); {{U}}stop.addActionListener(new Lst() implementsActionListener{{{/U}} public void actionPerformedActionEvent e) { theCounter.sus(); } }); start.addActionListener(new SuspenListener()); add(start); add(stop); theCounter.start(); } public void paint(Graphics g) { g.setCotor(color); g.drawString(String.valueOf(num),50,50); } public void setInt(int i) { num=i; } class SuspenListener implementsActionListener { public void actionPerformedActionEvent e) { theCounter.conti (); } } } {{U}}public classCounter extends Thread{{/U}} {Example3_4 example; boolean isHold;Counter Example3_4 ex) { this.example = ex; isHold = false; } public void sus() { isHold = true; } public synchronized void conti() { isHold = false; notify(); } public void run() { for (int i = 1000; i>0; i--) { if (i%2 == 1) example.color =Color.red; else example.color =Color.blue; example.setInt(i); example.repaint(); try { sleep(1000); {{U}}synchronized{{/U}} { while(isHold) wait ( ); } } catch (InterruptedException ie) {} } } } <HTML><HEAD> <TITLE>Example3_4</TITLE></HEAD><BODY> <applet code="Example3_4.class" width=300 height=400> </applet></BODY> </HTML>
查看答案解析

参考答案:

正在加载...

答案解析

正在加载...

根据网考网移动考试中心的统计,该试题:

0%的考友选择了A选项

0%的考友选择了B选项

0%的考友选择了C选项

0%的考友选择了D选项

你可能感兴趣的试题

将stock表的股票名称字段的宽度由8改为10,应使用SQL语句A.ALTERT下面对控件的描述正确的是A.用户可以在组合框中进行多重选择B.用户可以在列表框中如果在建立数据库表stock.dbf时,将单价字段的有效性规则设为“单价>0”,能够将表单的Visible属性设置为.T.,并使表单成为活动对象的方法是A.Hi下面是一个Applet程序,其功能是显示有闪烁特效的从左向右的滚动文字。要求定义下列程序中,定义了一个3行4列的数组A,并将A的内容转换为ASCII码值,并复制