Hi,
Could anyone help me to figure out why this code just get Kindle show me 'An error occurred openning the title'?
I just try to load a png image in my Kindlet. looks like it get error on 'Create' method.
Code:
package kapp;
import com.amazon.kindle.kindlet.AbstractKindlet;
import com.amazon.kindle.kindlet.KindletContext;
import com.amazon.kindle.kindlet.ui.KImage;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
public class Main extends AbstractKindlet {
private KindletContext ctx;
private Image im;
private KImage card;
public void create(KindletContext context) {
this.ctx = context;
URL urlImage = getClass().getResource("Images/xxx.png");
this.im = Toolkit.getDefaultToolkit().createImage(urlImage);
this.card = new KImage (im);
try {
ctx.getRootContainer().add(this.card);
} catch (Throwable t) {
//ctx.getRootContainer().
//t.printStackTrace();
}
}
public void start() {
try {
//this.card.setBounds(256, 56, 75, 108);
} catch (Throwable ex) {
//ex.printStackTrace();
}
}
public void stop() {
}
}
By move the 'try' statment, I can identify this line causes the error:
Code:
this.im = Toolkit.getDefaultToolkit().createImage(urlImage);
but I don't know why......