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.

Gui-ish Help

Featured Replies

wat do


 


Issue:


 


I have this sick GUI for a script right? How do I get it to start/load a class from a different package?


 


 


  1. Select option from a JComboBox
  2. Hit "start"
  3. Start selected item with a matching class name?

I've tried populating the JComboBox values two different ways, but neither prevailed, when trying to start the other class.


 


 


My onLoop method: (I want to assume that the problem is in this hopefully)



@Override
public int onLoop() throws InterruptedException {
try {
Class.forName(getName(), true, null);
// Class.forName((String) questName);
log("trying to start: " + questName);
} catch (Exception e) {
log("failed to start: " + questName);
e.printStackTrace();
}

return 500;
}

a straight forward way to do it is to have your class called 'Gui' which contains the code for your gui. in that class, you have an actionlistener for your start button which gets the current selected settings and sends them statically to your main class.

 

here's how the actionlistener goes:

		btnStart.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				//code here eg: 
                                Main.food = (String) foodComboBox.getSelectedItem();
				setVisible(false);
			}
		});

and your main class:

//vars:
public static String food;
Gui GUI;


@Override
	public void onStart() {
                GUI = new Gui();
                GUI.setVisible(true);
		log("======================================================================");		        log("script started or whatever");
	}


@Override
    public int onLoop() {
         while(GUI.isVisible())
                sleep(400);
    return 200;
}

then the gui will feed you the values chosen on the gui when the start button is pressed, at the same time as running the script (breaking the while loop) and closing the gui.

 

apa


ps sorry for any typos, wrote most of the code in the reply box so there may be a few errors

  • Author

a straight forward way to do it is to have your class called 'Gui' which contains the code for your gui. in that class, you have an actionlistener for your start button which gets the current selected settings and sends them statically to your main class.

 

here's how the actionlistener goes:

		btnStart.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				//code here eg: 
                                Main.food = (String) foodComboBox.getSelectedItem();
				setVisible(false);
			}
		});

and your main class:

//vars:
public static String food;
Gui GUI;


@Override
	public void onStart() {
                GUI = new Gui();
                GUI.setVisible(true);
		log("======================================================================");		        log("script started or whatever");
	}


@Override
    public int onLoop() {
         while(GUI.isVisible())
                sleep(400);
    return 200;
}

then the gui will feed you the values chosen on the gui when the start button is pressed, at the same time as running the script (breaking the while loop) and closing the gui.

 

apa

ps sorry for any typos, wrote most of the code in the reply box so there may be a few errors

 

I have my GUI in my 'main' file. And, I have already added a ActionListenser:

JButton button = new JButton("Start");
    button.addActionListener(event -> {
        questName = (String) questBox.getSelectedItem().toString();
        log("Selected Quest: " + questName);
        frame.dispose();
        synchronized(Test.class) {
            Test.class.notify();
        }
        
        
    });

So, it successfully logs "Selected Quest", and disposes.

 

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.