• Post Reply Bookmark Topic Watch Topic
  • New Topic

A few questions about netbeans classes  RSS feed

 
mitchell cooper
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didnt know what part of the forum to put this but as i am an absolute beginner and this post involves a few questions i will put it here.

I want to create a program using netbeans, i have looked up buttons, jframes, but struggling to put it all together. I have started a new project with a class, made a j frame, placed some buttons on the j frame.
Now first question is why is "public static void main(String args[])" on every class and jframe i create ? do i need to delete them ?.
question two - how do i go about linking up j frames and classes ?


Heres my code

Main Class



Jframe
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mitchell cooper wrote:. . . why is "public static void main(String args[])" on every class and jframe i create ? do i need to delete them ?.
Most likely because you have some option on NetBeans set up to add main methods to everything.
You will probably have to delete the main methods because you can usually not execute something in most of those classes on their own. Why are you using NetBeans as a beginner? Least of all their GUI builder, which as you can see produces code you can's actually read.
question two - how do i go about linking up j frames and classes ?. . .
Start by deleting all the GUI code and create an app which will run and produce results at the command line. You should have an interface which has get and set methods and other methods, some of them taking instructions. You should be able to write a driver class which tests your app calling all those methods. Only when that works should you even think of a GUI.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!