Aeon 43 Posted August 1, 2020 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!
Pixel_Life 24 Posted August 1, 2020 See Hashtag's tutorial here: The "Drawing an image" section. Super simple, that's the tutorial that helped me with it
Succulent 18 Posted August 1, 2020 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:
Aeon 43 Author Posted August 1, 2020 @Succulent Thank you! I'd read through that thread at some point and I guess I didn't remember reading that...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.