public void paint(Graphics g) { Graphics graphics = getGraphics(); }
public void paint(Graphics g) { Graphics graphics = getGraphics(); graphics.drawRect(10, 10, 50, 50); graphics.fillOval(70, 10, 50, 50); }
In this example, The drawRect() method is used in this example to draw a rectangle with the top-left corner at (10, 10) and width and height set to 50. The fillOval() method is used to draw a circle with a diameter of 50 and a centre at (70, 35).
public void paint(Graphics g) { Graphics graphics = getGraphics(); graphics.drawLine(10, 70, 110, 70); }
In this example, the drawLine() method is used to draw a line between the points (10, 70) and (110, 70).
public void paint(Graphics g) { Graphics graphics = getGraphics(); graphics.drawString("Hello, world!", 10, 100); }
In this example, the drawString() method is used to draw the string "Hello, world!" at the point (10, 100).
It's important to remember that the whenever paint() method is called the applet needs to be redrawn, which can be quite frequently. As a result, it's crucial to ensure that your paint() method is effective and doesn't perform any extraneous tasks. For instance, instead of drawing a static image repeatedly as the applet is painted, you should think about drawing it once and saving it in an Image object.
Police Colony
Patna, Bihar
India
Email:
Post your comment