i am trying to simply display a picture with a midlet but can't seem to get it to work, does anyone know how to do this???
do i have to include the picture in the package???
it's not something i've done, but is there a method called paintComponent that you can extend? there is in most visual java stuff (applets, awt, swing etc.)
if there is, then try this:
public void paintComponent(Graphics g){
super.paintComponent(g);
Toolkit tk = Toolkit.getDefaultToolkit();
image i = tk.getImage("breasts.jpg" //or whatever
g.drawimage(i, x, y, this);
}
//where x and y are the co-ordinates
below is the code i am using, i have an emulator for sprint phones and it does not display anything on them but it does on the defaultphones in my emulator, shouldn't this also work for sprint?
package TestFiles;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.* ;
import java.io.* ;
public class Test extends MIDlet implements CommandListener {
public Test() {
display = Display.getDisplay(this);
canvas = new MyCanvas(this);
exitCommand = new Command("Exit",Command.SCREEN,2);
}
public void startApp() {
display.setCurrent(canvas);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
class MyCanvas extends Canvas implements CommandListener
{
private Command cmdExit;
private Test midlet;
private Image image;
private int a;
private int b;
private int c;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.