DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   calling a function very basic >>> <<<< (http://www.daniweb.com/forums/thread158204.html)

localp Nov 19th, 2008 12:52 am
calling a function very basic >>> <<<<
 
I want to know how to call the above function ???

import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

public class GridDrawingApplet extends Applet {

  public void paint (Graphics g)
  {
    // Draw the vertical lines:
    g.drawLine (0,0, 0,240);

  }
}

public static void main(String []args)
{

    // now i want to call the above function here how do i do it ....
  //  the void paint (Graphics g) function
}

can some one plzz help me with the code .....

dickersonka Nov 19th, 2008 1:51 am
Re: calling a function very basic >>> <<<<
 
new GridDrawingApplet();

you don't need to explicitly call paint

localp Nov 19th, 2008 6:48 am
Re: calling a function very basic >>> <<<<
 
Quote:

Originally Posted by dickersonka (Post 739324)
new GridDrawingApplet();

you don't need to explicitly call paint


so how can i display the content of paint.. wat i am expecting here is to display the content of paint, from the main program.. how can i do that ??

dickersonka Nov 19th, 2008 9:46 am
Re: calling a function very basic >>> <<<<
 
sorry i assumed you knew where to place it

public static void main(String []args)
{
  new GridDrawingApplet();
}

anil_forum Nov 19th, 2008 12:49 pm
Re: calling a function very basic >>> <<<<
 
an applet do not require main method
to run your code include the following method
public void init()
{
}
and one comment
//<applet code=GridDrawingApplet height=300 width=300></applet>

and run this code after compiling by writing
appletviewer GridDrawingApplet

and remove main method......


All times are GMT -4. The time now is 10:12 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC