• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running program in netbeans, no GUI

 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two files, SwitchOverlay.java and HUD.java. SwitchOverlay is the following:



Hud.java is a jPanel. When I compile and run everything builds successfully but I get no window popping up for me to test out the program.






When I try to run at first it'd say that switchoverlay.HUD doesn't have a main method.
Any ideas? Why don't I see my window when I run this?
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can’t display a JPanel. You have to add it to a frame (or window or applet or dialog).
 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. So, create a new jFrame and drop the jPanel into the frame?
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anthony Schmitt wrote:Ah. So, create a new jFrame and drop the jPanel into the frame?

Yes, as JPanel is a container and JFrame is a window.
 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, new question. Is there a way to disable project files, and can I delete automatically generated code, such as a radio button action that doesn't need to be there? I tried deleting some code for it and lost my whole jFrame! Brought back the graphical components using history but all the code is missing now.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See my reply on the other thread you started.
http://www.coderanch.com/t/568828/GUI/java/Moving-code-netbeans
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic