This is meant to give you an example of how to develop simple GUI applications in Java using Netbeans. It will be relevant to the Grade 10 Computer Programming course for the end-of-year project, and also the Internal Assessment of the IB Computer Science course both at higher level and standard level. You could use a similar model to produce all sorts of applications, like:
- A library or catalogue of music, books, dvds
- A customer or product database
- An electronic photo album
- A personal organizer or study planner
- A quiz game
Points to note:
- This is not meant to be a useful or interesting application! It only exists to show you some basic ways to build a user interface and store data on and retrieve data from the hard disk.
- I try to separate the logic of the application from the interface as much as possible. Some classes are responsible for getting input from the user and displaying output. Other classes are responsible for adding, editing and deleting contacts — the core logic of the application. Separating the interface from the logic like this helps to build more reliable and easily maintained software.
- I have added lots of comments to the source code so you can understand what is going on. A good idea is to follow the sequence of method calls for specific operations and button presses, for instance you could check exactly what happens when the Add Contact button is pressed.
- The main input form is of type javax.swing.JFrame and the subform, used to add and edit contacts, is of type javax.swing.JDialog. In general I would always advocate using these two classes because it keeps your interface simple while still giving you enough scope for complexity.