java - 如何在java中定义可定制的RGB背景颜色?

标签 java colors background jframe

我是java新手,我已经在Google上搜索答案有一段时间了,但是我找不到获取RGB背景颜色的方法,我只能找到如何从主颜色设置背景颜色由java提供(例如,“Color.BLACK”)。我正在使用 JFrame。请帮忙。谢谢。这是我的后台代码。

    public void paintComponent(Graphics g){
        super.paintComponent(g);

        this.setBackground(Color.PINK); //My current background colour code but I am looking to use a customisable RGB one.

        g.setColor(Color.BLACK);
        g.fillRect(0, 0, 40, y);

        tm.start();
    }

最佳答案

你可以改变

    this.setBackground(Color.PINK);

    this.setBackground(new Color());//Put RGB number in the empty parenthesis

关于java - 如何在java中定义可定制的RGB背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43193531/

相关文章:

ios - 从另一个类访问 UI 控件

java - 为什么此代码会错误地报告我的 Android 设备上的可用空间?

java - 如何在主 UI 线程之外运行 TimerTask?

css - 为 div 中的像素着色

python - 如何获得 Pandas 数据框或系列图中使用的标准颜色?

javascript - 更改 Google 饼图下一页指示器的颜色

html - 在 CSS 中隐藏部分边框?

Java 'SyncServer' 允许两个用户同时编辑一个字符串变量

Java:不区分大小写的枚举 Jersey 查询参数绑定(bind)

html5和css3视频背景