Jump to content

implementing GUI in main class


dokato

Recommended Posts

Ok so i've made this unfinished gui using window builder and now I want it to just pop up when i start my script, nothing more.

I've tried to make an object of it in my main script class and also experimented and tried a bunch of diffrent things but nothing works (the script wont even start up).

 

my gui class:

http://pastebin.com/38v3WGrE

Edited by dokato
Link to comment
Share on other sites

remove 

 
        public static void main(String[] args) {
                        GUI window = new GUI();
                        window.frame.setVisible(true);
        }

in the main class create a simple instance of the gui

GUI window = new GUI();

then in the onstart you make it visible

window.frame.setVisible(true);

and incase you are waiting for gui to end before you continue with the script. 

 

in the onloop add a simple isVisible()  boolean check

Edited by josedpay
  • Like 1
Link to comment
Share on other sites

no error at all

the script doesnt start when i click start, even the paint doesnt show up

unless i undo what ive added sad.png

ok so keep this in the onStart

 GUI window = new GUI();

Your gui class extend JFrame so use it. What you did was created a new jFrame instance instead of using the classes JFrame. So delete

frame = new JFrame();
private JFrame frame;

you will get a few error with "frame." simply remove it and it should be good.

 

finally at the end of gui constructor the last line should be 

Gui() {
//stuff
setVisible(true);
}

no need for setVisible in the onstart since its in the constructor 

Edited by josedpay
Link to comment
Share on other sites

ok so keep this in the onStart

 GUI window = new GUI();

Your gui class extend JFrame so use it. What you did was created a new jFrame instance instead of using the classes JFrame. So delete

frame = new JFrame();
private JFrame frame;

you will get a few error with "frame." simply remove it and it should be good.

 

finally at the end of gui constructor the last line should be 

Gui() {
//stuff
setVisible(true);
}

no need for setVisible in the onstart since its in the constructor 

 

still doesnt work :(

and the script doesnt startup

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