Jump to content

Welcome to DreamBot!

Download for Free

Supercharge Your Bots

Run unlimited bots today using DreamBot's Covert Mode and
stay more protected.

Upgrade Now
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java 8 installed
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
OSRS Gambling

Interested in advertising your business? Reach out today!

Download the DreamBot client today!
Aeon

Adding an image to paint

Recommended Posts

As the title says, I'm trying to add an image to the screen for my script, but I can't seem to get it to work properly. I found this thread which has a bunch of dead screenshots so it wasn't too useful. Any help in pointing me in the direction would be greatly appreciated!

Share this post


Link to post
Share on other sites

Step 1: Add this method to your main class to return Image objects from a URL:

 private Image getImage(String url) {
    try {
    	return ImageIO.read(new URL(url));
    } catch (IOException e) {
    	e.printStackTrace();
    }
    return null;
}

Step 2: Create an Image property to store the image using this method:

 private final Image paintBackground = getImage("https://i.imgur.com/Muw7swQ.png");

Step 3: Draw the image using graphics in onPaint:

if (paintBackground != null) {
	g.drawImage(paintBackground, 30, 316, null);
}

Sources:

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...