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
setBackground(new Color(scr[0].getValue(),
scr[1].getValue(),
scr[2].getValue()));
}
}
- May 23 Wed 2007 21:38
<Java-基礎>AWT-使用Scrollbar
close
全站熱搜
留言列表