TAILIEUCHUNG - Java Programming for absolute beginner- P20

Java Programming for absolute beginner- P20:Hello and welcome to Java Programming for the Absolute Beginner. You probably already have a good understanding of how to use your computer. These days it’s hard to find someone who doesn’t, given the importance of computers in today’s world. Learning to control your computer intimately is what will separate you from the pack! By reading this book, you learn how to accomplish just that through the magic of programming. | 2 25 03 8 55 AM Page 338 Table Color Methods Method Description Color int r int g int b Constructs a Color object with the given red green and blue values that range from 0-255. Color int r int g int b int a Color brighter Color darker int getAlpha int getBlue int getGreen int getRed V Constructs a Color object with the given red green blue and alpha values which range from 0-255. Returns a brighter version of this Color. Returns a darker version of this Color. Returns the alpha value of this Color. Returns the blue value of this Color. Returns the green value of this Color. Returns the red value of this Color. Java Programming for the Absolute Beginner on which button you press. The canvas will change color accordingly. Here is the source code for the result can be seen in Figure . ColorTest Demonstrates the Color class import . import . public class ColorTest extends GUIFrame Canvas palette Button bright dark public final static int MIN 0 MAX 255 public ColorTest int r int g int b super Color Test r r MIN r MAX r MIN g g MIN g MAX g MIN b r MIN b MAX b MIN palette new Canvas new Color r g b 200 150 add palette Panel controlPanel new Panel new GridLayout 1 0 bright new Button Brighter team Line - live informative Nan-cast and Genuine Please purchase PDF Split-Merge on to remove this watermark. 2 25 03 8 55 AM Page 339 new ActionListener public void actionPerformed ActionEvent e Color c .brighter c bright dark new Button Darker new ActionListener public void actionPerformed ActionEvent e Color c .darker c dark add controlPanel pack setVisible true public static void main String args if

TỪ KHÓA LIÊN QUAN