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
  • Try asking for help in the chatbox
  • Hide/Show paint


    abdulr
     Share

    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

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.