|
Hi all,
I am a newbie with Java and I would lke to seek all Java's advice. I had this program below
import java.awt.*;
import javax.swing.*;
public class polygontest extends JFrame
{
public polygontest()
{
setSize( 400 , 500 );
setVisible(true);
}
public void painting(Graphics g)
{
int xInput[] ={20,10,50,150,200};
int yInput[] = {75,150,150,130,290};
Polygon pixpoly = new Polygon (xInput,yInput,5);
g.drawPolygon( pixpoly);
}
public static void main(String[] args)
{
polygontest mypix = new polygontest() ;
}
}
It's a simply program. I run this program but I can't seem to see the polygon display. Anyone has ides??
Thanks
|
|
|
import java.awt.*;
import javax.swing.*;
public class PolyTest extends JFrame
{
public PolyTest()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().add(new PolyPanel());
setSize( 400 , 500 );
setLocation(200,200);
setVisible(true);
}
private class PolyPanel extends JPanel
{
protected void paintComponent(Graphics g)
{
int xInput[] = {20,10,50,150,200};
int yInput[] = {75,150,150,130,290};
Polygon pixpoly = new Polygon (xInput,yInput,5);
g.drawPolygon( pixpoly);
}
}
public static void main(String[] args)
{
new PolyTest();
}
}
|
|
|
|
|
Thanks crwood. It worked!!
|
|
|
|
|
|
|
// |