import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class MyScrollbar extends Applet implements AdjustmentListener
{

String[] strColor={"紅色值:", "綠色值:", "藍色值:"};
Scrollbar[] scr=new Scrollbar[strColor.length];
Label[] lbl=new Label[strColor.length];
public void init()
{
setLayout(null); //不使用版面配置
for(int i=0; i {
scr[i]=new Scrollbar(0, 255, 1, 0, 256);
scr[i].setBounds(10, 30*i, 150, 20);
lbl[i]=new Label(strColor[i]);
lbl[i].setBounds(170, 30*i, 100, 20);
scr[i].addAdjustmentListener(this);
add(lbl[i]);
add(scr[i]);
}
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
for(int i=0; i lbl[i].setText(strColor[i] + scr[i].getValue());
setBackground(new Color(scr[0].getValue(),
scr[1].getValue(),
scr[2].getValue()));
}
}
arrow
arrow
    全站熱搜

    Neo Chao 發表在 痞客邦 留言(0) 人氣()