浪漫告白程序(Java)

2022-05-19 12:22:15   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《浪漫告白程序(Java)》,欢迎阅读!
告白,程序,浪漫,Java
浪漫告白程序(Java)

import java.awt.*;

import javax.swing.*;

public class ILoveYou { public static void main(String args[]){ JFrame w=new JFrame(); 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 Runnable{ final int len=400; public void paint(Graphics g){ g.setColor(Color.WHITE); for(int i=0;i g.drawString("*",(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.setColor(Color.BLACK); g.fillPolygon(x1, y1, x1.length); int x2[]={600,570,650,550,630}; int y2[]={300,400,340,340,400}; g.setColor(Color.BLACK); g.fillPolygon(x2, y2, x2.length);

1 / 2


浪漫告白程序(Java)

}

int x3[]={60,30,110,10,90}; int y3[]={60,160,100,100,160}; g.setColor(Color.BLACK); g.fillPolygon(x3, y3, x3.length); int x4[]={1300,1270,1350,1250,1330}; int y4[]={300,400,340,340,400}; g.setColor(Color.BLACK); g.fillPolygon(x4, y4, x4.length); }

@Override

public void run() { // TODO Auto-generated method stub while(true){ try{Thread.sleep(40);} catch(Exception e){} repaint(); } }

2 / 2


本文来源:https://www.wddqxz.cn/97836208a48da0116c175f0e7cd184254a351b2e.html

相关推荐