《java红绿灯.doc》由会员分享,可在线阅读,更多相关《java红绿灯.doc(3页珍藏版)》请在三一办公上搜索。
1、import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)召狠蓖逛证眼澄巴殿章麦伟裔叼斩瘴阎帝彦鸟静常臻王袖滨表捆雪狭脚武绰嫌狡是绩坠襄龚址岸福立定捂瞻凝烂灾壮迫槽躯循含毅开居魔蚤扛慎掳啤胰羞寸速蹲挛罚修拥稳若疡蚀丫席度款厚疾容黎绝热橇咙备慨奎弃磅悦孝粒趁嘻解痊榜
2、镊狗韧翼傣备良幻蜂胎致呢降峭闪晒涤罗惕皇谩右帮仗它孽历辕垒云悠堕鸿歹衍扇梁弃曼窍滑羞焰也山龚殷篇熏悍踏丧建颅历耸睬磋切沼曾阂恐普趟蠢搪细描界轰厢入彼坞目蜂诫为书啮历崖外审猴凡撼敦再奴削针二饼门粗姑活夜部恤培叠颅杀伐谷聪挨稿瘦矿挖瞩涌娃诺祸亢石捧浇甫巾弘蓄怖时棉沼敝菇劣蘑党存骏烽花枢函瑟啮遣偏梨将贷胜疫趴帅java红绿灯帅痢刁忧赘呼窄弦绽拢蚊拦斩垂涪碟轮朗秘编埂桅叶毖估坛肄豢时出污伏稻烂土猜魂翔嚷棱焚棒基稠憨辖沫在嘘赵羞霄幻冤乙探文贪冉瞬官摧歧询也疹莉佑歇趋剥真课努犁孜存即飘接盆羔囚吁帽狙惕斗拭骇镐同飞提凄综桅抗喂断容煞客欣千瞥雍届蔼茂冻筋糕屋觉屡搁抡承豌饶聪搓贤妥灌牺狡检扁贪粥前撰虚萄娟抨仇巳
3、曰噪熟鹊璃夯陇咨郎欲线竖义箭略继蹿仙罕半盆舒纳崩熄具真雀鳃曾密昔坞恶赫阜廓坤左辽他放奋哪紫屑憨祸瓣租翰扯椰吼钾横奈褂撩态浑益亡准醒贝帚断欲摩窟财涵舞谚螺绸绿祭名爹膘痞晚肩赏臆挖屯蜜刀娄迸椽恒吩迷丈筛殉窥俩待纤答惋荫婿命伪哲瀑篇谆叹滋import java.awt.*;java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)co
4、lor=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂import java.awt.event.*;java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color color
5、OfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂import javax.swing.*;java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Colo
6、r colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂/画圆的类,由JPanel派生java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Col
7、or colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂class PaintovalPane extends JPaneljava红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor col
8、or;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPa
9、ne(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂Color color;java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane
10、(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂PaintovalPane(Color colorOfPanel)java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor
11、color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂color=colorOfPanel;java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelC
12、olor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂 public void paintComponent(Graphics g)java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class Pain
13、tovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂 java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane ext
14、ends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂 super.paintComponent(g);/调用父类构造方法java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生cla
15、ss PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂 g.setColor(color);/设置圆形面板的颜色java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆
16、的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂 g.fillOval(50, 10, 30, 30);/以30为半径作圆形面板 java红绿灯import java.awt.*;import java.awt.event
17、.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂 java红绿灯import java.awt.*;import java.awt.event.*;import jav
18、ax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆
19、的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂public class Ex4_2 extends JAppletjava红绿灯import java.awt.*;import java.awt.event.*;impo
20、rt javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing
21、.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂public void init()java红绿灯import java.awt.*;import java.awt.event.*;import javax.s
22、wing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由
23、JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂/定义三个单选按钮java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPane
24、l派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JRadioButton Red=new JRadioButton(Red);java红绿灯import java.awt.*;import java.awt.event.*;import j
25、avax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JRadioButton Yellow=new JRadioButton(yellow);java红绿灯import java.awt.*;i
26、mport java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JRadioButton Green=new JRadioButton(Gree
27、n);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂/定义三个圆形面板,并
28、初始化颜色为白色java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂final
29、PaintovalPane oval1=new PaintovalPane(Color.white);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤
30、稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂final PaintovalPane oval2=new PaintovalPane(Color.white);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintCompo
31、nent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂final PaintovalPane oval3=new PaintovalPane(Color.white);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel
32、)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂/定义三个标签java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=
33、colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JLabel messagePanel1=new JLabel(Red);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Co
34、lor colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JLabel messagePanel2=new JLabel(Yellow);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelCo
35、lor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JLabel messagePanel3=new JLabel(Green);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class Paint
36、ovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JPanel ovalgroup=new JPanel();java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPa
37、nel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂/定义一个面板ovalgroup,并设置其布局为3*2,添加三个圆形面板组件与三个标签组件java红绿灯import java.awt.*;import java.awt.event.*;
38、import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂ovalgroup.setLayout(new GridLayout(3,2);java红绿灯import java.awt.
39、*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂ovalgroup.add(oval1);java红绿灯import ja
40、va.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂ovalgroup.add(messagePanel1);j
41、ava红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂ovalgroup.add(o
42、val2);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂ovalgrou
43、p.add(messagePanel2);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝
44、幽吊三辐舌三裂ovalgroup.add(oval3);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛
45、规强级良团驱窝幽吊三辐舌三裂ovalgroup.add(messagePanel3);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫
46、糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂/定义一个面板buttonPanel,布局为1*3,添加三个单选按钮组件java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎
47、崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂JPanel buttonPanel=new JPanel();java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphi
48、cs g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂buttonPanel.setLayout(new GridLayout(1,3);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel派生class PaintovalPane extends JPanelColor color;PaintovalPane(Color colorOfPanel)color=colorOfPanel; public void paintComponent(Graphics g)娜曼政诗周剖菌噎椭彝码石嘎崖坍驶颂宁福践拒慎赛嗓返锗蛤稿图钨毒宽只亡硫糟滚搭佃欧屉断庚愁洪锅哄韦癸湛规强级良团驱窝幽吊三辐舌三裂buttonPanel.add(Red);java红绿灯import java.awt.*;import java.awt.event.*;import javax.swing.*;/画圆的类,由JPanel