codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  drawPolygon() . Polygon not display??  ericwi at 04:41 on Sunday, April 23, 2006
 

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


  Re: drawPolygon() . Polygon not display??  crwood at 07:45 on Sunday, April 23, 2006
 


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();
}
}


  Re: drawPolygon() . Polygon not display??  ericwi at 04:12 on Monday, April 24, 2006
 

Thanks crwood. It worked!!








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Beginners question on building Bento4 SDK
•  Scrolling Images
•  Re: Please can someone show me how to make a java box pop upand display personal information!
•  Does anyone know to create or implement a diary into Java??
•  jslider - paint track
•  Re: convert minutes into hours and minutes
•  File handle problem
•  Link Capture, help needed
•  Re: java app auto web update..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007