help needed in makin GUI (in netbeans) for a maths program(with lots of loops).
Joined: Jun 17, 2011
hey i'm new in java. i need to make GUI for my program but i'm confused as to what to wirte in GUI codes and what to write in Main codes etc. could someone please help me?
mathprogram.java main class
mathmenu.java guiclass(i just started learning about gui like literally yesterday, all i know is how to design the GUI and how to let the user key in- im confused how to code in this class, and am i supose to write all the loops here instead of the mathprogram.java(main class). could someone show me how to do it?
Joined: Oct 24, 2010
Cross posted in DIC.
Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
First of all, welcome to the Ranch and the fascinating world of Java.
About your JFrame class, it pretty much looks like you have posted the code of a frame that you designed in NetBeans (or similar IDE). The whole code in initComponents() method declaration is auto-generated. Since you are providing the user with a Swing interface, it's only recommended to use the frame itself for coding rather than having a separate class.
With an IDE such as NetBeans, it's quite easy to do this. All you need to do is just use the GUI design mode and use the components context menus.
For example, consider you have a Frame named myFrame, in which you have few textfields and a Submit and a Cancel button. Your aim would to be close/kill the window on clicking "Cancel". For this, in design mode, you just right-click the "Cancel" button and go to
Events-> action -> actionPerformed.
When you click on actionPerformed, you will be taken to source code and a method will be readily created of the form
Now all you need to do here is, write this in your method.