The Color class Assignment Help

Assignment Help: >> Fonts and colour >> The Color class

The Color class

The Color class (note the spelling) encapsulates RGB colours, where RGB stands for red, green and blue. The RGB values allow us to create a huge range of colours because all colours can be created from a combination of the three primary colours - red, green and blue. The RGB system allows you to define a particular colour by specifying either three integer values between 0 and 255 or three fioating-point numbers in the range of 0.0 to 1.0. The value 255 is used simply to allow each value to be stored as an 8-bit byte. If we choose 0, 0, 0 (or 0.0, 0.0, 0.0) then the colour is black; if we choose 255, 255, 255 (or 1.0, 1.0, 1.0) then the colour is white. The colours are used to define the appearance of text, graphics primitives and graphical user interface components. To create a Color, there are several constructors that are supported, as shown in Table.

306_color class.png

So, for example, to create a colour where all three colours are set to 100, we can write the following statement:

Color myColor = new Color(100, 100, 100);

This results in myColor referring to some dark grey colour. However, most of the time there is no need to define colours with such precision and so the Color class defines a number of standard colours for general use. The range of colours is black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white and yellow. To use one of these predefined colours, for example green, use the following statement:

Color myColor = Color.green;

 

These predefined colours can be found in the class java.awt.Color. Once you have defined a colour, you can use it in your interface code. For example:

public void paintComponent (Graphics g)
{
Color myColor = Color.green; g.setColor(myColor);

g.fillRect(50, 50, 100, 100);
}

Once a colour has been set, any subsequent operations are performed using this colour. Consequently, it makes sense to group together the operations that require the same colours and fonts in your code in order to avoid switching more than you really need to. When using colour in your interface, remember that Java colour support is not device­ independent, and some colours will look different on a range of client machines.

 

Java Assignment Help - Java Homework Help

Struggling with java programming language? Are you not finding solution for your The Color class homework and assignments? Live The Color class experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer The Color class homework help, java assignment help and The Color class projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.

Why Expertsmind for assignment help

  1. Higher degree holder and experienced experts network
  2. Punctuality and responsibility of work
  3. Quality solution with 100% plagiarism free answers
  4. Time on Delivery
  5. Privacy of information and details
  6. Excellence in solving java programming language queries in excels and word format.
  7. Best tutoring assistance 24x7 hours

 

 

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd