试题查看

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

请完成下面的程序:实现一个可以每秒跳动的时钟。运行如下图所示。请填写横线处的内容。 注意:请勿改动main主方法和其他已有语句内容,仅在下划线处填入适当的语句。 import javax.swing.*; import jav

A、awt.*; import jav
A、awt.event.*;
import jav
A、util.*; public classExample2_12 extends JFrame (1) implements Runnable { Thread thread1;Color handColor;Color numberColor; JLabel jlabell = new JLabel(); publicExample2_12() { enableEventsAWTEvent.WINDOW_EVENT_MASK); try { getContentPane().add(jlabell,BorderLayout. SOUTH); } catchException e) { System.out.println(e.getMessage()); } } public static void main(String args[]) {Example2 12_clock1 = newExample2_12(); clock1.init(); clock1.start(); clock1.setSize(260, 230); clock1.setResizable(false); clock1.show(); } public void init() { int x, y; handColor =Color.blue; numberColor =Color.darkGray; setBackgroundColor.white); } public void paint (Graphics g) { int xh, yh, xm, ym, xs, ys, s = 0, m = 10, h = 10, xpoint, ypoint; String today;Calendar c1 = ______; s = c1.getCalendar.SECOND、; m = c1.getCalendar.MINUTE、; h = c1.getCalendar.HOUR); int day, month, year, weekday; day = c1.getCalendar.DATE、; month = c1.getCalendar.MONTH) + 1; year = c1. getCalendar. YEAR); weekday = c1.getCalendar.DAY_OF_WEEK); jlabell.setText("Today is "+ year + "/" + month + "/" + day + "/ "+ "Time:" + h + ":" + m + ":" + s); xpoint = 130; ypoint = 100; xs =(int) (Math.cos(s * 3.14f / 30 - 3.14f / 2) * 45 + xpoint); ys =(int) (Math.sin(s * 3.14f / 30 - 3.14f / 2) * 45 + ypoint); xm =(int) (Math.cos (m * 3.14f / 30 - 3.14f / 2) * 40 + xpoint); ym =(int) (Math.sin(m * 3.14f / 30 - 3.14f / 2) * 40 + ypoint); xh =(int) (Math.cos( (h * 30 + m / 2) * 3.14f / 180 - 3.14f / 2) * 30 + xpoint); yh =(int) (Math.sin( (h * 30 + m / 2) * 3.14f / 180 - 3.14f / 2) * 30 + ypoint); g.setColor (handColor); g.clearRect(0, 0, 260, 200); g.drawOval(xpoint / 2 + 10, ypoint / 2 - 5, 110, 110); g.setColor(numberColor); g.drawString("9", xpoint - 45, ypoint + 3); g.drawString("3", xpoint + 40, ypoint + 3); g.drawString("12", xpoint - 5, ypoint - 37); g.drawString("6", xpoint - 3, ypoint + 45); g.setColor(getBackground ( ) ); g.setColor(numberColor); g.drawString(" ", 5, 125); g.drawLine(xpoint, ypoint, xs, ys); g.setColor(handColor); g.drawLine(xpoint, ypoint, xm, ym); g.drawLine(xpoint, ypoint, xh, xh); } public void start() { thread1 = new Thread(this); thread1. ______; } public void stop () { thread1=null; } public void update (Graphics g) { paint (g); } public void run () { Thread me = Threa
D、currentThread (); while (thread1 == me) { try { Threa
D、currentThread ( ) . sleep ( 100 ); }catch (InterruptedException e) { e.printStackTrace(); } repaint ( ); } } protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) System.exit(0); } }
查看答案解析

参考答案:

正在加载...

答案解析

正在加载...

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

0%的考友选择了A选项

0%的考友选择了B选项

0%的考友选择了C选项

0%的考友选择了D选项

你可能感兴趣的试题

下列内部排序方法中,稳定的排序方法是______。A.快速排序B.堆排序C.希尔VisualBasic提供的工具栏中,一般只显示______。A.编辑B.标准工在下列方法中,不用查找表中数据元素的关系进行查找的方法是______。A.有序表在下列4个VisualBasic表达式中,非法的表达式是______。A.a=b表示窗体为“模态型”(强制响应方式)窗体的“模式”值为______。A.VbMo设有如下声明;DimXAsInteger如果Sgn(X)的值为-1,则X的值是_