Skip to Content

Set Graphics Color Example

  • strict warning: Non-static method view::load() should not be called statically in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/views.module on line 906.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_argument.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter_boolean_operator.inc on line 0.
  • strict warning: Declaration of views_plugin_style_default::options() should be compatible with views_object::options() in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_style_default.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.

  1. /*
  2.         Set Graphics Color Example
  3.         This java example shows how to set graphics color using Java AWT Color class.
  4. */
  5.  
  6. import java.applet.Applet;
  7. import java.awt.Color;
  8. import java.awt.Graphics;
  9.  
  10.  
  11. /*
  12. <applet code="SetGraphicsColorExample" width=200 height=100>
  13. </applet>
  14. */
  15.  
  16.  
  17. public class SetGraphicsColorExample extends Applet{
  18.  
  19.         public void paint(Graphics g) {
  20.                 /*
  21.                  * Graphic objects like lines and rectangles uses current
  22.                  * foreground color.
  23.                  *
  24.                  * To change the current graphic color use
  25.                  * void setColor(Color c) method of Graphics Class.
  26.                  */
  27.                
  28.                 //this will create light blue color
  29.                 Color customColor = new Color(10,10,255);
  30.                
  31.                 g.setColor(customColor);
  32.                 g.drawLine(10,10,30,30);
  33.                
  34.                 g.setColor(Color.red);
  35.                 g.fillRect(40,40,40,40);
  36.                
  37.                 g.setColor(Color.green);
  38.                 g.fillRect(80,80,40,40);
  39.                
  40.                 g.draw3DRect(81,81,40,40,true);
  41.                
  42.         }
  43. }

Example Output