Fran 99 Share Posted March 2, 2015 (edited) 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 Edited March 2, 2015 by Franjey Link to comment Share on other sites More sharing options...
GoldenGates 72 Share 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. :/ Link to comment Share on other sites More sharing options...
Vlad 216 Share 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/ DefCon 1 Link to comment Share on other sites More sharing options...
Chris 154 Share 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 Link to comment Share on other sites More sharing options...
Explicit 213 Share 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 Link to comment Share on other sites More sharing options...
Vlad 216 Share Posted March 2, 2015 (edited) plz stop linking ur shit code kthx Tell me what's wrong and I will improve it. =) Edited March 2, 2015 by Vlad Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted March 2, 2015 Tell me what's wrong and I will improve it. =) u wrote it Link to comment Share on other sites More sharing options...
Fran 99 Author Share 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 Link to comment Share on other sites More sharing options...
Polish Civil 90 Share Posted March 3, 2015 u wrote it Damn u rude boi. Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted March 3, 2015 Damn u rude boi. vlad knows i love him Link to comment Share on other sites More sharing options...
Recommended Posts