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.

Another question from me! [GUI]

Featured Replies

Hey everyone, how are you all doing?

 

This week i have been focussing on Java GUI. I have watched the JavaFX tutorial from Thenewboston. 

But now. I want to create a GUI for my script, but i have no idea how to make the GUI visible when the script has been selected. I have asked this once, and i got answers. But i tried to look up the topic, and i think it has been deleted.

 

Hope you all can help me.

 

 

Sebastian.

Edited by OSRS Sebastian

If you got another class you call the method from another class from onStart in the main class

I.e

onStart{

GUI.Initialise();

}

Gui represents the class. initialise represents the method you have that contains the gui components.

EDIT: and make sure your method in the gui class has:

jFrame.setVisible(true);

 

Edited by Viliuks

  • Author

If you got another class you call the method from another class from onStart in the main class

I.e

onStart{

GUI.Initialise();

}

Gui represents the class. initialise represents the method you have that contains the gui components.

 

I tried this. Got an error that i needed to create a method. I did, but the gui didn't pop up.

 

Edit: Didn't read your edit before posting this. But, when i do. jFrame gives an error. Maybe because i use JavaFX?

Edited by OSRS Sebastian

I tried this. Got an error that i needed to create a method. I did, but the gui didn't pop up.

 

Edit: Didn't read your edit before posting this. But, when i do. jFrame gives an error. Maybe because i use JavaFX?

no jFrame. is how you named your JFrame

its the name you gave JFrame jFrame = new JFrame();

  • Author

You lost me there. 

 

I wanted to import this GUI.java to my main.java wich is the bot script. What you see, is one GUI tutorial from Thenewboston.

Maybe you can help me better now: 

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class GUI extends Application{

	   Stage window;
	    Scene scene;
	    Button button;

	    public static void main(String[] args) {
	        launch(args);
	    }
	    
	    

	    @Override
	    public void start(Stage primaryStage) throws Exception {
	    	window = primaryStage;
	        window.setTitle("Choose something");
	        button = new Button("Click me");

	        ChoiceBox<String> choiceBox = new ChoiceBox<>();

	        choiceBox.getItems().add("Apples");
	        choiceBox.getItems().add("Bananas");
	        choiceBox.getItems().addAll("Bacon", "Ham", "Meatballs");

	        choiceBox.setValue("Apples");

	        button.setOnAction(e -> getChoice(choiceBox));

	        VBox layout = new VBox(10);
	        layout.setPadding(new Insets(20, 20, 20, 20));
	        layout.getChildren().addAll(choiceBox, button);

	        scene = new Scene(layout, 300, 250);
	        window.setScene(scene);
	        window.show();
	    }

	    //To get the value of the selected item
	    private void getChoice(ChoiceBox<String> choiceBox){
	        String food = choiceBox.getValue();
	        System.out.println(food);
	    }

		public static void Initialise() {
			
		}
}

 

You lost me there. 

 

I wanted to import this GUI.java to my main.java wich is the bot script. What you see, is one GUI tutorial from Thenewboston.

Maybe you can help me better now: 

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class GUI extends Application{

	   Stage window;
	    Scene scene;
	    Button button;

	    public static void main(String[] args) {
	        launch(args);
	    }
	    
	    

	    @Override
	    public void start(Stage primaryStage) throws Exception {
	    	window = primaryStage;
	        window.setTitle("Choose something");
	        button = new Button("Click me");

	        ChoiceBox<String> choiceBox = new ChoiceBox<>();

	        choiceBox.getItems().add("Apples");
	        choiceBox.getItems().add("Bananas");
	        choiceBox.getItems().addAll("Bacon", "Ham", "Meatballs");

	        choiceBox.setValue("Apples");

	        button.setOnAction(e -> getChoice(choiceBox));

	        VBox layout = new VBox(10);
	        layout.setPadding(new Insets(20, 20, 20, 20));
	        layout.getChildren().addAll(choiceBox, button);

	        scene = new Scene(layout, 300, 250);
	        window.setScene(scene);
	        window.show();
	    }

	    //To get the value of the selected item
	    private void getChoice(ChoiceBox<String> choiceBox){
	        String food = choiceBox.getValue();
	        System.out.println(food);
	    }

		public static void Initialise() {
			
		}
}

in on start put: 

GUI.Start();

and you don't need the jFrame.setVisible(true), you already have window.show()

  • Author

in on start put: 

GUI.Start();

and you don't need the jFrame.setVisible(true), you already have window.show()

 

Didn't do anything. It gave an error that i needed to create a method in GUI.java. So i did, but left it like this: 

	public static void Start() {
			// TODO Auto-generated method stub
			
		}

 

Didn't do anything. It gave an error that i needed to create a method in GUI.java. So i did, but left it like this: 

	public static void Start() {
			// TODO Auto-generated method stub
			
		}

What error?

  • Author

@Viliuks "The method Start() is undefined for the type GUI". "1 quick fix available: Create method start() in class GUI."

@Viliuks "The method Start() is undefined for the type GUI". "1 quick fix available: Create method start() in class GUI."

it could possibly be: GUI.main(); if it doesn't I'm clueless then.

  • Author

@viliuks didn't work either.. Well. Thanks for your time buddy :)

 

Anyone else have the answer?

@viliuks didn't work either.. Well. Thanks for your time buddy smile.png

 

Anyone else have the answer?

If you want I could give you an already made java gui which you could use.

  • Author

If you want I could give you an already made java gui which you could use.

 

Would be very sweet. I can learn from that. 

Would be very sweet. I can learn from that. 

http://pastebin.com/FYnKDJTE

just add: GUI.Window(this); in the onStart method :)

and try to look what each thing does although I commented stuff in.

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.