Jump to content

JavaFX


macalroy

Recommended Posts

package com.loudpacks.gui;
import org.osbot.rs07.script.Script;

public class Settings extends JFrame {
	
	private JPanel master;
	private Consumer<Boolean> callback;

	public Settings(Script script) {
		master = new JPanel();
		setTitle("Settings");
		setSize(300, 120);
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setLocationRelativeTo(null);
		
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new GridLayout(1, 1, 10, 10));
		buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		JButton buttonStart = new JButton("Start");
		buttonStart.addActionListener(event -> {
			callback.accept(true);
			dispose();
		});
		
		buttonPanel.setMaximumSize(new Dimension(getWidth(), 100));
		buttonPanel.add(buttonStart);
		master.add(buttonPanel);

		master.setLayout(new BoxLayout(master, BoxLayout.Y_AXIS));
		add(master);
		setVisible(true);
	}


	public void setCallback(Consumer<Boolean> callback) {
		this.callback = callback;
	}

}

package com.loudpacks.script;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.script.ScriptManifest;

import com.loudpacks.api.LoudScript;
import com.loudpacks.gui.Settings;

@ScriptManifest(author = "LoudPacks", info = "", logo = "", name = "LoudCCTracker", version = 1.0)
public class main extends LoudScript {
	
	private long start = 0;
	
	public static InventoryMonitor monitor;
	
	@[member='Override']
	public void onStart() {
		Settings settings = new Settings(this);
		settings.setCallback(b -> {
			start = System.currentTimeMillis();
			//add tasks, etc it will hand here til your settings callback is set to true;
			
		});
	}

	@[member='Override']
	public void onExit() {

	}
	
	@[member='Override']
	public void onPaint(Graphics2D g){
		super.onPaint(g);
	}
	

}

Do something like this maybe.

Edited by LoudPacks
Link to comment
Share on other sites

package com.loudpacks.gui;
import org.osbot.rs07.script.Script;

public class Settings extends JFrame {
	
	private JPanel master;
	private Consumer<Boolean> callback;

	public Settings(Script script) {
		master = new JPanel();
		setTitle("Settings");
		setSize(300, 120);
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setLocationRelativeTo(null);
		
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new GridLayout(1, 1, 10, 10));
		buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		JButton buttonStart = new JButton("Start");
		buttonStart.addActionListener(event -> {
			callback.accept(true);
			dispose();
		});
		
		buttonPanel.setMaximumSize(new Dimension(getWidth(), 100));
		buttonPanel.add(buttonStart);
		master.add(buttonPanel);

		master.setLayout(new BoxLayout(master, BoxLayout.Y_AXIS));
		add(master);
		setVisible(true);
	}


	public void setCallback(Consumer<Boolean> callback) {
		this.callback = callback;
	}

}

package com.loudpacks.script;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.script.ScriptManifest;

import com.loudpacks.api.LoudScript;
import com.loudpacks.gui.Settings;

@ScriptManifest(author = "LoudPacks", info = "", logo = "", name = "LoudCCTracker", version = 1.0)
public class main extends LoudScript {
	
	private long start = 0;
	
	public static InventoryMonitor monitor;
	
	@[member='Override']
	public void onStart() {
		Settings settings = new Settings(this);
		settings.setCallback(b -> {
			start = System.currentTimeMillis();
			//add tasks, etc it will hand here til your settings callback is set to true;
			
		});
	}

	@[member='Override']
	public void onExit() {

	}
	
	@[member='Override']
	public void onPaint(Graphics2D g){
		super.onPaint(g);
	}
	

}

Do something like this maybe.

 

 

JavaFX doesn't work like that because the constructor of the Application class can't take an argument

 

Link to comment
Share on other sites

Just so you know, because you are running JavaFX from a Swing application you don't need to extend the application class.

https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/swing-fx-interoperability.htm

because you are running JavaFX from a Swing application

Swing application

Well, I wasn't doing that as far as I know. But that makes it like 20x better.

You sir, are a God.

 

happypepe.jpg

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...