Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   help required (http://www.go4expert.com/forums/help-required-t3813/)

bhalla1335 9Apr2007 23:21

help required
 
hi everyone
well i need urgent help from all you java programmers
well i have never done java before and have to make an applet
its a very simple basic one but as i told u guys i dont even know even the abcd of java
so can anyone of you help me
if you could please reply at aman.bhalla1335@gmail.com
thanks
regards
aman bhalla

shabbir 10Apr2007 08:33

Re: help required
 
You have submitted as an article under the java forum but it should be under the Employer forum of queries and discussion and I have moved the thread at the right place.

Also having a better title will give better responses to your query. I would suggest you read Before you make a query thread.

ronsan 7May2007 11:39

Re: help required
 
Hey aman ,
// check this out

Code:

public void init() {
    ...
    imgs = new ImageIcon[nimgs];
    (new SwingWorker() {
        public ImageIcon[] doInBackground() {
            //Images are numbered 1 to nimgs,
            //but fill array from 0 to nimgs-1.
            for (int i = 0; i < nimgs; i++) {
                imgs[i] = loadImage(i+1);
            }
            return imgs;
        }
        ...
    }).execute();

}
...
protected ImageIcon loadImage(int imageNum) {
    String path = dir + "/T" + imageNum + ".gif";
    int MAX_IMAGE_SIZE = 2400;  //Change this to the size of
                                //your biggest image, in bytes.
    int count = 0;
    BufferedInputStream imgStream = new BufferedInputStream(
      this.getClass().getResourceAsStream(path));
    if (imgStream != null) {
        byte buf[] = new byte[MAX_IMAGE_SIZE];
        try {
            count = imgStream.read(buf);
            imgStream.close();
        } catch (java.io.IOException ioe) {
            System.err.println("Couldn't read stream from file: " + path);
            return null;
        }
        if (count <= 0) {
            System.err.println("Empty file: " + path);
            return null;
        }
        return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf));
    } else {
        System.err.println("Couldn't find file: " + path);
        return null;
    }
}



All times are GMT +5.5. The time now is 04:48.