Hello,
Before you start reading;
This post might have a lot of text.
Bad explaining might also occur since I have just started with JavaFX, and English is not my first language.
Code might have (very) bad syntax.
Many of the questions I raise may for the experienced seem stupid.
If the above is fine by you, please go on.
To get started I used a tutorial found at:
http://code.makery.ch/library/javafx-8-tutorial
I'm currently in a
Java Programming course in my first year of Computer Engineering. So basically we got an assignment to make a Java Program that simulated simple bank account management. The bank account manager is to have several users and should be able to handle actions like deposits and withdrawals in the first place. Although the original assignment was to be done in regular Java, stupid as I am I started looking at JavaFX and SceneBuilder to make a decent looking UI. Several hours later I now find myself dug deep in a hole and I can't seem to climb out. Any help would be greatly appreciated.
So what I basically wanted to do was:
*Create a
Main Window which included
(A list of customers, a login function to access the account of a given customer, a function to add a customer)
*Dialog for the "Add Customer" action
*Have an
account window with account balance and different actions
(Withdraw, deposit, transfer, logout)
*Dialogs for withdraw, deposit and transfer actions
Now, the code:
Code for the
Main Window:
Output of the
main window.
This functions properly aswell as the Ny Bruker (New user) function.
For the
account window the following code applies:
Output of
account window:
And this is where I seem to get stuck. I'll post the other control classes aswell before I explain my problem.
Main class:
Code for the withdrawal dialog controller (ForetaUttakController):
So before I started with this I created another bank account manager with JavaFX. The difference was that it only had one scene, whereas this has two (As of now I think of the
main window and the
account window as different scenes, please correct me if I'm wrong). The program with one scene worked as it should both with withdrawals and deposits. My main problem with this project is that I can't get the deposit/withdrawal to work. Whenever I click "Uttak" (Withdrawal) I get the following error message:
Caused by: java.lang.NullPointerException
at bankAccount.main.Main.showForetaUttak(Main.java:141)
at bankAccount.main.ui.BrukerVinduController.handleForetaUttak(BrukerVinduController.java:44)
... 58 more
The problem I suspect is that I'm not giving the selected Account any valid values thus the NullPointerException. I can get the dialog for withdrawal to show without errors by replacing:
with:
Naturally, the problem then is that I have no account bound to the withdrawal window.
So as i said earlier, my main problem is connecting the withdrawal dialog to the account, I want to be able to withdraw an amount from the account from that window. I really don't know how to explain this better, most likely due to my shallow knowledge of JavaFX. If anyone could point me in the right direction I would be grateful, this is tearing my brain apart..
Thanks in advance.
Again, I apologize for bad syntax and/or language. I'm new to this, I programmed my first HelloWorld six weeks ago so have mercy.