Jump to content

Gui Checkbox for Banking or Dropping


Recommended Posts

Posted

Just getting back into scripting. Trying to learn how to implement a GUI checkbox for which the user can select if they wish to bank or drop items. I have my GUI panel made, I just cannot figure out how to pass data from my GUI class, Main class, and drop/bank class task. If anyone can point me in the right direction! or has tips! please let me know! Thanks greatly in advance!!!

 

 

Posted
1 minute ago, Gunman said:

@mark jacobs Are you asking how to make a check box? Or are you asking how to determine the logic of banking and dropping based on this checkbox?

The logic behind it. My GUI design is there, the logic part is what I am struggling with. Here is what I have so far that is not quite working:

Gui class variables

private boolean DropToggle;
private JCheckBox DropCheckBox;

Gui class Checkbox

//Dropping Check Box
            DropCheckBox = new JCheckBox("Drop?");
            DropCheckBox.setFont(new Font("Sans Serif", Font.BOLD, 15));
            DropCheckBox.setBounds(53, 285, 150, 20);
            settingsPanel.add(DropCheckBox);
            DropCheckBox.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        DropCheckBox.setSelected(true);
                        DropToggle = true;
                    }
                });

Gui Call method

public boolean isDropBoxChecked(){
        return DropToggle;
    }

Main class OnSstart

 if(gui.isDropBoxChecked()){
            tasks.add(new DropFish(this));
        }

Drop task

 

public class DropFish extends Task{

    private boolean dropItemsEnabled;

    public DropFish(EioFisher script) {
        super(script);
    }


    @Override
    public boolean canProcess() throws InterruptedException {
        return script.inventory.isFull();
    }

    @Override
    public void process() throws InterruptedException {
        script. currentState = Status.DROPPING;

        script.inventory.dropAllExcept("Small fishing net");
    }
}

When I check the box it does nothing.

 

And here is a visual of my GUI design

2acdea7f3abd0a5518a3fe8c3f48221a.png

I still have to work on the other sections, but I was starting with figuring out the dropping and banking first before I even tried the Type, Tool, and Location.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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