【说明】 本程序通过移动滑动条修改颜色RGB值,从而控制颜色。程序中有一个面板、3

题型:问答题

问题:

【说明】
本程序通过移动滑动条修改颜色RGB值,从而控制颜色。程序中有一个面板、3个标签和3个滑动条,标签和滑动条一一对应,分别对应三原色红、绿、蓝,任意拖动其中的一个滑动条,所对应的颜色值就会发生变化,面板的颜色也会发生对应的变化,如下图所示,滑动条值的范围是0~255。


【Java代码】
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class simple extends JFrame implements AdjustmentListener
public simple()
setTitle("simple");
setSize(300, 200);
addWindowListener(new WindowAdapter()
public void windowClosing( (1) )
System.exit(0);

);
Container contentPane=getContentPane();
JPanel p= (2) ;
p.setLayout(new GridLayout(3, 2));
p.add(redLabel=new JLabel("Red 0"));
p.add(red=new JScrollBar(Adjustable. HORIZONTAL, 0, 0, 0, 255));
red.setBlocklncrement(16);
red.addAdjustmentListener(this);
p.add(greenLabel= (3) ("Green 0"));
p.add(green=new JScrollBar(Adjustable.HORIZONTAL 0, 0, 0, 255));
green setBIocklncrement(16);
green.addAdjustmentListener(this);
p.add(blueLabel=new JLabel("Blue 0"));
p.add(btue=new JScrollBar(Adjustable. HORIZONTAL, 0, 0, 0, 255));
blue,setBIocklncrement(16);
blue.addAdjustmentListener(this);
contentPane.add(p, "South");
colorPanet=new JPanel();
colorPanet.setBackground(new Color(0, 0, 0));
contentPane.add( (4) ,"Center");
public void adjustmentValueChanged(AdjustmentEvent evt)
redLabel.setText("Red"+red.getValue());
greenLabel.setText("Green"+green.getValue());
blueLabel.setText("Blue"+blue.getValue());
coiorPanel.setBackground(new Color(red.getValue(), green.getValue(), blue.getValue()));
colorPanel.repaint();

public static void main(String[] args)
JFrame f= (5) ;
f.show();

private JLabel redLabel;
private JLabel greenLabel;
private JLabel blueLabel;
private JScrollBar red;
private JScroilBar green;
private JScrollBar blue;
private JPanel colorPanel;

考点:计算机软件水平考试初级程序员初级程序员下午试题
题型:问答题
—Mary wants to know if _____ a picnic at weekend.
—Yes. But if it _____, we'll see a film instead.

A. you have; will rain
B. you will have; rains
C. you will have; will rain
D. will you have; rains
题型:问答题

图为“嫦娥一号”月球探测器飞行路线示意图。

(1)在探测器飞离地球的过程中,地球对它的引力_________;(选填“增大”、“减小”或“不变”)

(2)已知月球与地球质量之比为M:M=1:81。当探测器飞至月地连线上某点P时,月球与地球对它的引力恰好抵消,此时P到月球球心与地球球心的距离之比为_________。

题型:问答题

一节课既有检查复习,又有新知识的讲授和巩固关系,这节课就属于综合课。(  )

题型:问答题

冷却构筑物形式很多,大体分为______。

A.水面冷却池

B.喷水冷却池

C.冷却塔

D.水塔

题型:问答题

个人类业务用信基本流程:()

A、签订合同

B、贷款发放

C、贷款支付

D、调查

更多题库