您好,欢迎访问三七文档
当前位置:首页 > 办公文档 > 求职简历 > 浪漫告白程序(Java)
importjava.awt.*;importjavax.swing.*;publicclassILoveYou{publicstaticvoidmain(Stringargs[]){JFramew=newJFrame();w.setSize(1366,768);w.setBackground(Color.BLACK);MyPanelmp=newMyPanel();mp.setBackground(Color.BLACK);w.add(mp);Threadt=newThread(mp);t.start();w.show();}}classMyPanelextendsJPanelimplementsRunnable{finalintlen=400;publicvoidpaint(Graphicsg){g.setColor(Color.WHITE);for(inti=0;ilen;i++){g.drawString(*,(int)(Math.random()*1366),(int)(Math.random()*768));}g.setColor(Color.BLACK);Fontf=newFont(宋体,Font.BOLD,40);g.setFont(f);g.drawString(我爱你,不是说说而已,450,600);intx1[]={800,770,850,750,830};inty1[]={60,160,100,100,160};g.setColor(Color.BLACK);g.fillPolygon(x1,y1,x1.length);intx2[]={600,570,650,550,630};inty2[]={300,400,340,340,400};g.setColor(Color.BLACK);g.fillPolygon(x2,y2,x2.length);intx3[]={60,30,110,10,90};inty3[]={60,160,100,100,160};g.setColor(Color.BLACK);g.fillPolygon(x3,y3,x3.length);intx4[]={1300,1270,1350,1250,1330};inty4[]={300,400,340,340,400};g.setColor(Color.BLACK);g.fillPolygon(x4,y4,x4.length);}@Overridepublicvoidrun(){//TODOAuto-generatedmethodstubwhile(true){try{Thread.sleep(40);}catch(Exceptione){}repaint();}}}
本文标题:浪漫告白程序(Java)
链接地址:https://www.777doc.com/doc-2233841 .html