Advertisement
Guest User

Paint Tutorial Example 7

a guest
Aug 20th, 2015
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Image;
  4. import java.awt.Point;
  5. import java.awt.Rectangle;
  6. import java.awt.event.MouseEvent;
  7. import java.io.IOException;
  8. import java.net.URL;
  9. import java.text.DecimalFormat;
  10. import java.util.concurrent.TimeUnit;
  11.  
  12. import javax.imageio.ImageIO;
  13.  
  14. import org.dreambot.api.methods.skills.Skill;
  15. import org.dreambot.api.methods.tabs.Tab;
  16. import org.dreambot.api.script.AbstractScript;
  17. import org.dreambot.api.script.Category;
  18. import org.dreambot.api.script.ScriptManifest;
  19. import org.dreambot.api.utilities.Timer;
  20. import org.dreambot.api.wrappers.interactive.GameObject;
  21.  
  22.  
  23. @ScriptManifest(author = "Pug", name = "paint tutorial", version = 0.01, description = "0.01", category = Category.MISC)
  24. public class test extends AbstractScript
  25. {
  26.  
  27.     // PAINT VARIABLE DECLARATIONS
  28.     Point p;
  29.     boolean hide = false;
  30.     Rectangle close = new Rectangle(10, 457, 118, 20);
  31.     Rectangle open = new Rectangle(10, 457, 118, 20);
  32.     private final Image bg = getImage("http://www.linktoyourimage.com/image.jpg");
  33.     private final Image showImage = getImage("http://www.linktoyourimage.com/image.jpg");
  34.     private final Image hideImage = getImage("http://www.linktoyourimage.com/image.jpg");
  35.    
  36.     private Image getImage(String url)
  37.     {
  38.         try
  39.         {
  40.             return ImageIO.read(new URL(url));
  41.         }
  42.         catch (IOException e) {}
  43.         return null;
  44.     }
  45.    
  46.     public void onMouse(MouseEvent e)
  47.     {
  48.         p = e.getPoint();
  49.         if (close.contains(p) && !hide) {
  50.             hide = true;
  51.         } else if (open.contains(p) && hide) {
  52.             hide = false;
  53.         }
  54.     }
  55.    
  56.     // ONSTART() METHOD
  57.     public void onStart()
  58.     {
  59.  
  60.     }
  61.  
  62.     // ONLOOP() METHOD
  63.     @Override
  64.     public int onLoop()
  65.     {
  66.         return 0;
  67.     }
  68.    
  69.     //OUR PAINT METHOD
  70.     public void onPaint(Graphics g)
  71.     {
  72.         if (!hide)
  73.         {
  74.             g.drawImage(nameOfImageVariable, X, Y, null);       // background image
  75.             g.setColor(Color.white);                            // font beyond this point will be white
  76.             g.drawString(timer.formatTime(), 295, 349);         // show time
  77.             g.drawImage(nameOfHideImageVariable, X, Y, null);   // image for hide button - X & Y must match your hide rectangle
  78.         }
  79.         if(hide)
  80.         {
  81.             g.drawImage(nameOfShowImageVariable, X, Y, null);       // image for show button - X & Y must match your show rectangle
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement