Skip to Content

Draw Rounded Corner 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 Rounded Corner Rectangle & Square in Applet Window Example
  3.         This java example shows how to draw rounded corner rectangles and squares
  4.         in an applet window using drawRoundRect method of Graphics class. It also
  5.         shows how to draw a filled rounded corner rectangles and squares using
  6.         fillRoundRect method of Graphics class.
  7. */
  8.  
  9. /*
  10. <applet code="DrawRoundedRectExample" width=500 height=500>
  11. </applet>
  12. */
  13.  
  14.  
  15. import java.applet.Applet;
  16. import java.awt.Color;
  17. import java.awt.Graphics;
  18.  
  19. public class DrawRoundedRectExample extends Applet{
  20.  
  21.         public void paint(Graphics g){
  22.                
  23.                 //set color to red
  24.                 setForeground(Color.red);
  25.                
  26.                 /*
  27.                  * to draw a rounded corner rectangle in an applet window use,
  28.                  * void drawRoundRect(int x1,int y1, int width, int height, int arcWidth, int arcHeight)
  29.                  * method.
  30.                  *
  31.                  * This method draws a rounded corner rectangle of specified width and
  32.                  * height at (x1,y1)
  33.                  */
  34.                
  35.                 //this will draw a round cornered rectangle of width 50 & height 100 at (10,10)
  36.                 g.drawRoundRect(10,10,50,100,10,10);
  37.                
  38.                 /*
  39.                  * If you speficy same width and height, the drawRoundRect method
  40.                  * will draw a round cornered square!
  41.                  */
  42.                
  43.                 //this will draw a round cornered square
  44.                 g.drawRoundRect(100,100,50,50,10,10);
  45.                
  46.                 /*
  47.                  * To draw a filled round cornered rectangle or square use
  48.                  * fillRoundRect(int x1,int y1, int width, int height, int arcWidht, int arcHeight)
  49.                  * method of Graphics class.
  50.                  */
  51.                
  52.                 //set color to blue
  53.                 //setForeground(Color.blue);
  54.                
  55.                 //draw filled rounded corner rectangle
  56.                 g.fillRoundRect(200,20,50,100,10,10);
  57.                
  58.                 //draw filled square
  59.                 g.fillRoundRect(200,200,50,50,10,10);
  60.         }
  61. }

Example Output