Java程序设计附录_实训参考答案(8)

2018-11-21 22:43

Java语言程序设计基础

public class T17_4 extends Frame implements AdjustmentListener{ Scrollbar red,green,blue; TextArea textArea1=new TextArea(\测试区域\

Panel p1,p2,p3; Panel p;

public T17_4(){ super(\调整事件示例\

p=new Panel(); p1=new Panel(); p2=new Panel(); p3=new Panel();

p.setLayout(new GridLayout(3,1,5,5)); p1.setLayout(new GridLayout(1,1,20,10)); p2.setLayout(new GridLayout(1,1,20,10)); p3.setLayout(new GridLayout(1,1,20,10));

red=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255); green=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255); blue=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255); p1.add(red); p2.add(green); p3.add(blue); p.add(p1); p.add(p2); p.add(p3);

textArea1.setBackground(new Color(0,0,0)); add(textArea1,BorderLayout.NORTH); add(p,BorderLayout.CENTER); red.addAdjustmentListener(this); green.addAdjustmentListener(this); blue.addAdjustmentListener(this);

addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0);

294

附录 实训参考答案

}

}

} });

setSize(400,300);

//implementation of AdjustmentListener

public void adjustmentValueChanged(AdjustmentEvent e){ int r=red.getValue(); int g=green.getValue(); int b=blue.getValue(); textArea1.setBackground(new Color(r,g,b)); }

public static void main(String[] args){ new T17_4().setVisible(true); }

295


Java程序设计附录_实训参考答案(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:AAWT_report_Geely_2010.05.10

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: