Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • 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/Crypto gold? You can purchase vouchers from other users
  • Hide/Show paint


    abdulr

    Recommended Posts

    boolean hidePaint = false;
    
    Rectangle rect = new Rectangle(296, 444, 200, 16);
    Rectangle closePaint = rect;
    Rectangle openPaint = rect;
    Point p;
    public void onMouse(MouseEvent e) {
            p = e.getPoint();
            if (closePaint.contains(p) && !hidePaint) {
            	hidePaint = true;
            } else if (openPaint.contains(p) && hidePaint) {
            	hidePaint = false;
            }
        }
    @Override
    	public void onPaint(Graphics g) {
    		if (!hidePaint) {
    			.......
    		}
            	if (hidePaint) {
            		.....
            	}
        }

     

    Link to comment
    Share on other sites

    3 hours ago, Nex said:
    
    boolean hidePaint = false;
    
    Rectangle rect = new Rectangle(296, 444, 200, 16);
    Rectangle closePaint = rect;
    Rectangle openPaint = rect;
    Point p;
    
    public void onMouse(MouseEvent e) {
            p = e.getPoint();
            if (closePaint.contains(p) && !hidePaint) {
            	hidePaint = true;
            } else if (openPaint.contains(p) && hidePaint) {
            	hidePaint = false;
            }
        }
    
    @Override
    	public void onPaint(Graphics g) {
    		if (!hidePaint) {
    			.......
    		}
            	if (hidePaint) {
            		.....
            	}
        }

     

     

    If the rectangle for closing and opening the paint points to the same memory address, you could take advantage of this and cut the number of lines of code in half.

    	private boolean hidePaint = false;
    	private final Rectangle PAINT_BUTTON = new Rectangle(296, 444, 200, 16);
    
    	@Override
    	public void onMouse(MouseEvent e) {
    		if (PAINT_BUTTON.contains(e.getPoint()))
    			hidePaint = !hidePaint;
    	}
    
    	@Override
    	public void onPaint(Graphics g) {
    		if (!hidePaint) {
    			// ...
    		} else {
    			// ...
    		}
    	}
    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.