Skip to content
Advertisement

Tag: colors

How to change JFreeChart vertical bar to a solid color?

I have the following sample code for a JFreeChart, how to change the vertical bars to a solid color [ right now it has some white color in each bar ] ? Answer As shown here, use a StandardXYBarPainter to get a flat effect instead of the default gradient. I tried, but didn’t work: renderer2.setDefaultBarPainter(new StandardXYBarPainter()). Note that XYBarRenderer.setDefaultBarPainter() is

How to convert RGB color to grayscale in Java

I’m trying to create a method that converts a given java.awt.Color color to grayscale. Here’s what I have right now: However, when I call this method, it seems to be returning the color black every single time, regardless of the input color. How do I fix this? Answer The float components are in the range of [0.0, 1.0]. You are

Java: How got check colors from an invisible panel

is it possible to read colors of you mouse position of an invisible panel? I want to have an “invisible overlay” with an color coded image. I used the Robot class to get my mouse position and the color. It works fine on my visible image, but if I set the image to invisible, it completely gets ignored. Is there

How do I change the background color of a JFrame dynamically?

I was wondering how would I change this block of code to be able to have a dynamically changing background colour that switches from (red -> black -> green -> black -> blue -> black ->red) and the loop starts again. The background colour should be continuously changing per tick. Right now I have a render method that will continuously

Java Graphics Invert Color Composite

Basically what I want to do is make a cursor for a JComponent that’s pixels appear as the inverse of the color they are over. For example, take your mouse and hover it over the letters in the url for this page. If you look closely, the pixels of the cursor that are over black pixels of a letter turn

Convert RGB values to color name

How can I convert a color in RGB format into a color name? Examples: (0, 0, 255) -> “blue” (255, 0, 0) -> “red” (128, 128, 128) -> “grey” Answer Populate a list of “known” colors. For each known color compute: Return the name of colorI for which rgbDistance was smallest.

Compute hex color code for an arbitrary string

Heading Is there a way to map an arbitrary string to a HEX COLOR code. I tried to compute the HEX number for string using string hashcode. Now I need to convert this hex number to six digits which are in HEX color code range. Any suggestions ? Answer If you don’t really care about the “meaning” of the color

Advertisement