I'm working on creating a loan calculator in Java and using Swing.
I have previously used Java swing to create GUI. And my general approach has been to use one JFrame per screen and perform all functionalities in that class itself.
But this time I want to use oop and separate the GUI classes from the main class.(unlike previously where everything is jumbled into one class)
But I'm confused on how to proceed. Like what will be my main class.....the main menu UI or another class?
The project wil have three screens:ask user for input,display a table with the monthly installments and remaining balance, and a graph of months vs payment.
If someone could please give me an overview on how to proceed, it would be great!
Joined: Oct 02, 2012
This is what I've come up with so far.
Main class main()
initialise main menu screen
In fact you can split the classes or should I say redesign/refactor your classes by a) functions or use cases, b) component or layout (tables, panels, menubar, action etc)
From the look of your app, using a component-design is probably better. One down-side I can think of is your main window/frame will still need those necessary components such that if needed different panels can interact with. Eg if a graph gets updated when the table data is selected ... then you need the table's selected data or the table itself in your graph class.
This approach may make the number of classes in your app grow depending on how small a component each class is.
Hmmm...but for right now I'll just try and build a basic system and keep the communication between screens to a minimum.
Main Menu Screen asks user for Principal,rate and term.
It has two buttons:chart and graph.
On clicking chart button, a table is generated(Payment No, Monthly interest, Monthly payment, Remaining balance)
On clicking graph button, a graph of months vs amount is displayed.
Let me work on this, then I'll try and expand the scope of the project.
One more question....I have to validate the values entered by the user, so will Validation be a separate class?