Making a qustom EnumChatFormatting Color - java

Is there a way to make a custom color with EnumChatFormatting, with rgb or hsb? Because i got a gui where i can change the menu color with red(0-255), blue, green also. Now i got the problem to insert that values to EnumChatFormatting anyone got a solution?

It depends. So if you're making a forge mod, it's possible to set the color of your custom GUIs to whatever you want. The ChatFormatting enum is already used in minecrafts code, so you can't change that easily.

Related

What are other colors i can use in java? Are these the only colors?

This question probably sounds silly but I need a serious answer. I am trying to set the background color to a dark red or maroon color. The standard colors do not include the red I need.
I have tried crimson and maroon they do not work. I looked up the java standard colors and they do not include a dark red is there away to create a dark red.
this.gamePanel.setBackground(Color.RED);
The problem is not the code it works perfectly fine. I am in need of a way to get a darker Red for the back ground if possible.
You can create a Color object using any RGB value. So you could change it to
this.gamePanel.setBackground(new Color(128, 0, 0));
or whatever RGB value fits your need. You don't have to use the predefined color instances (like RED, CYAN, BLACK, or whatever).
There are docs for the Java 8 version of the class here that show a lot of options that are available for creating different color instances.

Full table background color in swing

I'm building my Java application interface using a lot of Photoshop.
But after implementing a table it doesn't look pretty cool as you can see:
I would like to make the table as transparent as possible, so only letters are shown. I have setted all the colors to black.
Any solution?
JTable#setFillsViewportHeight would be the starting point.
Make sure that the background color of the JTable has been set accordingly

Color Combination

I have a grey image containing at least 20 different shades of gray. I would like to apply a certain color without changing it with the exception of the grey affecting the colors brightness slightly. I don't want a very drastic modification to color, only a hint. How would I go about doing this?
I'm using java, however I am more interested in the concept behind doing this.
How would I get the hsv values of a color in Java?
Don't know about HSV, but you could probably use HSL instead. Check out HSL Color for a class that does the conversion.

How to get Alternative row colours using a gridControl component

I'm currently working on redoing the GUI of a project which uses the component GridControl which is an extension of gridView, found here:
http://techpubs.borland.com/books/jbuilder/jbuilder2/jbuilder/reference/borland.jbcl.control.GridControl.html
I'm not allowed to change the components used so I have to find a way to do this with gridControl, however I'm relatively new at programming, so don't really know what I'm doing. I've been asked to get the alternative rows of the table to be grey. I can't find a specific function of the component which caters for this like JTabel seems to have so I was hoping that someone would be able to help. The only one which seems related is .setBackground which seems to only affect the full table.
Thanks very much in advance.
Check out THIS link. It has a mention of this function:
public Color getBackgroundColor(..):callback method automatically invoked by the grid to retrieve the background color for each grid's cell. A programmer can override this method to specify distinct colors for grid's cells.
If the method is not overridden, then rows are colored alternatively with two different colors: one color is defined through ClientSettings.GRID_CELL_BACKGROUND attribute and the other color is slightly different from the first one, defined through getDeltaColor() method.
now, the defaule colour values for ClientSettings.GRID_CELL_BACKGROUND is rgb (238,238,238) which is grey, and for deltaColor is rgb (235,235,235) also grey.
so, the cells should all be grey, unless there's been an override for the function public Color getBackgroundColor(..), something like this:
public Color getBackgroundColor(int row,String attributedName,Object value) {
return new Color(255,255,255); /*for all cells to be White*/
}
In order to make alternate rows grey (assuming the other color white) find the override of the above method and change its body to get your required colours, for eg:
public Color getBackgroundColor(int row,String attributedName,Object value) {
if (row%2==0)
return new Color(255,255,255); /*sets White background for even rows*/
else
return new Color(238,238,238); /*sets Grey background for odd rows*/
}
I'm relatively new at programming, so don't really know what I'm doing hmm.. there are a lot of help/examples available online. you need to learn to search intelligently and follow it up with some background theory to learn on your own.. and you'll survive (for now).

What's the best guess for "highlight color" in Java Swing?

I'm writing a program that lets people highlight surfaces by dragging the mouse. (Just like the highlighted rectangles you can do make in most operating systems on the desktop).
Trouble is, what color should I use? I don't know of any color in UIDefaults that corresponds to the highlight color. SystemColor.controlHighlight is also no good. (It's a light gray in Windows 7, not the deep blue you would expect for highlighting).
Anyone know of a way to get Swing to give me an appropriate color for highlighting at runtime?
Thanks for your help!
In the WindowsLookAndFeel class, the system color "textHighlight" defaults to blue. The comment for this color is "Text background color when selected", so it might be what you're looking for.
Duncan Jauncey has a page that lists the UIDefaults keys for many different platforms.

Categories

Resources