Moparscape - RSPS Community

RuneScape 2 Development => RS Client Hacking => Topic started by: RiiPiiNFtW on June 21, 2014, 02:42:36 PM

Title: Adding Icon to Frame (Replacing Java Icon) | Image loaded from Internet
Post by: RiiPiiNFtW on June 21, 2014, 02:42:36 PM
This is my way of adding an icon to replace the default java icon on your client or any other program you want to use this with (written in Java of course).

This could be done easier, but this is my work around for people getting the icon from their website with cloudflare enabled.

You could simply do:

Code: Java
  1. ImageIO.read(newURL(";));

but again, this is for people with cloudflare enabled (works without it too)

So here anyways...

Code: Java
  1.         try{
  2.                         URL url =newURL(";);
  3.                         URLConnection urlConn = url.openConnection();
  4.                         urlConn.addRequestProperty("User-Agent",
  5.                                         "Mozilla/5.0(Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
  6.                         BufferedInputStream in = new BufferedInputStream(
  7.                                         urlConn.getInputStream());
  8.                         ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
  9.                         int c;
  10.                         while ((c = in.read()) != -1) {
  11.                                 byteArrayOut.write(c);
  12.                         }
  13.  
  14.                         Image image = Toolkit.getDefaultToolkit().createImage(
  15.                                         byteArrayOut.toByteArray());
  16.  
  17.                         i = new ImageIcon(image);
  18.                 } catch (IOException e) {
  19.                         e.printStackTrace();
  20.                 }
  21.                 setIconImage(i.getImage());