Draws Two Rounded Rectangles Using Applet
![draws Two Rounded Rectangles Using Applet draws Two Rounded Rectangles Using Applet](https://lh3.googleusercontent.com/-Vys52Yb5gu4/VZVGHNjO3PI/AAAAAAAAD1Q/mSpzTTYhi5A/s1600/3.png)
Draws Two Rounded Rectangles Using Applet To draw a solid (filled) rectangle, fillrect () method is used. this method also takes four parameters similar to the drawrect () method. to draw a solid rectangle having same parameters as above we use the statement g.fillrect (20 , 20 , 50, 30) which draws the rectangle as shown in figure. exampel: draw solid rectangle using the fillrect. Basically what you need to do is: on mouse down keep the mouse down coordinates and repaint. on mouse move keep current mouse coordinates and repaint. on mouse up, nullify the mouse down coordinates to indicate there is no rect, and repaint. on paint, draw background and then rect between mousedown and cur mouse coordinates.
![Draw And Filling rectangles In Java applet Computer Notes Draw And Filling rectangles In Java applet Computer Notes](https://ecomputernotes.com/images/Rounded-Rectangle-using-the-drawRoundRect.jpg)
Draw And Filling Rectangles In Java Applet Computer Notes By using the drawoval(int x, int y, int width, int height) or by using mathematical formula (x= a * sin a, y= b *cos a, where a and b are major and minor axes and a is the angle ) . similarly, we will draw a rectangle on java applet by two ways . by using the drawrect(int x, int y, int width, int height) or by drawing four lines joining the edges . Java program to create and fill shapes using applet. In this article, we will show you how to load an image or draw different shapes like an oval, rectangle and a line in an applet. to perform these operations, we are going to use three methods getcodebase () and getimage () method of applet class and drawimage () method of image class. Problem description. how to create different shapes using applet? solution. following example demonstrates how to create an applet which will have a line, an oval & a rectangle using drawline(), drawoval(, drawrect() methods of graphics clas.
Comments are closed.