我是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/