zoukankan      html  css  js  c++  java
  • 【Java】 GUI 在黑色背景画上随机色彩的圆圈

    import javax.swing.*;
    import java.awt.*;
    
    public class SystemUI{ 
    	
    	public SystemUI() {
    		
    		JFrame frame = new JFrame();
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setBounds(400, 300, 500, 300);
    		frame.setVisible(true);
    		
    		DrawPanel dpanel = new DrawPanel();
    		frame.add(dpanel);
    		
    	}
    	
    	public static void main(String[] args) {
    		// TODO 自动生成的方法存根
    		new SystemUI();
    		
    	}
    
    }
    
    class DrawPanel extends JPanel {
    
    	private static final long serialVersionUID = 1L;
    
    	public void paintComponent(Graphics g) {
    		
    		g.fillRect(0, 0, getWidth(), getHeight());
    		
    		int red = (int)(Math.random()*255);
    		int green = (int)(Math.random()*255);
    		int blue = (int)(Math.random()*255);
    		
    		Color randomColor = new Color(red,green,blue);
    		g.setColor(randomColor);
    		g.fillOval(70, 70, 100, 100);
    	}
    }
    

    在这里插入图片描述

  • 相关阅读:
    断棍构造过程-波利亚翁方案-中餐馆过程
    狄利克雷过程
    狄利克雷分布
    共轭先验(conjugate prior)
    镜像与文件系统
    Oracle-04
    Oracle-02
    Oracle-01
    认识数据库
    c:forEach的作用
  • 原文地址:https://www.cnblogs.com/HBU-xuhaiyang/p/12776015.html
Copyright © 2011-2022 走看看