Logo Search packages:      
Sourcecode: wims version File versions  Download package

rene::gui::IconWithGif::IconWithGif ( IconBar  bar,
String  file 
) [inline]

Initialize the icon and load its image. By changing the global parameter "icontype", png can be used too.

Definition at line 310 of file IconBar.java.

References rene::gui::IconBar::Resource.

      {     super(bar,file);
            String iconfile=getDisplay(file);
            if (!iconfile.equals("")) file=iconfile;
            try
            {     InputStream in=getClass().getResourceAsStream(
                        Bar.Resource+file+"."+Global.getParameter("icontype","gif"));
                  int pos=0;
                  int n=in.available();
                  byte b[]=new byte[20000];
                  while (n>0)
                  {     int k=in.read(b,pos,n);
                        if (k<0) break;
                        pos+=k;
                        n=in.available();
                  }
                  in.close();
                  I=Toolkit.getDefaultToolkit().createImage(b,0,pos);
                  MediaTracker T=new MediaTracker(bar);
                  T.addImage(I,0);
                  T.waitForAll();
            }
            catch (Exception e)
            {     try
                  {     I=getToolkit().getImage(file+"."+Global.getParameter("icontype","gif")); 
                        MediaTracker mt=new MediaTracker(this); 
                        mt.addImage(I,0); 
                        mt.waitForID(0); 
                        if (!(mt.checkID(0) && !mt.isErrorAny()))
                              throw new Exception("");
                  }
                  catch (Exception ex) { I=null; return;}
            }
            W=I.getWidth(this);
            H=I.getHeight(this);
            X=Size/2-W/2;
            Y=Size/2-H/2;
      }


Generated by  Doxygen 1.6.0   Back to index