Page 1 of 2 12 LastLast
Results 1 to 20 of 21
Like Tree1Likes

Thread: NetBeans won't show a GUI

  1. #1
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Question NetBeans won't show a GUI

    I am deeply concerned that my NetBeans has developed some kind of bug that is preventing it from opening a new window to show a user interface....
    I can run the following code in the command prompt and get a result, but when I run the exact same code in NetBeans all I get is run successful, but nothing else??
    Java Code:
    import javax.swing.*;
    import java.awt.*;
    
    public class Testnew2 {
        public static void main(String[] args){        
            JFrame frame = new JFrame();
            frame.setTitle("Test2");
            frame.setLocationRelativeTo(null);
            frame.setSize(240,240);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel  panel = new JPanel();
            panel.setLayout(new GridLayout(2,1));
            JLabel label = new JLabel();
            label.setText("Still testin");
            JTextField textfield = new JTextField(8);
            panel.add(label);
            panel.add(textfield);
            frame.getContentPane().add(panel);
            frame.setVisible(true);}}
    This is not the first time I have noticed that GUI programs do not open in NetBeans, and it is making it very difficult to practice my coding when no results are displayed!!
    PLEASE HELP!!

  2. #2
    Art Vandelay is offline Member
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default Re: NetBeans won't show a GUI

    If you want to be able to design and view a GUI in Netbeans... you need to BUILD the GUI in Netbeans. Once you build a GUI in Netbeans.. you will never ever with to go back to doing it manually.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by Art Vandelay View Post
    If you want to be able to design and view a GUI in Netbeans... you need to BUILD the GUI in Netbeans. Once you build a GUI in Netbeans.. you will never ever with to go back to doing it manually.
    There are many in here, myself included who disagree strongly with this. Myself, I find that the control that I gain by creating GUI's manually and the ability to be able easily read my GUI code far outstrips any advantage of using the NetBeans Matisse code generator.
    Last edited by Fubarable; 02-26-2013 at 02:50 PM.
    PhHein likes this.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by zlloyd1 View Post
    I am deeply concerned that my NetBeans has developed some kind of bug that is preventing it from opening a new window to show a user interface....
    I can run the following code in the command prompt and get a result, but when I run the exact same code in NetBeans all I get is run successful, but nothing else??
    Java Code:
    import javax.swing.*;
    import java.awt.*;
    
    public class Testnew2 {
        public static void main(String[] args){        
            JFrame frame = new JFrame();
            frame.setTitle("Test2");
            frame.setLocationRelativeTo(null);
            frame.setSize(240,240);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel  panel = new JPanel();
            panel.setLayout(new GridLayout(2,1));
            JLabel label = new JLabel();
            label.setText("Still testin");
            JTextField textfield = new JTextField(8);
            panel.add(label);
            panel.add(textfield);
            frame.getContentPane().add(panel);
            frame.setVisible(true);}}
    This is not the first time I have noticed that GUI programs do not open in NetBeans, and it is making it very difficult to practice my coding when no results are displayed!!
    PLEASE HELP!!
    Are you sure that NetBeans is running this file and not the project that it's in? How are you having NetBeans run this?

  5. #5
    Art Vandelay is offline Member
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by Fubarable View Post
    There are many in here, myself included who disagree strongly with this. Myself, I find that the control that I gain by creating GUI's manually and the ability to be able easily read my GUI code far outstrips any advantage of using the NetBeans Matisse code generator.
    Fair enough, you are free to disagree.

    Quote Originally Posted by Fubarable View Post
    Are you sure that NetBeans is running this file and not the project that it's in? How are you having NetBeans run this?
    Aye, I agree with Fubar that most likely if you are using old code...and not seeing the GUI...the project is probably not set up correctly to run it.

  6. #6
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Question Re: NetBeans won't show a GUI

    Quote Originally Posted by Fubarable View Post
    Are you sure that NetBeans is running this file and not the project that it's in? How are you having NetBeans run this?
    I am creating a project in NetBeans, and adding a package line to the code, and no I am not sure what is happening when I run it, but this is the only program in the package, so I am assuming it is running this!!

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: NetBeans won't show a GUI

    What do you mean by "adding a package line to the code"?
    The code in your original post has no package statement.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by Tolls View Post
    What do you mean by "adding a package line to the code"?
    The code in your original post has no package statement.
    Yes, I know that. It is because I wanted those who viewed my post to be able to compile the code, and run it outside of NetBeans.
    What I meant was that in order to try and run this in NetBeans. I would create a new project, named Textnew2, and add this code to the code generated upon creating the project, and then it would not run correctly.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: NetBeans won't show a GUI

    Right click the class file in Netbeans and select Run As (or whatever the equivalent in Netbeans is), then run it.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Question Re: NetBeans won't show a GUI

    Quote Originally Posted by Tolls View Post
    Right click the class file in Netbeans and select Run As (or whatever the equivalent in Netbeans is), then run it.
    Not sure exactly what you mean with this??

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: NetBeans won't show a GUI

    Well, you haven't actually explained how you are running this through Netbeans.
    I'm suggesting a way of ensuring it is trying to run this class.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  12. #12
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    351
    Rep Power
    4

    Default Re: NetBeans won't show a GUI

    The following link should provide you with clearer instructions.

    http://docs.oracle.com/javase/tutori.../examples.html

    Skip straight to the bottom to the section titled 'Compiling and Running a Project'.
    Files which can be run within Netbeans are indicated by a small green arrow on their icon. An example of this can be seen on the link in the image directly above the section mentioned. Look at bottom right corner of the ButtonDemo.java icon.

    Edit: I should add that the green arrow is an indication the file contains a main method.

    Regards.
    Last edited by Ronin; 02-28-2013 at 01:26 PM. Reason: Additional text

  13. #13
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Question Re: NetBeans won't show a GUI

    Quote Originally Posted by Ronin View Post
    The following link should provide you with clearer instructions.

    http://docs.oracle.com/javase/tutori.../examples.html

    Skip straight to the bottom to the section titled 'Compiling and Running a Project'.
    Files which can be run within Netbeans are indicated by a small green arrow on their icon. An example of this can be seen on the link in the image directly above the section mentioned. Look at bottom right corner of the ButtonDemo.java icon.

    Edit: I should add that the green arrow is an indication the file contains a main method.

    Regards.
    Oh I see, no what I was saying was that I created this program using NotePad++, a text editor, and it ran fine when I compiled it and ran it in the command prompt. However, then to double check it, I created a new project in NetBeans named Testnew2, and then tried to run it there, but it gave me a bunch of grief. I did not understand this, because it had run fine without a hitch in the command prompt, no errors, or even warnings....

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: NetBeans won't show a GUI

    Comment out the Swing code and simply replace it with System.out.println("Hello");
    If that doesn't work then you are not running the code you think you are.

    I have to say I'm not sure I understand the purpose of checking this by running it in a GUI.
    If it works from the command line then it works...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  15. #15
    MackSix is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default Re: NetBeans won't show a GUI

    What OS? What version of NetBeans? What is your JAVA_HOME environment variable set too? What is "netbeans_jdkhome=" in netbeans.conf set too?

    I ran your code from NetBeans and it worked fine.
    Last edited by MackSix; 02-28-2013 at 06:24 PM.

  16. #16
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by Tolls View Post
    Comment out the Swing code and simply replace it with System.out.println("Hello");
    If that doesn't work then you are not running the code you think you are.

    I have to say I'm not sure I understand the purpose of checking this by running it in a GUI.
    If it works from the command line then it works...
    I was just trying to transpose the code in the IDE because I wanted to see if there were any errors that I did not see in the command line.

  17. #17
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by MackSix View Post
    What OS? What version of NetBeans? What is your JAVA_HOME environment variable set too? What is "netbeans_jdkhome=" in netbeans.conf set too?

    I ran your code from NetBeans and it worked fine.
    This is a problem I was having back at the beginning of January, and I am not really clear what it was to be honest, but I keep getting responses now that it is almost March. It is honestly not still clear in my head the problems I was having with this code specifically anymore!!

  18. #18
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    351
    Rep Power
    4

    Default Re: NetBeans won't show a GUI

    Just another zombie thread then.
    zlloyd1, to prevent others getting carried away with this thread is this something you still want resolving?

    Regards.

  19. #19
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by zlloyd1 View Post
    I was just trying to transpose the code in the IDE because I wanted to see if there were any errors that I did not see in the command line.
    The compiler is the same.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  20. #20
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Default Re: NetBeans won't show a GUI

    Quote Originally Posted by Tolls View Post
    The compiler is the same.
    I realize that, but I was trying to see the red squiggly lines that are offered in NetBeans, in an attempt to pinpoint any errors. The command prompt will give you errors is there is a problem, but then you have to find them in your code, whereas in NetBeans, the coding is shown on the screen in its entirety with indications of where there is a problem....

Page 1 of 2 12 LastLast

Similar Threads

  1. NetBeans Didn't show the Design mode
    By ryor310575 in forum NetBeans
    Replies: 2
    Last Post: 05-31-2011, 06:48 AM
  2. How to Show Off?
    By maknib in forum New To Java
    Replies: 6
    Last Post: 11-05-2010, 10:26 AM
  3. Replies: 3
    Last Post: 05-27-2010, 10:54 AM
  4. show shapefiles in netbeans 6.5
    By dadar in forum New To Java
    Replies: 0
    Last Post: 09-30-2009, 03:33 PM
  5. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 06:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •