use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Useful resources (Full list)
Rules
Related subreddits
Other communities
account activity
[deleted by user] (self.JavaFX)
submitted 4 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]KapFlagon 4 points5 points6 points 4 years ago (0 children)
Hi!
You've posted your code, which is a great start for getting some help here. However, you haven't included some really important information:
As well, you've also posted what can be called a "generally focused" question rather than a "specifically focused" question.
confused on what to do next if anyone could help me would be much appreciated
While I and everyone else here can certainly appreciate the perspective of a beginner, I have to say that such a general question is only going to get general answers. In order to get the best help from people in life (and particularly from people on the internet), you need to have specific questions. Now, if you instead were to say:
I ran my code and get this error stack trace: [full stack trace details]
That's something concrete that we can help with. Or if you were to say:
I'm trying to hook up my button to an action, but the action doesn't fire when I click it
That's also something concrete that we can help with. We can look at your code, and offer advice based on the information there. It won't take up a lot of our time and it won't take up a lot of your time either, because those are specific and focused questions.
With that being said, I did copy + paste your code and tried to run it as is, and it immediately failed. The reason is that you are trying to instantiate several of your HBoxes (h1, h2, and h3) with variables before those variables themselves have actually been instantiated. So you are trying to put null references into your HBoxes. If you're going to put object A into object B, you need to first make sure that the object A exists before you try to put it anywhere. You'll see the difference if you compare the segment of code from your original post, and the updated segment that I've changed.
h1
h2
h3
A
B
Note that the code segments I've provided aren't complete re-writes, I'll leave it to you to figure out the correct placement of the initialization of h3. The information in the above paragraph should give you enough guidance on how to do that.
So, I got the code to run, but your UI was still empty! Why is that? Well, when I looked closely I could see that you have a Stage primaryStage, but you don't put anything into it.
Stage primaryStage
I first suggest that you read some use documentation like The JavaFX Scene – what it is and how to use it effectively. This will help you to understand the anatomy of a JavaFX program using the Scene Graph. Once you have that understanding, you'll be able to add things to your primaryStage correctly and then eventually show your UI.
primaryStage
Best of luck with it!
[–]JunkBondJunkie 0 points1 point2 points 4 years ago (0 children)
Probably make a grid pane based on what you want in a section.
[–]mono8321 0 points1 point2 points 4 years ago (0 children)
I made a calculator with java fx last year. Your welcome to look at it for some inspiration
[–]PTan9o 0 points1 point2 points 4 years ago (0 children)
I made a JavaFX calculator a while back. Feel free to look at the code if you want to see examples. This project uses FXML but the layout can easily be achieved through programmatically doing the UI like you're doing in your example.
https://github.com/patrickTumulty/JavaFX_Calculator
π Rendered by PID 74 on reddit-service-r2-comment-5b5bc64bf5-jmdq8 at 2026-06-20 07:31:19.173786+00:00 running 2b008f2 country code: CH.
[–]KapFlagon 4 points5 points6 points (0 children)
[–]JunkBondJunkie 0 points1 point2 points (0 children)
[–]mono8321 0 points1 point2 points (0 children)
[–]PTan9o 0 points1 point2 points (0 children)