View Single Post
Old 12-06-2013, 11:05 AM   #1
dragon123
Junior Member
dragon123 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2013
Device: kindle 4
Loading a png file

Hi,

could anyone help me to figure out why nothing is happen when I'm trying to load a png file in my kindlet. The kindlet is starting, but neither the picture is shown nor an error is saved in the crash log. I don't know why. Could anyone help me please.

Code:
package kindlebeispiel;

import com.amazon.kindle.kindlet.AbstractKindlet;
import com.amazon.kindle.kindlet.KindletContext;
import com.amazon.kindle.kindlet.ui.KImage;
import com.amazon.kindle.kindlet.ui.KTextArea;
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("/weather-icons/mix.png");
        this.im = Toolkit.getDefaultToolkit().createImage(urlImage);        
        this.card = new KImage(im);
    }

    public void start() {
        try {
            //ctx.getRootContainer().add(new KTextArea("Hello World!"));
            ctx.getRootContainer().add(this.card);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }

    public void stop() {
    }

    public void destroy() {
    }
}
dragon123 is offline   Reply With Quote