error with .setBounds()
I have read tutorials on how to set the x and y coordinates for boxes, they have told me to do this <ButtonName>.setBounds(<x><y><widt><height>)
Though when I do this in my code it does not work, it always keeps the box in the top middle of the applet. Here is the code, plz help me:
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.awt.Button;
public class DrakonTitle extends Applet implements Runnable
{
Font bigFont;
Font NotSoBig;
int xPos = 10;
int yPos = 200;
int radius = 20;
Image ScreenChar;
URL base;
MediaTracker mt;
private Image dbImage;
private Graphics dbg;
Button ClickToPlay;
Checkbox MaleFemale;
public void init()
{
mt = new MediaTracker(this);
bigFont = new Font("Arial",Font.BOLD,100);
NotSoBig = new Font("Arial",Font.BOLD,30);
ClickToPlay = new Button("Click here to play");
ClickToPlay.setBounds(200,200,20,20);
add(ClickToPlay);
try
{
base = getDocumentBase();
}
catch(Exception e) {}
ScreenChar = getImage(base,"FrontScreenCharacter.jpg");
mt.addImage(ScreenChar,1);
try
{
mt.waitForAll();
}
catch(InterruptedException e)
{}
}
public void start()
{
Thread th = new Thread(this);
th.start();
}
public void stop()
{
}
public void update (Graphics g)
{
if (dbImage == null)
{
dbImage = createImage (this.getSize().width, this.getSize().height);
dbg = dbImage.getGraphics ();
}
dbg.setColor (getBackground ());
dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
dbg.setColor (getForeground());
paint (dbg);
g.drawImage (dbImage, 0, 0, this);
}
public void destroy()
{
}
public void run()
{
while(true)
{
xPos++;
repaint();
try
{
Thread.sleep(17);
}
catch(InterruptedException ex)
{
}
}
}
public void paint(Graphics g)
{
g.setFont(bigFont);
g.drawString("Drakon:",45,100);
g.setFont(NotSoBig);
g.drawString("Lord of Lords",100,160);
g.drawImage(ScreenChar,xPos-radius,yPos-radius,2*radius,2*radius,this);
if(xPos==412){
xPos=10;
}
}
}

