1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* Get Darker Version Of Current Color Example This java example shows how to get darker version of current color using Java AWT Color class. */ import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; /* <applet code="GetDarkerColor" width=200 height=100> </applet> */ public class GetDarkerColor extends Applet{ public void paint(Graphics g){ //create a custom color using RGB Color customColor = new Color(255,10,10); /* * To get Darker version of current color, use * Color darker() * method of AWT Color class. */ Color darkerColor = customColor.darker(); this.setForeground(darkerColor); g.drawString("Darker Color", 80, 10); } } |
Example Output
Add Comment