#Does anyone here use JavaFX? I have a little trouble figuring out how to make the second form work
49 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @sick roost! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Could you show the code for this and the error if possible.
Want me to zip it or just ss it?
It's like, 1 main app, 2 controllers for their 2 fxml files
You can just send it here in code blocks, or use pastebin
^
Okay so
I tried doing a separate calculator to do a program that would do both gross and net
public class CalcuServiceImpl {
static CalcuServiceImpl calcService = null;
public static CalcuServiceImpl getCalcuService(){
if(calcService == null)
calcService = new CalcuServiceImpl();
return calcService;
}
Calcu calcu;
public CalcuServiceImpl(){
calcu = new Calcu();
}
public Calcu get(){
return calcu;
}
}
- public class Calcu {
int num1 = 0;
int num2= 0;
int sum= 0;
} ```
This message has been formatted automatically. You can disable this using /preferences.
For what I tried, it seemed to have no errors
Second form goes kapoot everytime I press the prompt where it's supposed to output it
Could you send the error code
Yeah mb just woke up
Are you attempting to create a new window or just call this class?
Well, create a new one
it's either i didn't put some of the Calcu codes on my first controller or I forgot to put a get and set for it
Would you mind sending the .java and fxml files to me so I can quickly run it on my end.
If not, could you show the code which your creating the new window.
Hold on
Think I found the issue, here's how I did it so you know how to debug this type of issue.
Firstly I ran and tested the program until I hit the error point, from then, I looked to the bottom of the terminal and looked for the highlighted blue section, this tells us the error is line 30 in first controller.
Above that we can see the actual error is that the field **hoursWorkedField **was null. To fix this I just had to go rename this variable to the one that is found in your FXML which is hoursField, after that it ran without the error and displayed the second window.
Let me know if this fixes the problem.
If you have a look at your PrimaryController FXML file, you will see a highlighted field at the bottom on line 38.
That is because the FX:ID="hoursField" hasn't got a reference in controller, so you were referencing a ID that did not exist in your FXML.
It couldn't have been the only error
Everything worked fine for me afterwards
try it on your end and see if it works
You can make it private, but would then need to add the @FXML annotation to make it visible to JavaFX.
But to explain a bit more clearly:
Your variable named hoursWorkedField would work perfectly fine, it's name was simply not correctly referencing the FX:ID name you set in your FXML file. As such, when the program attempted to get a value from that textfield it could not, since no textfield was created with that name, so we got a NullPointerException error each time.
But, if we change the hoursWorkedField to match the name you put in your FXML file which is hoursField you will then be able to use the field values in the code.
Ohhhh
Okay, looking back at my previous prompt that makes sense
I'll go ahead and try for myself
Thank you
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Shouldn't have said it too soon
Did you run into an issue?
No no, it's just this lol
I actually haven't ran with the code yet, I went to eat a bit
Ah, mb, misunderstood what you said.
No worries
I went back and did what you asked
And I got into a bit of trouble with the back button and the output is all wrong
The problem might be the same as for the calculating one
Okay, scratch that, I figured out the Back Button
The calculating one needs to be reconfigured because it just outputs zeroes
The back button is a similar issue. You are referencing a button back but you are not referencing the one inside the FXML file, you will need to add a FX:ID to the button and it should fix that problem.
Yeah, I figured that one out
Any issues with the calculating whatsoever?
From a quick glance I don't think your actually setting a value to the values in your Calcu class, or at least not the values the user inputs, have a look at that for now.
I reevaluated all of the codes from Calcu and CalcuImpl
If it means I have to output a user's role and payment, I would have to ditch both of those scripts to be able to put both calculations and category at the same time
It's not my intent to remove it completely, but I think this works better
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
@sonic stirrup Uh hello? you still there?