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);
    	}
    }
    

    在这里插入图片描述

  • 相关阅读:
    cookie的路径
    cookie的生命
    cookie详解
    cookie简介&用途
    编码
    请求转发和重定向的区别
    request:域
    request:请求转发,请求包含
    常用的html语法
    request:获取请求的URL
  • 原文地址:https://www.cnblogs.com/HBU-xuhaiyang/p/12776015.html
Copyright © 2011-2022 走看看