Skip to Content

Draw 3D Rectangle & Square in Applet Window 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.         Draw 3D Rectangle & Square in Applet Window Example
  3.         This java example shows how to draw 3-D rectangles and squares in an applet
  4.         window using draw3DRect method of Graphics class. It also shows how to
  5.         draw a filled 3-D rectangles and squares.
  6. */
  7.  
  8. /*
  9. <applet code="Draw3DRectanglesExample" width=200 height=200>
  10. </applet>
  11. */
  12.  
  13.  
  14. import java.applet.Applet;
  15. import java.awt.Color;
  16. import java.awt.Graphics;
  17.  
  18. public class Draw3DRectanglesExample extends Applet{
  19.  
  20.         public void paint(Graphics g){
  21.                
  22.                 g.setColor(Color.green);
  23.                 /*
  24.                  * To draw a 3-D rectangle in an applet window use,
  25.                  * void draw3DRect(int x1,int y1, int width, int height, boolean raised)
  26.                  * method.
  27.                  *
  28.                  * This method draws a 3-D rectangle of specified width and
  29.                  * height at (x1,y1)
  30.                  */
  31.                
  32.                 //this will draw a 3-D rectangle of width 50 & height 100 at (10,10)
  33.                 g.draw3DRect(10,10,50,100,true);
  34.                
  35.                 /*
  36.                  * If you speficy same width and height, the draw3DRect method
  37.                  * will draw a 3-D square!
  38.                  */
  39.                
  40.                 //this will draw a 3-D square
  41.                 g.draw3DRect(100,100,50,50,true);
  42.                
  43.                 g.setColor(Color.orange);
  44.                
  45.                 /*
  46.                  * To draw a filled 3-D rectangle in an applet window use,
  47.                  * void fill3DRect(int x1,int y1, int width, int height, boolean raised)
  48.                  * method.
  49.                  *
  50.                  * This method draws a filled 3-D rectangle of specified width and
  51.                  * height at (x1,y1)
  52.                  */
  53.                
  54.                 //this will draw a filled 3-D rectangle of width 50 & height 100 at (10,10)
  55.                 g.fill3DRect(10,150,50,100,true);
  56.                
  57.                 /*
  58.                  * If you speficy same width and height, the fill3DRect method
  59.                  * will draw a filled 3-D square!
  60.                  */
  61.                
  62.                 //this will draw a filled 3-D square
  63.                 g.fill3DRect(100,200,50,50,true);
  64.        
  65.         }
  66. }

Example Output