scriptersteve Posted January 19, 2018 Share Posted January 19, 2018 Hi, so i know how to add the picture t the script logo. But how does one make the picture appear on screen over chatbox, Can't seem to work that out :? Thanks Quote Link to comment Share on other sites More sharing options...
Explv Posted January 19, 2018 Share Posted January 19, 2018 (edited) 15 minutes ago, scriptersteve said: Hi, so i know how to add the picture t the script logo. But how does one make the picture appear on screen over chatbox, Can't seem to work that out :? Thanks By overriding the onPaint method and drawing the image? There's a bunch of threads that show you how to do this, you should try searching the forum instead of making a new thread for every trivial thing: Edited January 19, 2018 by Explv Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 19, 2018 Author Share Posted January 19, 2018 Fair enough, i had read that Quote Link to comment Share on other sites More sharing options...
Explv Posted January 19, 2018 Share Posted January 19, 2018 (edited) 6 minutes ago, scriptersteve said: Fair enough, i had read that Well it's on there, near the bottom. ( You can also use an image stored online, instead of storing in the resources directory) Assuming your images are stored in a directory called "resources" Firstly you need to read the image from the file. This should NOT be done inside the onPaint method as this would be VERY inefficient. Declare the images you need as global variables of type BufferedImage, for example: ... public class Main extends Script{ BufferedImage background; @Override public void onStart(){ } ... } Now we need to read the image from its file into the variable. This should be done inside onStart, as we only need to do it once: ... public class Main extends Script{ BufferedImage background; @Override public void onStart(){ try{ background = ImageIO.read(Main.class.getResourceAsStream("/resources/background.png")); } catch(IOException e){ log(e); } } ... } Now that the image has been read from its file we can draw it inside the onPaint method using g.drawImage: public class Main extends Script{ BufferedImage background; @Override public void onStart(){ try{ background = ImageIO.read(Main.class.getResourceAsStream("/resources/background.png")); } catch(IOException e){ log(e); } } ... @Override public void onPaint(Graphics2D g){ if(background != null){ g.drawImage(background, null, x, y); } } } Edited January 19, 2018 by Explv Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 19, 2018 Author Share Posted January 19, 2018 Yeah i know, my problem was i'm not quite sure where the picture needs to be saved i.e your resources/background - i was putting in my location and it isn't working That was my problem - probs should have specified before Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 19, 2018 Author Share Posted January 19, 2018 10 minutes ago, scriptersteve said: Yeah i know, my problem was i'm not quite sure where the picture needs to be saved i.e your resources/background - i was putting in my location and it isn't working That was my problem - probs should have specified before "/src/emma.jpg" is what i was using Quote Link to comment Share on other sites More sharing options...
Explv Posted January 19, 2018 Share Posted January 19, 2018 15 minutes ago, scriptersteve said: "/src/emma.jpg" is what i was using /resources/emma.jpg /src/YourCode.java Quote Link to comment Share on other sites More sharing options...