If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

java BankGUI

I've got an assignment in uni, and I wanted to see what you think of this program. Oh god...this is getting sad - I'm actually starting to hog the code review forum.

The program is designed to simulate a basic bank which allows you to create accounts and then deposit/withdraw from those accounts. Some features that are apparent on the program, such as the interest rate (that might actually be the only feature, I'm not sure), are not actually implemented in the program, but I would like you to ignore that (or at least not comment too much on it).

I was hoping that some people could comment on the design of the gui, and the way that it was coded, and also, that someone could give me an idea of how to get those bloody labels on the account details page to look aligned/tidy.

Thanks,

ac

(and once again, please note that I had to add the .txt extension to be allowed to upload the file)

You should always set resizable to false unless you want to make a method that will handle changes in the size of the window(s). Otherwise if the user changes the size of the window the gui components will be everywhere.

Code:

super("Bank GUI");

Could also use:

Code:

setTitle("Bank GUI");

Thats more self explanatory.

Code:

bank = new Bank(MAX_ACCOUNTS);

I don't like it when an instance has the same name as the class. You might capitalize the B, and when you have thousands of lines of code it would be a pain and a waste of time to have to go back and correct all of the errors you made. Of course you could use Find/Replace but i believe its better to have not made the mistake at all.

I would use:

Code:

bbb = new Bank(MAX_ACCOUNTS);

Thats as far as i have reviewed your code. I could get through more and look at the problem you are having with the labels but i need to be able to compile and see the problem.

Sorry bout that. I forgot that I had put a javabook class in it. Javabook is just a set of simple classes provided with a java textbook by thomas wu. I imported it because I didn't want to write my own messagebox when there was already another class that had it.

I realise that it is a bad idea to give objects the same name as the class. That is just down to me being lazy. (It also doesn't help that one of my lecturers, and I believe java by thomas wu, do that all the time :P)

I don't understand why you pointed out to me setResizable(false) when I already have that in my program...were you just explaining the reason for it?

Anyhow...I've attached the javabook classes so that you can compile the program. Thanks for the reply.

O man were do i start... Im trying to be as nice as possible but if i seem mean im not trying to be.

First off you need to correct the deposit and withdraw because i can deposit and withdraw using more than 2 digits after the decimal. I dont know about the uk but in us dollars money value cant go beyond the second digit after the decimal. I would use the DecimalFormat class(duh!!)&lt;-Not making fun of you just the name says it all.

You need to set up a couple of try-catch blocks.
1.NumberFormatException: When i enter a string into the account details-deposit/withdraw text box i get a NumberFormatException.
I can enter a string into the account number box and get a NumberFormatException too.

2.StringIndexOutOfBoundsException: In the account details when i select No Account Selected and deposit and withdraw a value i get a StringIndexOutOfBounds exception.

Thats all the errors i have found up to now.
I will help you tomorrow with your code, but right now i have to get some shut-eye.

That's a fair enough point (about being able to enter more than two digits after the decimal), but I should have explained that we were told not to bother implementing any error checking. I did, however, include some try-catch blocks in when I was updating the code two days ago because I had realised that there was a problem.

Thanks for pointing out the DecimalFormat class...I just hadn't noticed it (have never used it before, and didn't look for it). I actually hadn't thought about the fact that you could enter more than two digits after the decimal point.

I noticed the StringIndexOutOfBoundsException when doing some testing, but haven't had a chance to fix that. I did fix the problem when you don't enter an account number and try to create an account, or enter something other than a number.

Could you give me some feedback on the way the gui looks if you have some time? Thanks for the replies, man.