网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

请完成下面的程序:实现一个可以每秒跳动的时钟。运行如下图所示。请填写横线处的内容。

注意:请勿改动main主方法和其他已有语句内容,仅在下划线处填入适当的语句。

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

public class Example2_12 extends JFrame (1) implements Runnable

{

Thread thread1;

Color handColor;

Color numberColor;

JLabel jlabell = new JLabel();

public Example2_12()

{

enableEvents(AWTEvent.WINDOW_EVENT_MASK);

try

{

getContentPane().add(jlabell, BorderLayout. SOUTH);

}

catch (Exception e)

{

System.out.println(e.getMessage());

}

}

public static void main(String args[])

{

Example2 12_clock1 = new Example2_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;

setBackground(Color.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.get(Calendar.SECOND);

m = c1.get(Calendar.MINUTE);

h = c1.get(Calendar.HOUR);

int day, month, year, weekday;

day = c1.get(Calendar.DATE);

month = c1.get(Calendar.MONTH) + 1;

year = c1. get (Calendar. YEAR);

weekday = c1.get (Calendar. 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, yp


参考答案

更多 “ 请完成下面的程序:实现一个可以每秒跳动的时钟。运行如下图所示。请填写横线处的内容。注意:请勿改动main主方法和其他已有语句内容,仅在下划线处填入适当的语句。import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.util.*;public class Example2_12 extends JFrame (1) implements Runnable{Thread thread1;Color handColor;Color numberColor;JLabel jlabell = new JLabel();public Example2_12(){enableEvents(AWTEvent.WINDOW_EVENT_MASK);try{getContentPane().add(jlabell, BorderLayout. SOUTH);}catch (Exception e){System.out.println(e.getMessage());}}public static void main(String args[]){Example2 12_clock1 = new Example2_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;setBackground(Color.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.get(Calendar.SECOND);m = c1.get(Calendar.MINUTE);h = c1.get(Calendar.HOUR);int day, month, year, weekday;day = c1.get(Calendar.DATE);month = c1.get(Calendar.MONTH) + 1;year = c1. get (Calendar. YEAR);weekday = c1.get (Calendar. 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, yp ” 相关考题
考题 下列程序打包到example包,main方法调用线程类输出0~9这10个数,请填写横线处的内容。注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。______interface MyInterface{public abstract void print(int n);}class Mythread extends Thread ______ MyInterface{public void run(){for(int i = 0; i < 10; i++)this.print(i);}public void print(int n){System.out.print(n +" ");}}public class Example1_6{public static void main(String argv[]){Mythread th = new Mythread();______}}

考题 接口是抽象方法和常量的集合,是一种特殊的抽象类。下面的程序是对接口的操作,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________MyInterface{public static int NUM=100;public abstract void print();}public class ClassName___________MyInterface{public void print(){System.out.println(NUM);}public static void main(String args[]){__________________________obj .print();}}

考题 下面的程序是用do-while语句计算10的阶乘。请在程序的每条横线处填写1个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容;仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(______){int n=10;long result=1;do{_____;}_____;System.out.println("10的阶乘为:"+result);}}

考题 下面程序执行后,输出结果为:true请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class TestStringCompare{{public static void main(String ____________________ args){char charl[]={'t','e','s','t'};char char2[]={'t','e','s','t','1'};String str1=new String(___________________);String str2=new String(char2,0,4);System.out.println(__________________________);}}

考题 下面程序是关于类的继承的用法。阅读下面程序,根据程序中的注释在每一条横线处填写一个语句,使程序的功能完整,且运行程序后的输出结果为:I am parentclass!I am childclass!I am childclass!注意: 请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。class Parent {void printMe() {System.out.println("I am parentclass!");}}class Child extends Parent {void printMe() {System.out.println("I am childclass!");}void printAll() {______________.printMe ( ); // 调用父类的方法______________. printMe ( ); //调用本类的方法printMe ( );}}public class TestJieCheng {public static void main(String args[]) {______________myC.printAll();}}

考题 下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。____________________public class TestKeyBoardInPut{public static void main(String[] args){String yourname=JOptionPane. ____________________ ("What is your name?");System.out.println("Hello"+yourname);____________________.exit(0);}}

考题 下面是一个Applet小程序,其功能为:以坐标(10,20)为起点,画一条长为80个像素点的绿色直线,请在横线处填写一条语句,使程序的完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________________import java.awt.*;public class test_drawline extends Applet{public void paint(_______________){g.setColor(Color.green);_____________________}}

考题 下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(________){int n=10;long result=1;do{_______________}______________System.out.println("10的阶乘为: "+result);}}

考题 请完成下列Java程序。程序的输出结果:a=6,b=5。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下:public class ex38_2{public static void main(String args[]){int a=5,b=6;a=_________;b=a-b;a=_________;System.out.println("a="+a+"\tb="+b);}}

考题 下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________________public class SimpleCharInOut{public static void main(String args[]){char c=" ";System.out.println("Enter a character please: ");try{____________________//接受用户键盘输入的字符并保存在变量c中}catch(________________________e){}System.out.println("You've entered character "+c);}}