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.

Explv's Dank GUI Tutorial

Featured Replies

This will help noobs like me and Keven mayne but I hope it doesnt drop my items @ GE :(

  • Author

Nice job, but I do think most use builders though.

 

No one learns by using a builder :xdoge:

  • 3 weeks later...

Why do you dispose of it in onExit()? Wouldn't that get rid of it when the script stops and not when you press the start button?

Edited by Dora

  • Author

Why do you dispose of it in onExit()? Wouldn't that get rid of it when the script stops and not when you press the start button?

 

Yes. When the user stops the script the JFrame is disposed of if it exists.

 

The JFrame is also hidden when the user starts the script:

startButton.addActionListener(e -> { // This code is called when the user clicks the button
    started  = true; // Set the boolean variable started to true
    gui.setVisible(false); // Hide the GUI
});

See the line 

gui.setVisible(false); // Hide the GUI
  • 2 months later...

Why declare a JFrame within the script class? Separate it.

public class GUI extends JFrame {
    public GUI() {
        setTitle("GUI);
        ...
        pack();
        setVisible(true);
    }
}

Instantiate within the script class

public class ShitScript extends Script {
    private GUI gui;
...
    @Override
    public void onStart() {
        gui = new GUI();
    }

    @Override
    public void onExit() {
        if(gui != null) gui.dispose();
    }
...
}

This way, you can manage your GUI without having to trawl through a ton of unrelated code in the script class.

  • Author

Why declare a JFrame within the script class? Separate it.

public class GUI extends JFrame {
    public GUI() {
        setTitle("GUI);
        ...
        pack();
        setVisible(true);
    }
}

Instantiate within the script class

public class ShitScript extends Script {
    private GUI gui;
...
    @Override
    public void onStart() {
        gui = new GUI();
    }

    @Override
    public void onExit() {
        if(gui != null) gui.dispose();
    }
...
}

This way, you can manage your GUI without having to trawl through a ton of unrelated code in the script class.

 

Why are you reading a GUI tutorial noob :kappa:

Edited by Explv

Why are you reading a GUI tutorial noob emote3.png

Bc someone followed it and were having issues :boge:

// Declare two constants for width and height of the GUI
final int GUI_WIDTH = 350, GUI_HEIGHT = 75;
        
// Get the size of the screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        
// Calculating x and y coordinates
final int gX = (int) (screenSize.getWidth() / 2) - (GUI_WIDTH / 2);
final int gY = (int) (screenSize.getHeight() / 2) - (GUI_HEIGHT / 2);
Or to set a size to exactly your liking

gui#setSize(int width, int heigth) //size of the gui;
gui#setLocationRelativeTo(null); //centers the gui
Nice guide, will help the noobs. good job! biggrin.png

Edited by Psvxe

  • Author
// Declare two constants for width and height of the GUI
final int GUI_WIDTH = 350, GUI_HEIGHT = 75;
        
// Get the size of the screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        
// Calculating x and y coordinates
final int gX = (int) (screenSize.getWidth() / 2) - (GUI_WIDTH / 2);
final int gY = (int) (screenSize.getHeight() / 2) - (GUI_HEIGHT / 2);
Or to set a size to exactly your liking

gui#setSize(int width, int heigth) //size of the gui;
gui#setLocationRelativeTo(null); //centers the gui
Nice guide, will help the noobs. good job! biggrin.png

 

 

Nice, I wrote this a while ago :P  definitely more succinct to use setLocationRelativeTo(null)  

Edited by Explv

Nice, I wrote this a while ago tongue.png  definitely more succinct to use setLocationRelativeTo(null)  

 

Still a good read for beginners who want to make a GUI :)

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.