Thursday, February 29, 2024

Java Applet program to draw rectangle and right-aligned oval of orange color.

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class RectangleAndOvalApplet extends Applet { 
    public void paint(Graphics g) { 
   // Draw a rectangle with orange color
   g.setColor(Color.ORANGE); 
   g.drawRect(50, 50, 100, 80); 

   // Draw a right-aligned oval with orange color     g.setColor(Color.ORANGE); 
   int ovalX = getWidth() - 150; // Right-aligned
   int ovalY = 50; 
   int ovalWidth = 100; 
   int ovalHeight = 80; 
   g.fillOval(ovalX, ovalY, ovalWidth, ovalHeight); }
}

No comments:

Post a Comment

Java program to implement file input stream class to read binary data from image file.

import java.io.FileInputStream; import java.io.IOException; public class ReadImageFile {     public static void main(String[] args) {       ...