开发者

Substance Look and Feel is making my colors brighter?

I'm trying to call setBackground on a JPanel, so that it matches the color of my JFrame, but the color is some how brighter than the one I type in.

I've have tried setting HSB, RGB, HEX code, they all give me the same color, a brighter version of my color.

Don't quite know how to get the color I want?

edit:

I get my colors from Photoshop. I look up the right colors (that i want) and copy the HSB RGB 开发者_C百科or HEX code. It looks as it should in Photoshop, but java gives me e brighter color?

Substance Look and Feel is making my colors brighter?

I have used the java code:

Color color = new Color(0x94b3c7); 

    jpanel.setBackground(color);


Substance is 'colorizing' your background colors to try and add some of the theme's color. If you used different skins, you would get different results. The Autumn skin, for example, would make things very orange. This can be changed on a component per component basis by setting the client property org.pushingpixels.substance.api.SubstanceLookAndFeel#COLORIZATION_FACTOR to 1.0. For example:

frame.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0)

This will instruct the background painter to use 100% of the user specified background color, rather than using 50% of the color.

This can also be set globally...

UIManager.put(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0);

again, subject to per component overrides. If not set the defaults colorization factor is 0.5.


This SSCCE shows the color in your Photoshop sample:

public class ColorTest {

    public static void main(String[] args) {
        JLabel label = new JLabel("Java Color");
        label.setFont(label.getFont().deriveFont(20f));
        label.setForeground(Color.WHITE);
        label.setBackground(new Color(0x94b3c7));
        label.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
        label.setOpaque(true);

        JPanel jpanel = new JPanel();
        jpanel.setOpaque(true);
        jpanel.add(label);
        jpanel.setBackground(Color.GREEN);

        JFrame frame = new JFrame();
        frame.setContentPane(jpanel);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

Perhaps this helps reveal to you how you should be setting the color to get what you want?

Edit: Now added explicit setting of opaque to try to solve Substance L&F problem.


So I've found the problem. It's actually kind of annoying, and I probably should have added this in the question, but I never thought that this was causing the problem.

Se im using something called Substance.api from the webpage http://www.pushing-pixels.org

Its a colorskin for the GUI, My intention was to change the color of the JFrame, but insted I changed the whole color proof.

So if someone knows how to change the JFrame Color, hawla at me! :)

This is the bandit code:

public static void main(String[] args) {

    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel());
            } catch (Exception e) {
            }
        }
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜