HELP! Can't see my graphic result
I just wrote a program, 1) for component and 2) the viewer... it compiles correctly however when I try to view my result the frame is blank.
Any idea on why? here is my program...
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import javax.swing.JPanel;
import javax.swing.JComponent;
public class TriangleComponent extends JComponent
{
public void paintComponet(Graphics g)
{
// Recover Graphics2D
Graphics2D g2 = (Graphics2D) g;
// Construct a triangle and draw it
Line2D.Double line = new Line2D.Double(5, 20, 10, 5);
Line2D.Double line1 = new Line2D.Double(10, 5, 40, 5);
Line2D.Double line2 = new Line2D.Double(40, 5, 100,25);
g2.draw(line);
g2.draw(line1);
g2.draw(line2);
}
}
import javax.swing.JFrame;
public class TriangleViewer
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
final int FRAME_WIDTH = 300;
final int FRAME_HEIGHT = 400;
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
frame.setTitle("Triangles");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TriangleComponent component = new TriangleComponent();
frame.add(component);
frame.setVisible(true);
}
}

