doc.parseString(xml);
doc.parseString(xmlBuffer.toString());
  public void loadConfig(String config)  		throws IOException  {    String xml = "";    InputStream dis = new BufferedInputStream(getClass().getResourceAsStream(config));    while (dis.available() > 0) {      byte[] b = new byte[dis.available()];      if (dis.read(b) == -1) {        break;      }      xml += new String(b);    }    XMLElement doc = new XMLElement();    try {      doc.parseString(xml);    } catch (XMLParseException ex) {    	throw new IOException(ex.toString());    }    for (Enumeration e = doc.enumerateChildren(); e.hasMoreElements(); ) {      XMLElement tmp = (XMLElement) e.nextElement();      if (tmp.getName().equals("img")) {        try {          if (tmp.getStringAttribute("name").equals("normal")) {            normalImage = getSystemImage(tmp.getStringAttribute("src"));          } else if (tmp.getStringAttribute("name").equals("over")) {            overImage = getSystemImage(tmp.getStringAttribute("src"));          } else if (tmp.getStringAttribute("name").equals("pressed")) {            pressedImage = getSystemImage(tmp.getStringAttribute("src"));          }        } catch (IOException ex) {          System.out.println("Cannot load " + tmp.getStringAttribute("src"));          return;        }      } else if (tmp.getName().equals("display")) {        for (Enumeration e_display = tmp.enumerateChildren(); e_display.hasMoreElements(); ) {          XMLElement tmp_display = (XMLElement) e_display.nextElement();          if (tmp_display.getName().equals("numcolors")) {            deviceDisplay.numColors = Integer.parseInt(tmp_display.getContent());          } else if (tmp_display.getName().equals("iscolor")) {            deviceDisplay.isColor = parseBoolean(tmp_display.getContent());          } else if (tmp_display.getName().equals("background")) {          	int color = Integer.parseInt(tmp_display.getContent(), 16);            deviceDisplay.backgroundColor =             		SwtDeviceComponent.createColor(            				new RGB((color >> 16) % 256, (color >> 8) % 256, color % 256));          } else if (tmp_display.getName().equals("foreground")) {						int color = Integer.parseInt(tmp_display.getContent(), 16);            deviceDisplay.foregroundColor = 								SwtDeviceComponent.createColor(										new RGB((color >> 16) % 256, (color >> 8) % 256, color % 256));          } else if (tmp_display.getName().equals("rectangle")) {            deviceDisplay.displayRectangle = getRectangle(tmp_display);          } else if (tmp_display.getName().equals("paintable")) {            deviceDisplay.displayPaintable = getRectangle(tmp_display);          }        }        for (Enumeration e_display = tmp.enumerateChildren(); e_display.hasMoreElements(); ) {          XMLElement tmp_display = (XMLElement) e_display.nextElement();                    if (tmp_display.getName().equals("img")) {            if (tmp_display.getStringAttribute("name").equals("up")) {              deviceDisplay.upImage = new PositionedImage(                  getImage(tmp_display.getStringAttribute("src")),                  getRectangle(getElement(tmp_display, "paintable")));            } else if (tmp_display.getStringAttribute("name").equals("down")) {              deviceDisplay.downImage = new PositionedImage(                  getImage(tmp_display.getStringAttribute("src")),                  getRectangle(getElement(tmp_display, "paintable")));            } else if (tmp_display.getStringAttribute("name").equals("mode")) {              if (tmp_display.getStringAttribute("type").equals("123")) {                deviceDisplay.mode123Image = new PositionedImage(                    getImage(tmp_display.getStringAttribute("src")),                    getRectangle(getElement(tmp_display, "paintable")));              } else if (tmp_display.getStringAttribute("type").equals("abc")) {                deviceDisplay.modeAbcLowerImage = new PositionedImage(                    getImage(tmp_display.getStringAttribute("src")),                    getRectangle(getElement(tmp_display, "paintable")));              } else if (tmp_display.getStringAttribute("type").equals("ABC")) {                deviceDisplay.modeAbcUpperImage = new PositionedImage(                    getImage(tmp_display.getStringAttribute("src")),                    getRectangle(getElement(tmp_display, "paintable")));              }            }          }        }      } else if (tmp.getName().equals("keyboard")) {        for (Enumeration e_keyboard = tmp.enumerateChildren(); e_keyboard.hasMoreElements(); ) {          XMLElement tmp_keyboard = (XMLElement) e_keyboard.nextElement();          if (tmp_keyboard.getName().equals("button")) {            Rectangle rectangle = null;            Vector stringArray = new Vector();            for (Enumeration e_button = tmp_keyboard.enumerateChildren(); e_button.hasMoreElements(); ) {              XMLElement tmp_button = (XMLElement) e_button.nextElement();              if (tmp_button.getName().equals("chars")) {                for (Enumeration e_chars = tmp_button.enumerateChildren(); e_chars.hasMoreElements(); ) {                  XMLElement tmp_chars = (XMLElement) e_chars.nextElement();                  if (tmp_chars.getName().equals("char")) {                                     stringArray.addElement(tmp_chars.getContent());                                      }                }              } else if (tmp_button.getName().equals("rectangle")) {                rectangle = getRectangle(tmp_button);              }            }            char[] charArray = new char[stringArray.size()];            for (int i = 0; i < stringArray.size(); i++) {              String str = (String) stringArray.elementAt(i);              if (str.length() > 0) {                charArray[i] = str.charAt(0);              } else {                charArray[i] = ' ';              }            }            buttons.addElement(new SwtButton(tmp_keyboard.getStringAttribute("name"),                 rectangle, tmp_keyboard.getStringAttribute("key"), charArray));          } else if (tmp_keyboard.getName().equals("softbutton")) {            Vector commands = new Vector();            Rectangle rectangle = null, paintable = null;            for (Enumeration e_button = tmp_keyboard.enumerateChildren(); e_button.hasMoreElements(); ) {              XMLElement tmp_button = (XMLElement) e_button.nextElement();              if (tmp_button.getName().equals("rectangle")) {                rectangle = getRectangle(tmp_button);              } else if (tmp_button.getName().equals("paintable")) {                paintable = getRectangle(tmp_button);              } else if (tmp_button.getName().equals("command")) {                commands.addElement(tmp_button.getContent());              }            }            SwtSoftButton button = new SwtSoftButton(tmp_keyboard.getStringAttribute("name"),                rectangle, tmp_keyboard.getStringAttribute("key"), paintable,                 tmp_keyboard.getStringAttribute("alignment"), commands);            buttons.addElement(button);            softButtons.addElement(button);          }        }      }    }  }