Well, lets get this party started. I am currently working on a loan calculator. I understand how to create it using JOptionPane.showInputDialog and only allowing for one loan at a time. What I really want to do is create a single content pane that uses arrays to store up to 5 different loans. I envision a JMenu with “New Loan,” “Existing Loans,” and “Delete Loan.” Under the “New Loan” menu, I would have:
CODE
JMenu newLoan = new JMenu(“New Loan”);
JMenuItem nl;
nl = new JMenuItem(“Preferred Customer”);
nl.addActionListener(this);
newLoan.add(nl);
nl = new JMenuItem(“Regular Customer”);
nl.addActionListener(this);
newLoan.add(nl);
I would have two different selections, seeing as which one you pick determines the interest rate you are going to be stuck with. Now, I am still very new to Java, but I think I am getting a handle on it pretty quick. I am guessing I first want to create a class, something along the lines as NewLoan to handle this part of the program. Up until this point, I have been using just command line and JOptionPane; so, the contentPane is still very new to me. One of my many questions is how do I make this all take place within the same screen? I mean, when I click “Preferred Customer” and it sets off the if (actionCommand.equals(“Preferred Customer”)), how is this going to effect my contentPane. Because I would like pane to be “over written” I guess for lack of better words, when I select new selections from the menu bar. Does this have to do with setting things visible?
But here is my real question, how do I get this to work with arrays. I understand to this point how to send data to an array using for loops, but how do I get the data to go any of the available slots that might be vacant. I mean what if I have entered 5 loans, but then I delete loan 4 using the delete function, how do I then make the next “New Loan” go to the available slot. I am probably making this so much harder than it really is, and the answer I am staring at it in the book.
I have so many other questions; such as how do I turn automatically turn the objects that I am going to have populated by the array in the “Existing Loans” list into working buttons. But I am sure that is way over my head at this point. Any help/advice would be much appreciated.