help required

Discussion in 'Java' started by bhalla1335, Apr 9, 2007.

  1. bhalla1335

    bhalla1335 New Member

    Joined:
    Apr 9, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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 [thread=168]Before you make a query[/thread] thread.
     
  3. ronsan

    ronsan New Member

    Joined:
    May 6, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.cristinasymons.co.uk
    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;
        }
    }
     
    Last edited by a moderator: May 7, 2007

Share This Page

  1. 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.
    Dismiss Notice