Substance Look and Feel is making my colors brighter?
Asked Answered
S

3

14

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 or HEX code. It looks as it should in Photoshop, but java gives me e brighter color?enter image description here

I have used the java code:

Color color = new Color(0x94b3c7); 

    jpanel.setBackground(color);
Seventeenth answered 4/10, 2011 at 9:31 Comment(10)
Java makes you brighter :)Dicarlo
You need to provide an SSCCE.Katiekatina
You get an upvote for the title, but you need to provide an example (as aioobe noted) and need to tell us where you got the value from, which color you try to set and why you think it should look different from what it does. Does it have an alpha value?Lillianalillie
Thank you i will look in to SSCCESeventeenth
Interesting: when I check these colors in Gimp the Java Color is cde0ee, the Photoshop Color is 94b3c7 and 1d557a (as in the source code) is even darker (but a similar hue).Lillianalillie
Try to paste this color code somwhere else. In html page, css (look at it in browser), into some other Gimp or Paint.NET or even into Kuler and compare. You Photoshop may have some strange color space set or something like this. Pick the color from your rendered JFrame with some screen color picker and check the HEX color.Seltzer
Thanks will check it out, On Joachim's answer: It's my bad I edited the wrong HEX code in my question, I use the 94b3c7 for java, its the HEX i get from photoshop. Could it have anything to do with my Panel? shouldn't int be on top? Its a panel that's added to a contentPane.Seventeenth
could it be that your photoshop is set to a different color proof than your monitor?Vd
Are You running Windows by any chance?Shepard
Yes im running Windows, that has hardly anything to do with the solution.Seventeenth
D
11

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.

Duarte answered 6/10, 2011 at 15:28 Comment(1)
Great! Will test it right away, the closest i will get to an answer on this question i think.Seventeenth
E
6

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.

Edmonson answered 4/10, 2011 at 11:44 Comment(3)
Great! I've tried your code, and i got the correct color. It took a bit scouting in my code but i think i found the problem. Im using a skin for my JFrame: import org.pushingpixels.substance.api.skin.SubstanceBusinessBlueSteelLookAndFeel;Seventeenth
And when i don't use the better looking JFrame it works, but then I don't need it to work. In not happy with the truth :(Seventeenth
This could be an "opaque" problem. I've modified my sample code to include setting opaque to true on both the JPanel and the JLabel. The panel should now be green, with the label the desired color (0x94b3c7)Edmonson
S
3

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) {
            }
        }
    });
}
Seventeenth answered 4/10, 2011 at 19:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.