AWT COLOR CLASS. Introduction. Class declaration. Field

Similar documents
AWT QUADCURVE2D CLASS

AWT GRAPHICS CLASS. Introduction. Class declaration. Class constructors. Class methods

AWT CHECKBOX CLASS. Creates a check box with the specified label and sets the specified state.

AWT DIALOG CLASS. Dialog control represents a top-level window with a title and a border used to take some form of input from the user.

AWT CHOICE CLASS. Choice control is used to show pop up menu of choices. Selected choice is shown on the top of the menu.

AWT SCROLLBAR CLASS. Scrollbar control represents a scroll bar component in order to enable user to select from range of values.

AWT TEXTFIELD CLASS. Constructs a new empty text field with the specified number of columns.

AWT LIST CLASS. The List represents a list of text items. The list can be configured to that user can choose either one item or multiple items.

AWT WINDOW CLASS. The class Window is a top level window with no border and no menubar. It uses BorderLayout as default layout manager.

SWING - GROUPLAYOUT CLASS

AWT MENUBAR CLASS. Introduction. Class declaration. Class constructors. Class methods

Building Java Programs

12/22/11. } Rolling a Six-Sided Die. } Fig 6.7: Rolling a Six-Sided Die 6,000,000 Times

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Topic 8 Graphics. Margaret Hamilton

1.00 Lecture 14. Lecture Preview

Class 14: Introduction to the Swing Toolkit

Building Java Programs

Building Java Programs

Garfield AP CS. Graphics

Types of Specifications

JAVA.LANG.INTEGER CLASS

Topic 8 graphics. -mgrimes, Graphics problem report 134

Java Programming Lecture 6

GUAVA - RANGE CLASS. Range represents an interval or a sequence. It is used to get a set of numbers/ strings lying in a particular range.

Using Graphics. Building Java Programs Supplement 3G

Dr. Hikmat A. M. AbdelJaber

11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events

Chapter 12 GUI Basics

Overview. Java2D. Graphics in Java2D: Colour Images Fonts. The bigger picture of Java Graphics: Java Advanced Imaging (JAI) API Java3D

Building Java Programs

Example 3-1. Password Validation

DEMYSTIFYING PROGRAMMING: CHAPTER TEN REPETITION WITH WHILE-LOOP (TOC DETAILED)

CS/ENGRD 2110 FALL Lecture 4: The class hierarchy; static components

Inf1-OOP. Data Types. A Foundation for Programming. type value set operations. Overview. Using Data Types 1. Image Processing

Lecture 4: The class hierarchy; static components

CS Problem Solving and Object-Oriented Programming

IT101. Graphical User Interface

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API

Some classes and interfaces used in this chapter from Java s original graphics capabilities and from the Java2D API.

This guide helps you understand how operations available on the printer can be used to adjust and customize color output.

CS/ENGRD 2110 FALL2017. Lecture 4: The class hierarchy; static components

public static void main(string[] args) { GTest mywindow = new GTest(); // Title This program creates the following window and makes it visible:

Using the API: Introductory Graphics Java Programming 1 Lesson 8

Graphics and Painting

Color quality guide. Quality menu. Color quality guide. Page 1 of 6

Lecture 3: Java Graphics & Events

Lecture 5: Java Graphics

IS311 Programming Concepts J AVA. Abstract Window Toolkit. (part 2: Graphics2D)

Inf1-OOP. Data Types. A Foundation for Programming. type value set operations. Overview. Using Data Types 1. Image Processing

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Exercise NMCGJ: Animated Graphics

Graphics and Java 2D Introduction OBJECTIVES. One picture is worth ten thousand words.

Chapter 1 GUI Applications

LUCENE - TERMRANGEQUERY

GUAVA - CHARMATCHER CLASS

CS 100: Programming Assignment P1

JAVA MOCK TEST JAVA MOCK TEST III

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

Blue Pelican Computer Science AP Picture Lab

DCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming

CS/ENGRD 2110 SPRING Lecture 4: The class hierarchy; static components

GWT - UIOBJECT CLASS

ITP 140 Mobile App Technologies. Colors

Chapter 12 Advanced GUIs and Graphics

Assignment 2. Application Development

Practice Midterm 1. Problem Points Score TOTAL 50

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

LUCENE - BOOLEANQUERY

Adobe Illustrator CS Design Professional CREATING TEXT AND GRADIENTS

Part 3: Graphical User Interface (GUI) & Java Applets

Project #1 Seam Carving

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

Java Applet Basics. Life cycle of an applet:

C30c: Model-View-Controller and Writing Larger JavaFX Apps

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

GWT - TOGGLEBUTTON WIDGET

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

Java - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,

Lecture 4: The class hierarchy; static components

CompSci 230 Software Construction

COS 126 Exam 2 Review Part 1

2IS45 Programming

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

A foundation for programming. Classes and objects. Overview. Java primitive types. Primitive types Creating your own data types

Admin. CS 112 Introduction to Programming. Counting Down: Code Puzzle. Counting Down: Code Puzzle

Trident Z Royal. Royal Lighting Control Software Guide

Processing & Arduino in Tandem. Creating Your Own Digital Art Tools

Use the scantron sheet to enter the answer to questions (pages 1-6)

JAVA - FILE CLASS. The File object represents the actual file/directory on the disk. Below given is the list of constructors to create a File object

Introduction to Programming Using Java (98-388)

CLASS DESIGN. Objectives MODULE 4

Admin. CS 112 Introduction to Programming. Recap: OOP Analysis. Software Design and Reuse. Recap: OOP Analysis. Inheritance

Graphics User Defined Forms, Part I

Graphics and Java2D. Objectives

C# MOCK TEST C# MOCK TEST I

7. Program Frameworks

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

CISC 1115 (Science Section) Brooklyn College Professor Langsam. Assignment #5

Transcription:

http://www.tutorialspoint.com/awt/awt_color.htm AWT COLOR CLASS Copyright tutorialspoint.com Introduction The Color class states colors in the default srgb color space or colors in arbitrary color spaces identified by a ColorSpace. Class declaration Following is the declaration for java.awt.color class: public class Color extends Object implements Paint, Serializable Field Following are the fields for java.awt.geom.arc2d class: static Color black -- The color black. static Color BLACK -- The color black. static Color blue -- The color blue. static Color BLUE -- The color blue. static Color cyan -- The color cyan. static Color CYAN -- The color cyan. static Color DARK_GRAY -- The color dark gray. static Color darkgray -- The color dark gray. static Color gray -- The color gray. static Color GRAY -- The color gray. static Color green -- The color green. static Color GREEN -- The color green. static Color LIGHT_GRAY -- The color light gray. static Color lightgray -- The color light gray. static Color magenta -- The color magenta. static Color MAGENTA -- The color magenta. static Color orange -- The color orange. static Color ORANGE -- The color orange. static Color pink -- The color pink. static Color PINK -- The color pink. static Color red -- The color red. static Color RED -- The color red. static Color white -- The color white.

static Color WHITE -- The color white. static Color yellow -- The color yellow. static Color YELLOW -- The color yellow. Class constructors S.N. 1 Constructor & Description ColorColorSpacecspace, float[]components, floatalpha Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha. 2 Colorfloatr, floatg, floatb Creates an opaque srgb color with the specified red, green, and blue values in the range 0.0 1.0. 3 Colorfloatr, floatg, floatb, floata Creates an srgb color with the specified red, green, blue, and alpha values in the range 0.0 1.0. 4 Colorintrgb Creates an opaque srgb color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. 5 Colorintrgba, booleanhasalpha Creates an srgb color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. 6 Colorintr, intg, intb Creates an opaque srgb color with the specified red, green, and blue values in the range 0 255. 7 Colorintr, intg, intb, inta Creates an srgb color with the specified red, green, blue, and alpha values in the range 0 255. Class methods S.N. Method & Description

1 Color brighter Creates a new Color that is a brighter version of this Color. 2 PaintContext createcontext ColorModelcm, Rectangler, Rectangle2Dr2d, AffineTransformxform, RenderingHintshints Creates and returns a PaintContext used to generate a solid color pattern. 3 Color darker Creates a new Color that is a darker version of this Color. 4 static Color decodestringnm Converts a String to an integer and returns the specified opaque Color. 5 boolean equalsobjectobj Determines whether another object is equal to this Color. 6 int getalpha Returns the alpha component in the range 0-255. 7 int getblue Returns the blue component in the range 0-255 in the default srgb space. 8 static Color getcolorstringnm Finds a color in the system properties. 9 static Color getcolorstringnm, Colorv Finds a color in the system properties. 10 static Color getcolorstringnm, intv Finds a color in the system properties. 11 float[] getcolorcomponentscolorspacecspace, float[]comparray Returns a float array containing only the color components of the Color in the ColorSpace specified by the cspace parameter. 12 float[] getcolorcomponentsfloat[]comparray

Returns a float array containing only the color components of the Color, in the ColorSpace of the Color. 13 ColorSpace getcolorspace Returns the ColorSpace of this Color. 14 float[] getcomponentscolorspacecspace, float[]comparray Returns a float array containing the color and alpha components of the Color, in the ColorSpace specified by the cspace parameter. 15 float[] getcomponentsfloat[]comparray Returns a float array containing the color and alpha components of the Color, in the ColorSpace of the Color. 16 int getgreen Returns the green component in the range 0-255 in the default srgb space. 17 static Color gethsbcolorfloath, floats, floatb Creates a Color object based on the specified values for the HSB color model. 18 int getred Returns the red component in the range 0-255 in the default srgb space. 19 int getrgb Returns the RGB value representing the color in the default srgb ColorModel. 20 float[] getrgbcolorcomponentsfloat[]comparray Returns a float array containing only the color components of the Color, in the default srgb color space. 21 float[] getrgbcomponentsfloat[]comparray Returns a float array containing the color and alpha components of the Color, as represented in the default srgb color space. 22 int gettransparency Returns the transparency mode for this Color. 23 int hashcode

Computes the hash code for this Color. 24 static int HSBtoRGBfloathue, floatsaturation, floatbrightness Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model. 25 static float[] RGBtoHSBintr, intg, intb, float[]hsbvals Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model. 26 String tostring Returns a string representation of this Color. Methods inherited This class inherits methods from the following classes: java.lang.object Color Example Create the following java program using any editor of your choice in say D:/ > AWT > com > tutorialspoint > gui > AWTGraphicsDemo.java package com.tutorialspoint.gui; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; public class AWTGraphicsDemo extends Frame { public AWTGraphicsDemo(){ super("java AWT Examples"); preparegui(); public static void main(string[] args){ AWTGraphicsDemo awtgraphicsdemo = new AWTGraphicsDemo(); awtgraphicsdemo.setvisible(true); private void preparegui(){ setsize(400,400); addwindowlistener(new WindowAdapter() { public void windowclosing(windowevent windowevent){ System.exit(0); ); @Override public void paint(graphics g) { Graphics2D g2 = (Graphics2D)g; Font plainfont = new Font("Serif", Font.PLAIN, 24);

g2.setfont(plainfont); g2.setcolor(color.red); g2.drawstring("welcome to TutorialsPoint", 50, 70); g2.setcolor(color.gray); g2.drawstring("welcome to TutorialsPoint", 50, 120); Compile the program using command prompt. Go to D:/ > AWT and type the following command. D:\AWT>javac com\tutorialspoint\gui\awtgraphicsdemo.java If no error comes that means compilation is successful. Run the program using following command. D:\AWT>java com.tutorialspoint.gui.awtgraphicsdemo Verify the following output Loading [MathJax]/jax/output/HTML-CSS/jax.js