JW_*_*JW_ 6 java rgb swing hex setbackground
搜索谷歌半小时后,我放弃了!:)
在我设置的JFrame上,我有一个带有一些gui的程序,
setBackground( new Color(107, 106, 104) );
Run Code Online (Sandbox Code Playgroud)
[问题]它呈现出灰色,但不是正确的颜色!如果我在Photo Shop中检查gui的颜色,它会给我RGB值(126,125,123)
我真的很沮丧..有人有同样的问题吗?
PS.我尝试过HEX值,结果相同.
最好的问候,Juri
I have a program with some gui, on the JFrame I set,
setBackground( new Color(107, 106, 104) );
[The problem] It gives a greyish color, but not the right one!
If I check the gui's color in Photo Shop, it gives me the RGB
values (126, 125, 123)
Run Code Online (Sandbox Code Playgroud)
你无法设置setBackground,例如JFrame,这只能ContentPane用于
JFrame#getContentPane.setBackground(new Color(107, 106, 104));
Run Code Online (Sandbox Code Playgroud)
编辑

来自代码
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class Check extends JFrame {
private static final long serialVersionUID = 1L;
public void makeUI() {
JFrame f = new JFrame();
f.getContentPane().setBackground(new Color(107, 106, 104));
f.setDefaultCloseOperation(EXIT_ON_CLOSE);
f.setSize(new Dimension(300, 200));
f.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new Check().makeUI();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
75909 次 |
| 最近记录: |