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.

How do I make a GUI for my script?

Featured Replies

I am familiar with java, but I am brand new to scripting and the OSBot API. I looked in the API for some GUI, I could not find anything. So I tried to open up a JFrame using Java Swing on the script start method.. I am looking to just put some checkboxes and some dropdowns for my woodcutting script for Ex: Pick from yews or willows. Thanks!

Create new class for the GUI (I prefer Eclipse Windowbuilder) and create new JFrame. Then in your onStart() method set the gui visible and while it is visible read the data. And ofcourse a button to hide the gui and start the script.

  • Author

Yup, ive used it once before. Ty tho. Love this community. <3

Here I made it quickly for you

public class GUI extends JFrame {

	private JPanel contentPane;
	public JButton btnNewButton;
	public JComboBox<String> comboBox;
	public GUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 148, 108);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		btnNewButton = new JButton("New button");
		btnNewButton.addActionListener(ae -> setVisible(false));
		btnNewButton.setBounds(20, 42, 89, 23);
		contentPane.add(btnNewButton);
		
		comboBox = new JComboBox<String>();
		comboBox.setModel(new DefaultComboBoxModel<String>(new String[] {"Willow", "Yew"}));
		comboBox.setBounds(10, 11, 121, 20);
		contentPane.add(comboBox);
	}
}

Also in your onStart

private int tree; //0 -> willow, 1 -> yew
	public void onStart() {
		GUI g = new GUI();
		g.setVisible(true);
		while(g.isVisible()) {}
		tree = g.comboBox.getSelectedIndex();
	}

And btw API has nothing to do with gui

Here I made it quickly for you

public class GUI extends JFrame {

	private JPanel contentPane;
	public JButton btnNewButton;
	public JComboBox<String> comboBox;
	public GUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 148, 108);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		btnNewButton = new JButton("New button");
		btnNewButton.addActionListener(ae -> setVisible(false));
		btnNewButton.setBounds(20, 42, 89, 23);
		contentPane.add(btnNewButton);
		
		comboBox = new JComboBox<String>();
		comboBox.setModel(new DefaultComboBoxModel<String>(new String[] {"Willow", "Yew"}));
		comboBox.setBounds(10, 11, 121, 20);
		contentPane.add(comboBox);
	}
}

Also in your onStart

private int tree; //0 -> willow, 1 -> yew
	public void onStart() {
		GUI g = new GUI();
		g.setVisible(true);
		while(g.isVisible()) {}
		tree = g.comboBox.getSelectedIndex();
	}

And btw API has nothing to do with gui

Don't forget to post your Swing related code to the Event Dispatch Thread! Ensures no inconcistencies with any GUI code that may be executing.

 

As for the busy-waiting, wait/notify (guarded blocks) would be the best solution for what you want to achieve. It ensures a thread isn't continuously running while not executing any code (consuming CPU power).

 

If you choose to busy-wait (maybe you find wait/notify too complex, which if so, message me), you should at least sleep for 1 or 2 millisec between each iteration, to ensure CPU usage isn't at max (You'd be surprised how much 2 ms helps). Hope you found this info beneficial! :) And thanks for the contribution!

Edited by fixthissite

Create new class for the GUI (I prefer Eclipse Windowbuilder) and create new JFrame. Then in your onStart() method set the gui visible and while it is visible read the data. And ofcourse a button to hide the gui and start the script.

 

Look up a tutorial for eclipse window builder.

pfft

 

Netbeans UI builder > Eclipse UI builder

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.