Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Paint disappearing when minimizing client, will only show when I hover over it ?

Featured Replies

This has been killing me for too long now :(

 

My paint is :

  private BufferedImage img = null;
    private void setBuffImage(){
    try {
        img = ImageIO.read(new URL("http://i.imgur.com/hxNYgK6.jpg"));
    } catch (IOException e) {
    }
    }
   
    private static final Font font1 = new Font("Gentium Basic", 0, 16);
    private static final Color color1 = Color.WHITE;
    @Override
    public void onPaint(Graphics2D g) {        
            timeRan = System.currentTimeMillis() - this.timeBegan;
            g.drawImage(img, 0, 335, null);
            g.setFont(font1);
            g.setColor(color1);
           
            g.drawString("Rewards collected: "+picked,70, 425);
            g.drawString("Farming XP(per hour): "+experienceTracker.getGainedXP(Skill.FARMING)+"("+experienceTracker.getGainedXPPerHour(Skill.FARMING)+")",280, 425);
          
            g.drawString("Status: "+statusWrite(),130, 455);
            g.drawString("Run time: " + ft(timeRan), 360, 385);
        
    }

 

the img gets set on script start. But everytime I minimise my client and open it again, my paint has disappeared and will only come back after I move my cursor on screen.

I have reason to believe setBuffImage() is the culprit as I didn't have this problem before adding it.

make a graphics var

Graphics2D paint = (Graphics2D) g.create();

and do:

paint.drawString(); etc.

 

I think its because you are using an entity debugger which overrides your paint.

Not relevant to your problem but in your onPaint you should also do a null check for your image.

if(img != null) g.drawImage(img, null, 0, 335);

 

Not relevant to your problem but in your onPaint you should also do a null check for your image.

if(img != null) g.drawImage(img, null, 0, 335);

 

Why?

If it was initialized correctly there's no need to check if it's null 30 times per second.

 

@OP empty try-catch blocks are a big no-no.

Why?

If it was initialized correctly there's no need to check if it's null 30 times per second.

 

@OP empty try-catch blocks are a big no-no.

 

Well it has no impact on performance.

 

If imgur fucks up your script will still work.

 

onPaint runs on a separate thread so I think there could also be a point at the start where img is null

Edited by Explv

  • Author

Well it has no impact on performance.

 

If imgur fucks up your script will still work.

 

onPaint runs on a separate thread so I think there could also be a point at the start where img is null

 

Yeah, I should really move it to a local file :X

 

 

make a graphics var

Graphics2D paint = (Graphics2D) g.create();

and do:

paint.drawString(); etc.

 

I think its because you are using an entity debugger which overrides your paint.

 

I'll look into this now thanks for the fast reply

Well it has no impact on performance.

 

If imgur fucks up your script will still work.

 

onPaint runs on a separate thread so I think there could also be a point at the start where img is null

 

You might be right since onPaint gets called before onStart.

 

@OP try this

public class Script {

	public static BufferedImage PAINT_BACKGROUND;
	
	static {
		try {
			PAINT_BACKGROUND = ImageIO.read(new URL("http://i.imgur.com/hxNYgK6.jpg"));
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	// onstart ...
	// onloop ...
	
}
  • Author

 

You might be right since onPaint gets called before onStart.

 

@OP try this

public class Script {

	public static BufferedImage PAINT_BACKGROUND;
	
	static {
		try {
			PAINT_BACKGROUND = ImageIO.read(new URL("http://i.imgur.com/hxNYgK6.jpg"));
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	// onstart ...
	// onloop ...
	
}

 

Sorry, the only thing that gets called in the onStart, relative to the onPaint, is the setBuffImage() call

Sorry, the only thing that gets called in the onStart, relative to the onPaint, is the setBuffImage() call

 

onStart usually gets called AFTER the first onPaint called.

So if you use onStart to initialize variables used inside onPaint you could run into trouble.

You could use a static block to make sure the image gets initialize on time or you could null check the image variable in your onPaint.

 

Or maybe it's something entirely different that's causing the issue :p Getting any errors? Try providing a gif if you can.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.