Jump to content

UI for epic bot parameters


Recommended Posts

  • 2 months later...
public class PrivateWalkerGUI extends JFrame {
    private JPanel panel;
    private JLabel label;
    private JComboBox<String> comboBox;
    private JButton button;
    private String areaName;
    private Area area;

    private enum Areas {
        VARROCK ("Varrock", new Area(new Tile(3210, 3422, 0), new Tile(3218, 3433, 0))),
        LUMBRIDGE ("Lumbridge", new Area(new Tile(3221, 3221, 0), new Tile(3226, 3216, 0)));

        private final String name;
        private final Area area;

        Areas(String _name, Area _area) {
            this.name = _name;
            this.area = _area;
        }
    }

    public PrivateWalkerGUI(PrivateWalkerBot bot) {
        setTitle("Private Walker");
        setSize(300, 100);
        setLocationRelativeTo(null);
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());

        panel = new JPanel();
        panel.setLayout(new FlowLayout());

        label = new JLabel("Select an area to walk to: ");
        panel.add(label);

        comboBox = new JComboBox<String>();
        for (Areas a : Areas.values()) {
            comboBox.addItem(a.name);
        }

        panel.add(comboBox);

        button = new JButton("Walk");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                areaName = (String) comboBox.getSelectedItem();
                for (Areas a : Areas.values()) {
                    if (a.name.equals(areaName)) {
                        area = a.area;
                    }
                }
                bot.setArea(area);
            }
        });

        panel.add(button);

        add(panel);

        setVisible(true);
    }
}

This is a very basic implementation of the GUI system in EpicBot.

Epic bot automatically sets the look and feel (laf) of the Java Swing GUI. So you don't really need to worry about it too much.

Edited by crashbashash
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.

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.

×
×
  • Create New...