PDA

Click to See Complete Forum and Search --> : Ok, whats going on?...


invitro
Aug 19th, 2000, 11:19 PM
public class Applet1 extends Applet
{
public String i_item;


/**
* The entry point for the applet.
*/
public void init()
{

xitem = new Class1(i_item);

}

public void paint(Graphics g) {

}
}



Ok, i want to be able to call the xitem in the paint sub. Sorry this is a basic question but this is my 3rd day doing this hehe :)

Anyways, i want to make it so i can do



public void paint(Graphics g) {

xitem.Draw();

{

But the thing is, when i put in xitem. the submenu wont pop up. It should have Draw inside because my Class1 has it. This is what it looks like.


import java.awt.*;

public class Class1
{
String x_item;
public Class1(String x){

x_item = x;



}

public void DrawX(Graphics d){
d.drawString(x_item,20,20);


}
}


I know there are many errors, but what am i forgeting to make xitem equal to... i tried making it
public xitem Class1;
before the init void but that dosent work.

??? Please help, im stuck damnit! :\

parksie
Aug 25th, 2000, 04:22 PM
How about:

public class Applet1 extends Applet {
private String m_xitem;

public init(String x_item) {
m_xitem = x_item;
}

public void paint(Graphics g) {
g.drawString(m_xitem, 5, 50);
}
}

You'd need to use a different way of setting m_xitem, though, such as: getParameter("string"), which is set in the <applet> tag.

invitro
Aug 25th, 2000, 09:10 PM
Ahhhhhhh.... now i see it! Thanks for the post! Ill go play around with it right now!