Jump to content

Make GUI open on start.


Recommended Posts

Guest Apogee
Posted

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.)

Posted (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 by oTroll
Posted (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:

8bySF.png

 

then in the actionPerformed method you can set the "Start" boolean to true.

Edited by Deffiliate
Guest Apogee
Posted

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:

8bySF.png

 

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:

8bySF.png

 

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?

  • Like 1
Posted (edited)

This is the best code response i have ever gotten. Very clear, thank you. smile.png

 

 

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 by Deffiliate
Posted

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.

Guest Apogee
Posted

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.

Posted (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 by Deffiliate
Guest Apogee
Posted

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.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...