1、w.setSize(1366,768);w.setBackground(Color.BLACK);MyPanel mp=new MyPanel();mp.setBackground(Color.BLACK);w.add(mp);Thread t=new Thread(mp);t.start();w.show();class MyPanel extends JPanel implements Runnablefinal int len=400;public void paint(Graphics g)g.setColor(Color.WHITE);for(int i=0;ilen;i+)g.dr
2、awString(*,(int)(Math.random()*1366),(int)(Math.random()*768);g.setColor(Color.BLACK);Font f=new Font(宋体,Font.BOLD,40);g.setFont(f);g.drawString(我爱你,不是说说而已,450,600);int x1=800,770,850,750,830;int y1=60,160,100,100,160;g.fillPolygon(x1, y1, x1.length);int x2=600,570,650,550,630;int y2=300,400,340,340
3、,400;g.fillPolygon(x2, y2, x2.length);int x3=60,30,110,10,90;int y3=60,160,100,100,160;g.fillPolygon(x3, y3, x3.length);int x4=1300,1270,1350,1250,1330;int y4=300,400,340,340,400;g.fillPolygon(x4, y4, x4.length);Overridepublic void run() / TODO Auto-generated method stubwhile(true)tryThread.sleep(40);catch(Exception e)repaint();