Guest Apogee Posted April 16, 2014 Share Posted April 16, 2014 I've built a GUI with jformdesigner in eclipse. I have imported the gui to my script.I don't know how to do the following:A: Make the GUI open on script start. B: After the user presses Start on the GUI, the script starts. (not before.) Link to comment Share on other sites More sharing options...
oTroll Posted April 16, 2014 Share Posted April 16, 2014 (edited) A. In the first loop that runs in your script, open the GUI. This includes creating the dimensions and the .setVisible() method. B. Set a boolean called "start" equal to false and when the user presses the Start button on your GUI to set the boolean to true. Have this boolean as a condition that runs the main loop of your script. After the user presses the start button on the GUI, you should also dispose of the GUI to save some resources Edited April 16, 2014 by oTroll Link to comment Share on other sites More sharing options...
Deffiliate Posted April 16, 2014 Share Posted April 16, 2014 (edited) Some more info: A) I'd just like to add that usually JFormDesigner usually comes with an initComponents() method, which will initialize all the components. Make sure that this is called in the constructor of you GUI object. Then all you need to do in onStart() is myGui.setVisible(true) B ) To check when the player click a button you'll need to register a new ActionListener to your start button: then in the actionPerformed method you can set the "Start" boolean to true. Edited April 16, 2014 by Deffiliate Link to comment Share on other sites More sharing options...
Joseph Posted April 16, 2014 Share Posted April 16, 2014 Create a Boolean within your GUI class. Add an event handler on your start button , within the event handler invert the Boolean, also dispose the GUI. In your main class within your onloop set the GUI visible. Then you will sleep while your GUI is still running Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 17, 2014 Share Posted April 17, 2014 Some more info: A) I'd just like to add that usually JFormDesigner usually comes with an initComponents() method, which will initialize all the components. Make sure that this is called in the constructor of you GUI object. Then all you need to do in onStart() is myGui.setVisible(true) B ) To check when the player click a button you'll need to register a new ActionListener to your start button: then in the actionPerformed method you can set the "Start" boolean to true. This is the best code response i have ever gotten. Very clear, thank you. Some more info: A) I'd just like to add that usually JFormDesigner usually comes with an initComponents() method, which will initialize all the components. Make sure that this is called in the constructor of you GUI object. Then all you need to do in onStart() is myGui.setVisible(true) B ) To check when the player click a button you'll need to register a new ActionListener to your start button: then in the actionPerformed method you can set the "Start" boolean to true. http://gyazo.com/e2f421581d27c474bcb0746498a89900 Having an issue however. Everything you said made complete sense, but why would i need a bool for this? 1 Link to comment Share on other sites More sharing options...
Deffiliate Posted April 17, 2014 Share Posted April 17, 2014 (edited) This is the best code response i have ever gotten. Very clear, thank you. http://gyazo.com/e2f421581d27c474bcb0746498a89900 Having an issue however. Everything you said made complete sense, but why would i need a bool for this? You might not have the GUI class setup right. It should extend JFrame, that way it will inherit the isVisible boolean from the JFrame. Edited April 17, 2014 by Deffiliate Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 17, 2014 Share Posted April 17, 2014 You might not have the GUI class setup right. It should extend JFrame, that way it will inherit the isVisible boolean from the JFrame. http://gyazo.com/bb1713c2afde5398e89de63ab5b9d0d3 I extended it. I'm now getting this: http://gyazo.com/663823a1869812936d6fb0d3c33dddd4 I also tried isVisible(). Neither seem to be working :c Link to comment Share on other sites More sharing options...
Swizzbeat Posted April 17, 2014 Share Posted April 17, 2014 http://gyazo.com/bb1713c2afde5398e89de63ab5b9d0d3 I extended it. I'm now getting this: http://gyazo.com/663823a1869812936d6fb0d3c33dddd4 I also tried isVisible(). Neither seem to be working :c You need to either call the method from within the minergui class or by creating an instance of minergui. Please learn Java before making scripts mate Link to comment Share on other sites More sharing options...
Deffiliate Posted April 17, 2014 Share Posted April 17, 2014 http://gyazo.com/bb1713c2afde5398e89de63ab5b9d0d3 I extended it. I'm now getting this: http://gyazo.com/663823a1869812936d6fb0d3c33dddd4 I also tried isVisible(). Neither seem to be working :c Well the problem is that you're declaring that in a static way, if you don't know what static/non-static means add me on Sykpe and i'll help you get it sorted. Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 17, 2014 Share Posted April 17, 2014 You need to either call the method from within the minergui class or by creating an instance of minergui. Please learn Java before making scripts mate I have to learn hands on. Not by reading, not by un-important doo-dats in java. I'm trying to learn the best i can the way that i know how. If i'm a bother, don't read the threads i make or just ask me to stop making them. Otherwise, i intend to fully learn this my way. I'm sorry if i come off as rude, but this is the only way i learn. Thanks for all of your help in the past. Link to comment Share on other sites More sharing options...
Deffiliate Posted April 17, 2014 Share Posted April 17, 2014 (edited) learn Java before making scripts LOL ya right... majority of people on here have no idea of what a class is, much less why variables should be static/ non-static.... But Swizzie makes a good point. go take a class or read a book (Head first into Java), then come back and you'll be amazed at what you can do. Edited April 17, 2014 by Deffiliate Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 17, 2014 Share Posted April 17, 2014 Well the problem is that you're declaring that in a static way, if you don't know what static/non-static means add me on Sykpe and i'll help you get it sorted. Adding you, dementedfury. Link to comment Share on other sites More sharing options...
Deffiliate Posted April 17, 2014 Share Posted April 17, 2014 Adding you, dementedfury. didn't get it, make sure u dint add my impostor. My display name is jsut "Deffiliate" not deffilaite the scripter or w/e that other guys name is. Link to comment Share on other sites More sharing options...