更多"阅读下面Applet程序 import javax. swing. *"的相关试题:
[简答题]阅读下列程序,写出程序能。
import java. applet.*;
import java. awt. *;
public class C3602 extends,Applet implements Runnable
Thread myThread=null;
public void start( )
setSize(300,200);
if(myThread==null)myThread=new Thread(this);
myThread. start( );
public void run( )
while(true)
trymyThread. sleep(500);
catch(InterruptedException e)
repaint( );
public void paint(Graphics g)
double i=Math. random( );
if(i<0.33)g.setColor(Color.yellow);
else if(i<0.66)g.setColor(Color. red);
else g.setColor(Color. blue);
int x=(int)(100*i);
g.fillOval(x,x,x,x);
[简答题]阅读下列程序,写出程序功能。
import java.applet.*;
import java. awt.*;
import java. awt. event.*;
public class C3601 extends Applet implements ActionListener
AudioClip clip;
Button buttonPlay,buttonLoop,buttonStop;
public void init( )
clip=getAudioClip(getCodeBase( ),"1.wav");
buttonPlay=new Button("start");
buttonLoop=new Button("loop");
buttonStop=new Button("stop");
buttonPlay. addActionListener(this);
buttonStop.addActionListener(this);
buttonLoop. addActionListener(this);
setSize(300,100);
add(buttonPlay);add(buttonLoop);add(buttonStop);
public void stop( )
clip.stop( );
public void actionPerformed(ActionEvent e)
if(e.get.Source( )==buttonPlay)clip.play( );
else if(e. getSource( )==buttonLoop)clip.loop( );
if(e. getSource( )==buttonStop)clip. stop( );
[填空题]将下列的程序补充完整。
import java.applet.Applet;
import java.awt.Graphics;
public class Applet2 extends Applet
public void print(Graphics gap)
int i=678;
gap.drawstring(Integer. ______ (i),20,60);
[简答题]阅读下列程序,请写出程序的运行结果。
import java. applet.*;
import java.awt.*;
public class C extends Applet implements Runnable
Thread redBall,blueBall;
Graphics redPen,bluePen;
int blueSeta=0,redSeta=0;
public void init( )
setSize(250,200);
redBall=new Thread(this);
blueBall=new Thread(this);
redPen=getGraphics( );
bluePen=getGraphics( );
redPen.setColor(Color. red);
bluePen.setColor(Color. blue);
setBackground(Color. gray);
public void start( )
redBall.start( );
blueBall.start( );
public void run( )
int x,y;
while(true)
if(Thread.currentThread( )==redBall)
//以下代码为顺时针画圆
x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));
redPen.setColor(Color.gray);
redPen.fillOva
[单项选择]关于下面程序段的说法,正确的是
import java.applet.*;
import java.awt.*;
public class Test extends Applet
Image img;
public void init( )
img=new Image( );
public void paint(Graphics g)
g.drawImage(img,0,0,this);
A. 该程序段可以正常运行
B. 程序中所创建的Image为空,但可以显示
C. 程序中所创建的Image不为空
D. 程序中所创建的Image为空,不能显示
[单项选择]关于下面程序段的说法,正确的是
import javA.applet.*;
import java.awt,*;
public class Test extends Applet
Image img;
public void init( )
img=new Image( );
public void paint(Graphics g)
g. drawlmage(img,0,0,this);
A. 该程序段可以正常运行
B. 程序中所创建的Image为空,但可以显示
C. 程序中所创建的Image不为空
D. 程序中所创建的Image为空,不能显示
[简答题]下面的代码实现一个简单的Applet:
import java.applet.Applet;
import java.awt.*;
public class Sample extends Applet
private String text="Hello World";
public void init( )
add(new Label(text));
public Sample(String string)
text=string;
通过下面的HTML文件访问:
<html>
<title>Sample Applet</title>
<body>
<applet code="Sample.class"width=200 height=200></applet>
</body>
</html>
当编译和运行该小程序时会出现什么结果,请选择正确的答案。( )
[填空题]
请将下面的Applet程序补充完整。
import java. awt. *;
import java. applet. *;
public class Hi 【12】 {
public void paint(Graphics g){
g. drawString("Hi!", 25, 25);
}
}
[填空题]有下面的Applet程序段:
import,java.awt.*;
import.java.applet.*;
public class Hello extends Applet{
public void panin(Graphics g){
gdrawString("Hello World!",25,25);
}
}
为了使该Applet 程序段能在浏览器中运行,请将下面的程序段补充完整。
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<APPLET> 【15】 "WIDTH=150 HEIGHT=25"></APPLET>
[填空题]有下面的Applet程序段:
import.java.awt.*;
import.java.applet.*;
public class Hello extends Applet
public void panin(Graphics g)
gdrawString("Hello World!",25,25);
为了使该Applet程序段能在浏览器中运行,请将下面的程序段补充完整。
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<APPLET "WIDTH=150 HEIGHT=25"></APPLET>
[单项选择]阅读下面程序
import javax.swing.JOptionPane;
public class BreakLabelTest
public static void main( String args[] )
String output="";
stop:
for (int row=1; row<=10; row++)
for (int column=1; column<=5; column++ )
if ( row=5 )
break stop;
output+="* ";
output +="/n";
output +="/nLoops terminated normally";
JOptionPane.showMessageDiaiog(
null, output,"用一个标志测试break语句",
JOptionPane.INFORMATION_MES SAGE );
System.exit( 0 );
程序运行结果是( )。
A. 窗口中有5行*****
B. 窗口中有5行****
C. 窗口中有4行*****
D. 窗口中有6行*****
[单项选择]阅读下面程序
import javax.swing.JOptionPane;
public class BreakLabelTest{
public static void main (String args[]){
String output=" ";
stop:{
for(int row=1;row<10;row++){
for(int column=1;column<=5;column++){
if(row=5)
break stop;
output+=" * ";
}
output+=" /n ";
}
output+="/nLoops terminated normally";
}
JOptionPane.showMessageDialog(
null,output,"用一个标志测试break语句”,
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
程序运行结果是【 】
A. 窗口中有5行*****
B. 窗口中有5行****
C. 窗口中有4行*****
D. 窗口中有6行*****
[单项选择]阅读下面程序
import javax.swing.JOptionPang;
public class BreakLabelTest
public static void main (String args[])
String output=" ";
stop:
for(int row=1; row<=10; row++)
for (int column=1; column<=5; column++)
if(row==5)
break stop;
output+=¨*¨;
output+="/n";
output+= "/nLoops terminated normally";
JOptionPane.showMes sageDialog(
Null, output,"用一个标志测试break语句",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
程序运行结果是______。
A. 窗口中有5行*****
B. 窗口中有5行****
C. 窗口中有4行*****
D. 窗口中有6行*****