Hopefully this helps a bit...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class JFrameExample extends JFrame{
public JFrameExample() //Constructor
{
super("JFrameExample"); //Set title
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(400,400); //Set size to 400 by 400
setVisible(true); //Make the JFrame visible
}
public void paint(Graphics g) //This is where the painting is done
{
super.paintComponents(g); //Paint components
g.setColor(Color.GREEN); //Change the color to green
g.drawRect(10,50,100,100); //Draw a rectangle
}
public static void main (String[] args){
new JFrameExample(); //Create an instance of JFrameExample
}
}
Also this might help you a bit:
http://www.corewebprogramming.com/PDF/ch10.pdf