How can I write a Java program to draw a box, an oval, and an arrow?
You'll find what you're looking for in the Java 2D Graphics Tutorial. The section on Drawing Geometric Primitives shows how to draw rectangles and ovals, and you should be able to put an arrow together after reading the Drawing Arbitrary Shapes section.
A paintbrush, some ink and some careful and loving application of ink to monitor and you'll be set for life.
I understand it may be hard to start.
So here it goes.
import javax.swing.*;
import java.awt.Graphics;
public class Homework {
public static void main( String [] args ) {
JFrame frame = new JFrame();
frame.add( new JComponent() {
public void paintComponent( Graphics g ) {
// invoke "Graphics" methods here
}
});
frame.setVisible( true );
}
}
Now, you just have to invoke the methods you need from the Graphics object and that will take charge of displaying the shapes in the screen:
That would help to start with something useful.
To gain deeper understanding continue with this article: Painting in AWT and Swing. It would help you to understand what's going on.
Finally for "advanced" painting these article is a must read: 2D graphics