• 会变色的文字


    public class paint extends JFrame{
    public paint(){

    setLocation(0, 0);
    setSize(400, 400);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container con=getContentPane();
    // con.setLayout(new BorderLayout());
    draw dra=new draw();
    con.add(dra);


    // con.add(new button(),BorderLayout.SOUTH);



    }


    public static void main(String args[]){
    paint pai=new paint();
    Container con=pai.getContentPane();
    // con.setLayout(new BorderLayout());
    draw dra=new draw();
    con.add(dra);
    pai.setVisible(true);
    Thread th=new Thread(dra);
    th.start();


    }
    }
    class draw extends JPanel implements Runnable{


    Color color;
    @Override
    public void paint(Graphics g) {
    // TODO 自动生成的方法存根
    Graphics2D g2=(Graphics2D)g;

    int x=100;
    int y=100;
    String str=new String("mafeng");

    Font font =new Font("华文行楷",Font.BOLD,72);
    g2.setFont(font);

    g2.setColor(color);

    g2.drawString(str, x, y);
    System.out.println("456");
    }
    public void run(){
    Random ran=new Random();
    while(true){
    int r=ran.nextInt(256);
    int g=ran.nextInt(256);
    int b=ran.nextInt(256);
    color=new Color(r, g, b);
    repaint();
    System.out.println("123");
    try{
    Thread.sleep(1000);

    }catch(InterruptedException e){
    e.printStackTrace();
    }
    }


    }
    }

  • 相关阅读:
    域名系统
    DNS域名解析过程
    服务器常用的状态码
    重绘与重排及它的性能优化
    console.time和console.timeEnd用法
    用CSS开启硬件加速来提高网站性能
    公钥和私钥
    svn conflict 冲突解决
    svn分支开发与主干合并(branch & merge)
    源生js惯性滚动与回弹效果
  • 原文地址:https://www.cnblogs.com/mafeng/p/4461442.html
Copyright © 2020-2023  润新知