maxime 0 Share Posted October 1, 2016 hi i am looking to make Area i know people will just comment (Area tree = new Area()I need to make Area for Each TreeTree areaOak area ect..in only 1 script with Gui when you select example : Yew it will go to the Yew Area , Tree to the TreeArea , Oak to the OakAreaThanks for helping. Link to comment Share on other sites More sharing options...
Stormscythe 263 Share Posted October 1, 2016 The way to do this (atleast how I do) is by making 3 classes: 1. The main class for the script (main) 2. The GUI class for the script (gui) 3. A class to pass the variables from the gui into the script (scriptvars) Make the GUI take a variable of the scriptvars class in the constructor: public gui(ScriptVars sv){ public String selectedArea } When pressing the "Start" button in your script, pass the selected value in the GUI into a field in the scriptvars class: startButton.addActionListener(new ActionListener() { sv.selectedArea = comboBox.getSelectedItem().ToString(); } In your mainclass, initialise the GUI and Scriptvars class as follows: public void onStart(){ sv = new ScriptVars(); gui = new GUI(sv); gui.setVisible(true); while(gui.isVisible()){ sleep(10,30); } } I hope this helps. If it's too confusing, let me know. Link to comment Share on other sites More sharing options...
maxime 0 Author Share Posted October 2, 2016 The way to do this (atleast how I do) is by making 3 classes: 1. The main class for the script (main) 2. The GUI class for the script (gui) 3. A class to pass the variables from the gui into the script (scriptvars) Make the GUI take a variable of the scriptvars class in the constructor: public gui(ScriptVars sv){ public String selectedArea } When pressing the "Start" button in your script, pass the selected value in the GUI into a field in the scriptvars class: startButton.addActionListener(new ActionListener() { sv.selectedArea = comboBox.getSelectedItem().ToString(); } In your mainclass, initialise the GUI and Scriptvars class as follows: public void onStart(){ sv = new ScriptVars(); gui = new GUI(sv); gui.setVisible(true); while(gui.isVisible()){ sleep(10,30); } } I hope this helps. If it's too confusing, let me know. send you a pm Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.