GridPane | JavaFX GUI Tutorial for Beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 14

  • @JavaCodeJunkie
    @JavaCodeJunkie  4 ปีที่แล้ว +2

    We continue with our exploration of the JavaFX Layout Managers. Let me know if you have any comments or questions. Stay safe and keep on coding!

  • @alexop5919
    @alexop5919 3 ปีที่แล้ว +3

    That was very useful. I don't understand, why other tutorials doesn't tell you, that you can span 2 cells.

    • @JavaCodeJunkie
      @JavaCodeJunkie  3 ปีที่แล้ว +1

      @Alex Op - Glad it was helpful! Perhaps they don't know or don't realize how useful it can be when creating a GridPane.

  • @glennspencergalanido5427
    @glennspencergalanido5427 4 ปีที่แล้ว +1

    Good tutorial. Liked and subbed😎

    • @JavaCodeJunkie
      @JavaCodeJunkie  4 ปีที่แล้ว +2

      @gelnn spencre - Thank you and welcome!

  • @iamamogus7702
    @iamamogus7702 2 ปีที่แล้ว

    thank you. you are gold.
    \o/

  • @SorryBones
    @SorryBones 4 ปีที่แล้ว +2

    Thanks for the video, it's really clear. I had a question though - is it possible to change a specific index? By that, I mean if a pre-existing child is there can we replace it?
    Using add() inserts what you want where you want it, yeah, but it doesn't remove the original, it just shifts it over one. I looked around in the javafx API but there doesn't seem to be a set() that does this, nor does there seem to be a remove() kind of method that will let me do it manually by removing it then adding a new one.
    Is it possible to replace a specific index with GridPane? If not, are one of the other Panes (FlowPane, TilePane, etc.) better for that? I'm very inexperienced so I hope I just overlooked something simple. Thanks again!

    • @JavaCodeJunkie
      @JavaCodeJunkie  4 ปีที่แล้ว +1

      @Alex Bone - Thank you for the feedback! I am glad that you found the video to be useful. To answer your question, child nodes for all JavaFX Layout Panes are contained in an Observable List. You can access this list using the getChildren() method. You can then access (add, remove clear) the individual items (Nodes) in the Observable List.
      For example ...
      FlowPane flowPane = new FlowPane();
      Button button = new Button("Click me");
      flowPane.getChildren().add(button); *// Add Button to the FlowPane*
      ObservableList list = flowPane.getChildren(); *// Get the list of Nodes in the FlowPane*
      System.out.println(list.isEmpty());
      list.remove(button); *// Remove the Button from the list*
      System.out.println(list.isEmpty());
      Console output will be ...
      false
      true
      I hope that this answers your question.
      Cheers!

    • @SorryBones
      @SorryBones 4 ปีที่แล้ว +3

      @@JavaCodeJunkie Thanks 🙏

    • @JavaCodeJunkie
      @JavaCodeJunkie  4 ปีที่แล้ว +1

      @ Alex Bone - Happy to help! Let me know if you have any further questions.

  • @curyatomique2420
    @curyatomique2420 2 ปีที่แล้ว

    Thank you soooo much

  • @uARamboGS
    @uARamboGS 3 ปีที่แล้ว

    Thanks for the video. Ive got a question. How do i horizontally align the buttonbar in the center? I try to do it with GridPane.setHalignment(buttonbar, HPos.CENTER); but it doesnt work

    • @JavaCodeJunkie
      @JavaCodeJunkie  3 ปีที่แล้ว

      @RambiGS - The ButtonBar occupies the entire horizontal space in the GridPane cell and cannot be justified. The point of using the ButtonBar is that the Buttons are arranged according to an Operating System specific placement and are all the same size. If your goal is to CENTER align Buttons then you would have to use another container in place of the ButtonBar. eg. HBox and use HBox.setAlignment(Pos.CENTER). Give that a try and see if it meets your needs. Cheers!

  • @samirshrestha5252
    @samirshrestha5252 2 ปีที่แล้ว

    i am so confused with javafx. Can we use javafx for commercial use?