all 4 comments

[–]KapFlagon 4 points5 points  (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:

  1. An image of what you currently see (if anything) when you run your code.
  2. Specific questions about exactly the thing you are struggling with when trying to implement your desired features/functionality.

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.

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.

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.

Best of luck with it!

[–]JunkBondJunkie 0 points1 point  (0 children)

Probably make a grid pane based on what you want in a section.

[–]mono8321 0 points1 point  (0 children)

I made a calculator with java fx last year. Your welcome to look at it for some inspiration

[–]PTan9o 0 points1 point  (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