March 28, 201510 yr 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 March 28, 201510 yr by dokato
March 28, 201510 yr 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 March 28, 201510 yr by josedpay
March 28, 201510 yr still doesnt work change window.frame.setVisible(true); to window.setVisible(true);
March 28, 201510 yr Author change window.frame.setVisible(true); to window.setVisible(true); nope still doesnt work, i also tried some additional thing as well but nothing works
March 28, 201510 yr Author any error code? no error at all the script doesnt start when i click start, even the paint doesnt show up unless i undo what ive added Edited March 28, 201510 yr by dokato
March 28, 201510 yr no error at all the script doesnt start when i click start, even the paint doesnt show up unless i undo what ive added 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 March 28, 201510 yr by josedpay
March 28, 201510 yr Author 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
March 28, 201510 yr Should run the gui on its own thread. SwingUtilities.invokeLater(new Runnable() { public void run() { Gui gui = new Gui(); gui.setVisible(true); } });
Create an account or sign in to comment