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.

SystemTrayManager

Featured Replies

ph34r.png (fetched from an old 2D game API of mine)

package game_context;

import java.awt.AWTException;
import java.awt.SystemTray;
import java.awt.TrayIcon;

/**
 * @author Bjorn Krols (Botre)
 */

public class SystemTrayManager {

	private static SystemTrayManager instance = new SystemTrayManager(); 
	private boolean supported;
	private SystemTray tray;
	
	private SystemTrayManager() {
		supported = SystemTray.isSupported();
		if (!supported) return;
		setTray(SystemTray.getSystemTray());
	}
	
	public static SystemTrayManager getInstance() { return instance == null ? instance = new SystemTrayManager() : instance; }

	private SystemTray getTray() { return supported ? tray : null; }

	private void setTray(SystemTray tray) {
		if (!supported) return;
		this.tray = tray;
	}

	public void setIcon(TrayIcon icon) {
		if (!supported) return;
		try {
			getTray().add(icon);
		} catch (AWTException e) {
			e.printStackTrace();
		}
	}
	
}

Edited by Botre

better 2 throw exception if unsupported

also why is supported static?

Edited by VladBots

  • Author

better 2 throw exception if unsupported

also why is supported static?

 

Making that part throw an exception will make any OS that doesn't support system trays crash :x

Mhm not sure, why not though ?

Edited by Botre

Making that part throw an exception will make any OS that doesn't support system trays crash :x

Mhm not sure, why not though ? 

you're not using it statically

  • 2 weeks later...

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.