Simple Java application for tracking monthly income and balance



For tracking my personal bank balance, inasmuch as I found the movement list in my home banking not useful, I usually use an Excel file that do simple calculation and return how much money I can spent over the month. So why not write this in java using Swing?

So here a simple analysis:
Monthly Income (shortened in MonIn), is a simple java application which read a file with some hashtag inside, each tag define a value.
Using Swing GUI, display this data to video, then let you modify the data and calculate some total predetermined.

In the future I change the file I/O with a DataBase and relative query.



As you can see I'm a real artist when using MSPaint. 

The source file contains some tag in this form:
#tag1 = value1;
#tag2= value2;
...
#tagN=valueN;
The java.io package is needed to read and write to the file.

The Swing GUI contains the form with all the text field, a table, a button to make the calculation, a checkbox to enable advance setting.

in the future I change the form adding a tabbed pane



The first four text fields are JTextFields, tfAccrual is not editable (setEnabled(false)) and by default set to 200. Constant loss is a JTable, and contains only standard monthly expenses. By default is not editable.
CalcBtn is a JButton, which at click calc the total. Advanced Setting is a JCheckBox, if selected enable editing to tfAccrual and Constant Loss. Totals are three JTextField, not editable, when start application they contains the previous month total.
SaveBtn is a JButton, when pressed write the new value to the file (or in the DB).
This project use the GroupLayout as Layout Manager.
JFrame cannot be resizable in this application (setResizable(false));

On exit, using a WindowListener to check the exit before the closing action of the frame, if there are no unsaved modification then exit, else popup a message that ask if want to save before exit, the popup message is a JOptionPane.

----------------------------------------------------------------------

At this point I need to do only the pop up message when closing the window and I need to do some fixes to the layout, as you can see in the screen below.



You can find the full code at my repository on GitHub, and here is the part of code which make me mad:


I'll try to use multiple pane, and so multiple layout manager, to resolve this damn layout, as explained here.

----------------------------------------------------------------------

I fix the layout, improve the readability and add the message box when closing.
For fixing the layout I choose to separate the components into 3 JPanel, adding all three into a GroupLayout set as layoutmanager of the JFrame


The first and the third JPanel are themeselves managed with a GroupLayout, otherwise the second JPanel has a simple FlowLayout because in it there is only the JTable.

The graphical result is the screen down here:



The only fix I need now is to align the third JPanel to center, or move the JCheckBox and the save JButton near the extreme left, aligned with the left edge of the JTable.



To add the message in the closing action when have unsaved modification, I inherit the WindowListener and in his windowClosing() method I managed the Exit. For doing this you must set the default closing action of the JFrame to DO_NOTHING_ON_CLOSE , and change when it need.
I don't have really implemented the others methods because I don't need them in this project. But I must put their implementation in my code or there is a compiler error caused by the not fully implementation of the methods present in the WindowListener interface.

If you want to see the full code is still on my GitHub repository . Now, as I say up here, I need to align the JPanel3 to center, and change the JLabel jlabError with a JOptionPane message, and maybe improve readability and shortening the code, but these are minor improvement so for the nexts days I work on other project.

----------------------------------------------------------------------
On line documentation about these component and listener on Oracle Doc and Oracle Tutorial.
JTable: Oracle Doc  Oracle Tutorial
GroupLayout: Oracle Tutorial
JFrame: Oracle Doc
WindowListener: Oracle Tutorial
JOptionPane: Oracle Doc
Swing Tutorial: The GuideBook

Ygy Freezone

3 comments:

  1. Balance manager App-The My Optus app is the easiest way to manage your prepaid mobile. Protect your mobile leisure and your mobile device Block all kinds of prank calls and messages!

    ReplyDelete
  2. Great blog, good information is given about Expense Report .It was worth reading.Thanks for posting the blog. Expense Report Software | Expense Tracker

    ReplyDelete