读下列程序 import java.awt.*; import java.awt.event.*; publid class MyApplet
A、import shiffman.box2d.*;
B、import org.jbox2d.collision.shapes.*;
C、import org.jbox2d.common.*;
D、import processing.opengl.*;
阅读下列程序,请写出程序的运行结果。
import java.applet.*;
import javax.swing.*;
import java.awt.event.*;
public class C extends Applet implements ActionListener
{
int n=0;
JButton button;
public void init()
{
setSize(400,100);
button=new JButton("");
add(button);
button.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
n++;
button.setText(n+"");
}
}
A.importjava.sql.*
B.importjava.util.*
C.importjava.io.*
D.importjava.net.*
阅读下列程序,请写出该程序的功能。
import java.awt.*;
import javax.swing.*;
public class Class32
{public static void main(String[] args)
{
JFrame. frame=new JFrame("登录对话框");
TextField id=new TextField(12);
TextField pw=new TextField(12);
JButton login=new JButton("登录");
JButton cancel=new JButton("取消");
pw.setEchoChar('*');
frame.setLayout(new GridLayout(3,2));
frame.add(new JLabel("ID:",JLabel.RIGHT));
frame.add(id);
frame.add(new JLabel("密码:",JLabel.CENTER));
frame.add(pw);
frame.add(login);
frame.add(cancel);
frame.pack();
frame.setVisible(true);
}
}
下列Applet在坐标(20,20)处显示一幅GIF图像,请填写正确的程序在横线处。 import java.awt.*; import java.applet.*; import java.net.URL; public class Testl3 extends Applet { Image i; public void init() { URL url=getDocumentBase(); String name="IMG nClick=over(this) title=放大0, gif"; 【 】; } public void paint(Graphics g) { g.drawImage(i,20,20,this); } }
阅读下列程序,写出程序功能。
import j ava. awt. *;
import j avax. swing. *;
import j ava. awt. event. *;
public class C3401 implements ActionListener
{
JFrame. frmFrame;
JButton btnUp, btnDown;
public C3401()
{
frmFrame=new JFrame("按钮应用") ;
frmFrame. setLayout(new CridLayout(2, 1) ) ;
btnUp=new JButton("上") ;
btnUp. setActionCommand("btnUp") ;
btnUp. addActionListener(this) ;
btnDown=new JButton("下") ;
btnDown. setActionCommand("btnDown") ;
btnDown. addActionListener(this) ;
frmFrame. add(btnUp) ;
frmFrame. add(btnDown) ;
frmFrame. pack() ;
frmFrame. setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
String cmd=e. getActionCommand() ;
if(cmd. equals("btnDown")
if(btnUp. getBackground() ==Color. BLUE.
btnUp. setBackground(Color. red) ;
else
btnUp. setBackground(Color. blue) ;
else
if(btnDown. getBackground() ==Color. BLUE.
btnDown. setBackground (Color. red) ;
else
btnDown. setBackground(Color. blue) ;
}
public static void main(String[] args)
{
new C3401() ;
}
}
阅读下列程序,写出程序运行结果。
import j ava. util. StringTokenizer;
public class C3301
{
public static void main(String[] args)
{
String ss="public static void main";
StringTokenizer pas=new StringTokenizer(ss, " ") ;
int n=pas. countTokens() ;
System. out. println(n) ;
String s=pas. nextToken() ;
for(pas. nextToken() ; pas. hasMorcTokens() ; s=pas. nextToken()
System. out. println(s) ;
}
}
A.import jav
B.awt.
C.package mypackage
D.class OtherClass{ }
E.public class MyClass{ }