download
http://www.bodytag.org/nav.php?u=grid2/grid2.jar, and decompile it to view source code.

解决方案 »

  1.   

    sorry, i don't know how to decompile it. i decompreeed it ,and get some class files. i want to get java source code. How to do it?
    thanks indeed
      

  2.   

    download jad from http://kpdus.tripod.com/jad/winnt/jadnt158.zip
    use command jad -sjava *.class to decomplie classes in grid2.jar;
    after decompile, open those java files in jbuilder, and jbuilder will report errors; 
    modify two methods of BGraphics.java
        public byte[] loadBytes(String s)
        {
          try
          {
            ByteArrayOutputStream bytearrayoutputstream;
            InputStream inputstream = loadStream(s);
            BufferedInputStream bufferedinputstream = new BufferedInputStream(
                inputstream);
            bytearrayoutputstream = new ByteArrayOutputStream();
            for (int i = bufferedinputstream.read(); i != -1;
                 i = bufferedinputstream.read())
              bytearrayoutputstream.write(i);        return bytearrayoutputstream.toByteArray();
          }
          catch(    IOException ioexception)
          {        ioexception.printStackTrace();
          }
            return null;
        }    public String[] loadStrings(String s)
        {
            String as[];
            int i;
            try
            {
              BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(
                  loadStream(s)));
              as = new String[100];
              i = 0;
              for (String s1 = null; (s1 = bufferedreader.readLine()) != null; ) {
                if (i == as.length) {
                  String as1[] = new String[i << 1];
                  System.arraycopy(as, 0, as1, 0, i);
                  as = as1;
                }
                as[i++] = s1;
              }          bufferedreader.close();
              if (i == as.length)
                return as;
              String as2[];
              as2 = new String[i];
              System.arraycopy(as, 0, as2, 0, i);
              return as2;
            }
            catch(   IOException ioexception)
            {
    //          ioexception;
              ioexception.printStackTrace();
            }
            return null;
        }
    modify BApplet.java
        public static void main(String args[])
        {
            if(args.length != 1)
            {
                System.err.println("error: BApplet <appletname>");
                System.exit(1);
            }
            try
            {
                Frame frame = new Frame();
                Class class1 = Class.forName(args[0]);
                BApplet bapplet = (BApplet)class1.newInstance();
                bapplet.init();
                bapplet.start();
                Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
                frame.setLayout(new BorderLayout());
                frame.add(bapplet, "Center");
                frame.pack();
                frame.setLocation((dimension.width - bapplet.g.width) / 2, (dimension.height - bapplet.g.height) / 2);
                frame.show();
                bapplet.requestFocus();
                frame.addWindowListener(bapplet.new _cls1());//change new to bapplet.new
            }
            catch(Exception exception)
            {
                exception.printStackTrace();
                System.exit(1);
            }
        }
    Then you are able to compile them error free