I'm trying to create my own graphic menu.
So, i create an item Class(myGraphic).
This class load a picture.
The main class should be able to create some myGraphic instances.
But, it doesn't work.
In fact, i'm able to create a simple circle or any other shapes, but when i
try to load picture, it bugs.
This is the bugging piece of code :
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class imgbouton extends Applet implements MouseListener{
myGraphic tom;//my own graphic button
public void init()
{
tom=new myGraphic();
tom.setSize(100,100);
add(tom);
tom.addMouseListener(this);
}
public void mousePressed(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){showStatus("picture Cliked");}
}
class myGraphic extends Applet//instead of Applet, when i use a Canvas
extanding, i'm able to draw a circle or all other shapes, but i don't
succeded in loading picture
{
Image ii;
Graphics gg;
public void init()
{
//i try this in order to synchronize images loading,but...
MediaTracker mt=new MediaTracker(this);
ii=getImage(getDocumentBase(),"../img/haut.gif");
mt.addImage(ii,0);
try{
mt.waitForAll();
mt.waitForAll();
}
catch(InterruptedException ex){}
}
public void paint(Graphics g)
{
g.drawImage(ii,0,0,this);
}
}