本题的功能是用按钮来控制文字的颜色。窗口中有三个按钮“Yellow”、“Blue”和

题型:问答题

问题:

本题的功能是用按钮来控制文字的颜色。窗口中有三个按钮“Yellow”、“Blue”和“Red”,它们分别对应文字标签中文本的颜色为黄色、蓝色和红色,单击任意一个按钮,文字标签中的文本就变成按钮对应的颜色。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ButtonPanel extends JPanel implements ActionListener
public ButtonPanel()
yellowButton=new JButton("Yellow");
blueButton=new JButton("Blue");
redButton=new JButton("Red");
j1=new JLabel("I am from China!");
add(yellowButton);
add(blueButton);
add(redButton);
add(j1);
yellowButton.addActionListener(this);
blueButton.addActionListener(this);
redButton.addActionListener(this);

public void actionPerformed(ActionEvent evt)
Object source=evt.getSource();
Color color=getForcground();
if(source==yellowButton)color=Color.yellow;
else if(source==blueButton)color=Color.blue;
else if(source==redButton)color=Color.red;
______;
______;

private JButton yellowButton;
private JButton blueButton;
private JButton redButton;
private JLabel j1;

class ButtonFrame extends JFrame
public ButtonFrame()
setTitle("exam 16");
setSize(300,200);
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);

);
Container contentPane=getContentPane();
contentPane.add(new ButtonPanel());


public class java2
public static void main(String[]args)
JFrame frame=new ButtonFrame();
frame.show();

考点:计算机等级考试JAVA二级JAVA机试
题型:问答题

1标准大气压约等于__________m高水银柱产生的压强,其值约为_________ Pa。

题型:问答题

某大医院一位眼科博士,因急于为两位病人进行角膜移植,而又一时找不到现成的供体角膜,所以在太平间"盗取"了一病死者的尸体角膜用于移植,获得成功。此事后被死者家属发现,以未经本人生前及死者家属知情同意,严重损害了死者及其家属的权益为由,将该医生告上了法庭。经调查得知:接受眼角膜移植手术的两位病人与该医师无特殊关系;死者生前与该医师无利害冲突;该医师也未由此谋取分文私利,只是不了解有关要求。

对该医师的正确医德评价应为()

A.符合医德要求

B.不符合医德要求

C.说不清

D.不能进行医德评判

E.以上都不对

题型:问答题

一位人民代表说的好:每个人都要尊重自己的权利和义务。作为人民代表,不能只是“张张口,举举手”。这位代表之所以这样讲,是因为他认识到人民代表应该:

A.履行政府赋予的权利和义务

B.直接行使立法权和监督权

C.履行宪法赋予的权利和义务

D.直接行使国家最高权力

题型:问答题

在现有的产品类别中增加新的产品项目,并以同样的品牌名称推出,是()战略。

A.品牌延伸

B.多品牌

C.新品牌

D.产品线扩展

题型:问答题

冷凝器真空低的原因有()。

A.冷凝器有漏点

B.抽气器故障

C.冷却水量不足或中断

D.排汽压力温度升高

更多题库