• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running program in netbeans, no GUI

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah. So, create a new jFrame and drop the jPanel into the frame?
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See my reply on the other thread you started.
https://coderanch.com/t/568828/GUI/java/Moving-code-netbeans
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic