Guest Apogee Posted April 11, 2014 Share Posted April 11, 2014 I know some of the API to display paint, but i really don't want JUST text on screen. IS there a way i can put an image i made on screen? (I know it is possible due to it being done on other scripts, i'm just unsure of how.) If you any of you know of a thread or section that has a guide or walkthrough of all of it, a link to that would be HIGHLY appreciated. Thanks Link to comment Share on other sites More sharing options...
Deffiliate Posted April 11, 2014 Share Posted April 11, 2014 (edited) Welp it's pretty simple acutally. All you need is an Image, which you get from a URL. You need to create 2 instance variables: Image paintImg; URL paintUrl; then in your onStart do the following: try { paintUrl = new URL("yourPaint.com"); } catch (MalformedURLException e1) { log("Problem loading URL."); e1.printStackTrace(); } try { paintImg = ImageIO.read(paintUrl); } catch (IOException e1) { log("Problem loading image from URL."); e1.printStackTrace(); } Finally, paint it in your onPaint(). g.drawImage(paintImg, x, y, width,height,this); Edited April 11, 2014 by Deffiliate Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 11, 2014 Share Posted April 11, 2014 Welp it's pretty simple acutally. All you need is an Image, which you get from a URL. You need to create 2 instance variables: Image paintImg; URL paintUrl = new URL("yourPaint.com"); then in your onStart do the following: paintImg = ImageIO.read(url); Finally, paint it in your onPaint(). g.drawImage(paintImg, x, y, width,height,this); what would "this" be? Link to comment Share on other sites More sharing options...
Deffiliate Posted April 11, 2014 Share Posted April 11, 2014 (edited) what would "this" be? "this" refers to your instance of your class. It means your main class will watch over the image. Don't change it just keep it as "this". Also, make sure you add those changes I made to my post. Edited April 11, 2014 by Deffiliate Link to comment Share on other sites More sharing options...
Dog_ Posted April 11, 2014 Share Posted April 11, 2014 what would "this" be? http://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html Link to comment Share on other sites More sharing options...
oTroll Posted April 11, 2014 Share Posted April 11, 2014 "this" refers to a parameter or a local variable that has the same name or is similar to another variable (I think) // Global Variable int Vara = 0; public void DoThis(int Vara) { this.Vara = Vara; // Grabs the parameter and sets it to the global variable } Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 12, 2014 Share Posted April 12, 2014 Welp it's pretty simple acutally. All you need is an Image, which you get from a URL. You need to create 2 instance variables: Image paintImg; URL paintUrl; then in your onStart do the following: try { paintUrl = new URL("yourPaint.com"); } catch (MalformedURLException e1) { log("Problem loading URL."); e1.printStackTrace(); } try { paintImg = ImageIO.read(paintUrl); } catch (IOException e1) { log("Problem loading image from URL."); e1.printStackTrace(); } Finally, paint it in your onPaint(). g.drawImage(paintImg, x, y, width,height,this); paintIMG and paintURL are both "wrong" according to eclipse. As far as i can tell, there's nothing to import. Link to comment Share on other sites More sharing options...
Deffiliate Posted April 12, 2014 Share Posted April 12, 2014 paintIMG and paintURL are both "wrong" according to eclipse. As far as i can tell, there's nothing to import. Because you haven't done this... You need to import Image and URL... import javax.imageio.ImageIO; import java.net.URL; Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 12, 2014 Share Posted April 12, 2014 Because you haven't done this... You need to import Image and URL... import javax.imageio.ImageIO; import java.net.URL; Hmmm, I have those imports and i have created the instance variables. Does it matter where i declare them? Link to comment Share on other sites More sharing options...
Deffiliate Posted April 12, 2014 Share Posted April 12, 2014 (edited) Hmmm, I have those imports and i have created the instance variables. Does it matter where i declare them? You can declare an instance variable anywhere after this: public class MyScript extends Script { Edited April 12, 2014 by Deffiliate Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 12, 2014 Share Posted April 12, 2014 (edited) You can declare an instance variable anywhere after this: public class MyScript extends Script { Mmmkay, thank you for the help. You're practically spoon feeding me and i can't get this to work. I'll figure it out. If it helps, http://gyazo.com/d8b1cbcb019ab0467589d88d9053922c EDIT: Solved that issue, Now i'm getting this. http://gyazo.com/660780ce0d959268249e89b5c1a6d35d Edited April 12, 2014 by Bitter Link to comment Share on other sites More sharing options...
Deffiliate Posted April 12, 2014 Share Posted April 12, 2014 Mmmkay, thank you for the help. You're practically spoon feeding me and i can't get this to work. I'll figure it out. If it helps, http://gyazo.com/d8b1cbcb019ab0467589d88d9053922c /no problem. remove the URL and Image here: http://puu.sh/85795.png, you've already got it declared about. Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 12, 2014 Share Posted April 12, 2014 (edited) /no problem. remove the URL and Image here: http://puu.sh/85795.png, you've already got it declared about. Yep that was exactly the problem. I just wish i had seen that sooner xD. Now i'm getting this. http://gyazo.com/660...49e89b5c1a6d35d Edited April 12, 2014 by Bitter Link to comment Share on other sites More sharing options...
Deffiliate Posted April 12, 2014 Share Posted April 12, 2014 Yep that was exactly the problem. I just wish i had seen that sooner xD. Now i'm getting this. http://gyazo.com/660...49e89b5c1a6d35d uhmm simplest option would be to change "this" to null. Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 12, 2014 Share Posted April 12, 2014 uhmm simplest option would be to change "this" to null. PERFECT. Can i rep you without actually doing a transaction with you? I went to rep and it was making me choose from buyer, or seller or something. :x Link to comment Share on other sites More sharing options...