Write down the syntax to create new Graphics object code example
Example 1: Write a simple java swing application that will display rectangle graphics as shown in the picture below:
void setColor(Color c)
Color getColor()
void setFont(Font f)
Font getFont()
void setClip(int xTopLeft, int yTopLeft, int width, int height)
void setClip(Shape rect)
public abstract void clipRect(int x, int y, int width, int height)
Rectangle getClipBounds()
Shape getClip()
Example 2: Write a simple java swing application that will display rectangle graphics as shown in the picture below:
public void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getWidth();
int height = getHeight();
. . .
}