⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colorpanel.java

📁 color panel is a simple tool to help you to creat a color panel
💻 JAVA
字号:
package herbTool;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.geom.*;
public class colorPanel extends JPanel
    {
        private Color sc;
        private Color ec;
        private int xax;
        private int yax;
        public colorPanel(Color s,Color e, int x, int y)
        {
            sc = s;
            ec = e;
            xax = x;
            yax = y;
        }
        public void paintComponent(Graphics g)
        {
            Graphics2D g2 = (Graphics2D) g;
            drawShapes(g2);
        }
        public void drawShapes(Graphics2D g2)
        {
            int gridWidth = 400;
            int gridHeight = 300 / 2;
         
            int rowspacing = 5;
            int columnspacing = 7;
            int rectWidth = gridWidth - columnspacing;
            int rectHeight = gridHeight - rowspacing;
            int x = 0;
            int y = 0;
            // fill RoundRectangle2D.Double
            GradientPaint redtowhite;
            redtowhite = new GradientPaint(x,y,sc,xax,yax,ec);
            g2.setPaint(redtowhite);
            g2.fill(new RoundRectangle2D.Double(x, y, xax,
                                        xax, 10, 10));
            g2.setPaint(Color.black);
            x += gridWidth;
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -