Jump to content

How to JFrame?


Mexiah

Recommended Posts

Hi guys, I was trying to make a menu where users select what scenarios to include from my script and was told to use JFrame. I've watched some tutorials on it but I can't figure out how to include it in my script. Any help to get out there? :-)

 

This is what I have so far, btw, and it clearly doesn't work xD

 

public class SlayerBot extends (Script && JFrame) {

     private Frame() {

        //Code

     }

}

Link to comment
Share on other sites

Gui class:

public class Gui extends JFrame { 
    public Gui() { //constructor
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 
        //stick your Gui code in here for the jframe. You can use windowbuilder plugin for eclipse to design it a bit simpler. 
    } 
}

Main class:

private Gui GUI;

@Override
public void onStart() {
    GUI = new Gui();
    GUI.setVisible(true);
}

merry christmas

apa

Edited by Apaec
Link to comment
Share on other sites

Gui class:

public class Gui extends JFrame { 
    public Gui() { //constructor
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 
        //stick your Gui code in here for the jframe. You can use windowbuilder plugin for eclipse to design it a bit simpler. 
    } 
}

Main class:

private Gui GUI;

@Override
public void onStart() {
    GUI = new Gui();
    GUI.setVisible(true);
}

merry christmas

apa

 

It's Christmas in August!

  • Like 1
Link to comment
Share on other sites

Hi guys, I was trying to make a menu where users select what scenarios to include from my script and was told to use JFrame. I've watched some tutorials on it but I can't figure out how to include it in my script. Any help to get out there? :-)

 

This is what I have so far, btw, and it clearly doesn't work xD

 

public class SlayerBot extends (Script && JFrame) {

     private Frame() {

        //Code

     }

}

 

code your gui in a seperate class (so that the gui class itself extends JFrame)

 

then you declare a new instance in your slayerbot class

 

the way Apaec had it written

Edited by RickyD
Link to comment
Share on other sites

Alright, so I've figured out that making this using Window Builder is actually pretty simple. I just still can't figure out how to get the two classes to work together. I get the onStart-code calling the GUI but how do I make the GUI change variables in my main script? Or should I declare the variables in the GUI and then pass them to my SlayerBot-class? There are no "classes" in C so this concept is not familiar to me :-P

:-P

Link to comment
Share on other sites

Alright, so I've figured out that making this using Window Builder is actually pretty simple. I just still can't figure out how to get the two classes to work together. I get the onStart-code calling the GUI but how do I make the GUI change variables in my main script? Or should I declare the variables in the GUI and then pass them to my SlayerBot-class? There are no "classes" in C so this concept is not familiar to me :-P

:-P

struct GUI
{
    int valueA;
    int valueB;
};  

int main() // Your script
{
struct GUI MyGUI;
// > Load GUI and set values here <

int valueA = MyGUI.valueA;
int valueB = MyGUI.valueB;

return 0;
}

Think of a class as a struct with more functionality (crude definition but might help you).

Edited by Botre
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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