g.setColor(Color.green); After you set the current color, all drawing operations will occur in that color. Color can be controlled by accessing the Using the superimposition of RGB, we can represent 255*255*255 different colors. public void paintComponent(Graphics g) {} The parameter g is a Graphics object. The argument for paintComponent() is a type Graphics which is from java.awt.Graphics:.  g.setColor (Color.orange); The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0 - 1.0 or 0 - 255. Thanks. Green c. Yellow d. Cyan Some of them can be also used in national languages and are listed below. Color myNewBlue = new Color (R, G, B);   g.drawLine(50, 50, 150, 50); This segment of code will print Color object can be passed in 2 ways 1. Version: 4.04, 2016/08/17 (to accompany BJP 4th edition). static Color BLACK -- The color black. public abstract void drawString(String str, int x, int y): is used to shit the included string. import java.applet.Applet; import java.awt.Graphics; import java.awt.Color; public class Javaapp extends Applet { public void paint(Graphics g) { g.setColor(Color.PINK); g.fillOval(20, 20, 100, 100); g.setColor(Color.blue); g.fillOval(150, 20, 50, 100); g.setColor(Color.red); g.drawOval(20, 140, 100, 100); g.setColor(Color.MAGENTA); g.drawOval(40, 140, 60, 100); g.setColor(Color.ORANGE); … What color is the line? Now the outline of the rectangle is drawn in red color. WOW! Create your new color by using the following code. getGreen (), color. La méthode pack() agit en étroite collaboration avec le layout manager et permet à chaque contrôle de garder, dans un premier temps sa taille optimale. Creates a color in the color space of the supplied ColorSpace with the color components specified in the float array and the specified alpha. Alpha is defaulted to 1.0. You may check out the related API usage on the sidebar. The argument for paintComponent() is a type Graphics which is from java.awt.Graphics:. line in orange. colors in this scheme. *; import ij.util. Browse. . an English color name (see Reference:Colors). Terms Exercise - answer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. The Color can be used to draw or fill shapes on the screen. Java Graphics.setColor(Color c) Syntax. dmiga asked on 2004-02-03. the class constants shown in the table below. Color.red gives the Color /*. Dissecting the Program. Access the PAINT program on your The color black has an English color name (see Reference:Colors). Graphics: clipRect(int x, int y, int width, int height), Graphics: draw3DRect(int x, int y, int width, int height, boolean raised), Graphics: drawArc(int x, int y, int width, int height, int startAngle, int arcAngle), Graphics: drawBytes(byte[] data,int offset,int length,int x,int y), Graphics: drawChars(char[] data, int offset, int length, int x, int y), Graphics: drawImage(Image img, int x, int y, ImageObserver ob), Graphics: drawLine(int x1, int y1, int x2, int y2), Graphics: drawRoundRect(int x,int y,int width,int height,int arcWidth,int arcHeight), Graphics: drawOval(int x, int y, int width, int height), Graphics: drawPolygon(int[] xPoints, int[] yPoints, int nPoints), Graphics: drawPolyline(int[] xPoints,int[] yPoints,int nPoints), Graphics: drawRect(int x, int y, int width, int height), Graphics: drawString(String str, int x, int y), Graphics: fillArc(int x, int y, int width, int height, int startAngle, int arcAngle), Graphics: fill3DRect(int x, int y, int width, int height, boolean raised), Graphics: fillOval(int x, int y, int width, int height), Graphics: fillPolygon(int[] xPoints, int[] yPoints, int nPoints), Graphics: fillRect(int x, int y, int width, int height), Graphics: fillRoundRect(int x,int y,int width,int height,int arcWidth,int arcHeight), Graphics: setClip(int x, int y, int width, int height).