Fran 99 Posted March 2, 2015 Hey guys! Hope you're all doing great. Was just wondering, as I am getting used to working with GUIs & scripting for RuneScape, if anyone could help with the following thing: I want the JTextField String that I introduce when I start the GUI, to be the input String in my main class. Please see the following: I have my GUI class, added a JTextField, as shows the following: logsNameField = new JTextField(); contentPane.add(logsNameField); logsNameField.addActionListener(new ActionListener () { @Override public void actionPerformed(ActionEvent arg0) { String logsName = logsNameField.getText(); } } And in my main class, I want the input logsName from the GUI class, to be the input as follows: getInventory().interactWithItem(input from logsName, "Use"); I know a way to do this would be using Getters, but how would that work with a JTextField? If someone can be explicit, I will greatly appreciate
GoldenGates 72 Posted March 2, 2015 The way I see it, the best method is to process everything in your Start Button. There's no reason to add it into your TextField's listener unless you want the GUI to be open and editable at any time. :/
Vlad 216 Posted March 2, 2015 The way I see it, the best method is to process everything in your Start Button. There's no reason to add it into your TextField's listener unless you want the GUI to be open and editable at any time. :/ This. I'll also re-post what I said to you on Skype: You should be using private variables in your GUI class along with getters for them. You should be making a new instance of your GUI in your script, use that to get data, then assign them to variables in your main script class with the getters and dispose of the GUI instance. Then you should be using those variables from your main class for your script. Example: http://dreambot.org/forums/index.php?/topic/880-haku-s-aio-woodcutter-source/
Chris 154 Posted March 2, 2015 I've always made a GUI class which contains the structure of my GUI. Inside of that class I have getters for the user input. Create an instance of the GUI class on startup to access it while the script is running
Explicit 213 Posted March 2, 2015 Example: http://dreambot.org/forums/index.php?/topic/880-haku-s-aio-woodcutter-source/ plz stop linking ur shit code kthx
Vlad 216 Posted March 2, 2015 plz stop linking ur shit code kthx Tell me what's wrong and I will improve it. =)
Fran 99 Author Posted March 3, 2015 The way I see it, the best method is to process everything in your Start Button. There's no reason to add it into your TextField's listener unless you want the GUI to be open and editable at any time. :/ This. I'll also re-post what I said to you on Skype: You should be using private variables in your GUI class along with getters for them. You should be making a new instance of your GUI in your script, use that to get data, then assign them to variables in your main script class with the getters and dispose of the GUI instance. Then you should be using those variables from your main class for your script. Example: http://dreambot.org/forums/index.php?/topic/880-haku-s-aio-woodcutter-source/ I've always made a GUI class which contains the structure of my GUI. Inside of that class I have getters for the user input. Create an instance of the GUI class on startup to access it while the script is running Okay thanks guys I use to do the same thing, maybe anyone had a better way
Recommended Posts
Archived
This topic is now archived and is closed to further replies.