JavaFX Java GUI Tutorial - 12 - ChoiceBox (Drop Down Menu)

Поділитися
Вставка
  • Опубліковано 10 жов 2024
  • Source Code: github.com/the...
    Core Deployment Guide (AWS): docs.google.co...

КОМЕНТАРІ • 43

  • @gurpreet7169
    @gurpreet7169 7 років тому +46

    *coughs while makng JavaFx tutorial* Sorry I got black lung from working in the mines xD

  • @NA-is2oo
    @NA-is2oo 7 років тому +14

    "meatballs is a fruit" - thenewboston 2015

  • @toonpomme5178
    @toonpomme5178 6 років тому +2

    thank you for this tutorial, the way of talkign is great compared to some other dev youtube tutos direct and to the point ! thanks alot

  • @JerrOoenn
    @JerrOoenn 9 років тому +7

    THANK YOU GWEN STEFANI

  • @heshamscorpe5652
    @heshamscorpe5652 9 років тому +7

    thnx for the spelling of Bananas

  • @eyofoyeyo
    @eyofoyeyo 9 років тому +3

    Hey bucky, how about doing some tutorials about wiring that'll awesome thanks!

  • @AKEgo
    @AKEgo 6 років тому

    Hey, a little other question. Did you have any idea why i cant add any element like button or label to a vbox? I use:
    VBox vb = new VBox();
    Button btn = new Button("hello");
    vb.getChildren().add(btn); //here i get an error at 'add' ????? 🤔

  • @TheFuckingInfernal
    @TheFuckingInfernal 9 років тому +1

    wouldn't it be better to initialize an array of Strings and pass it as a parameter of the choiceBox instead? it may help you to organize your program better

  • @cubingunlocked1812
    @cubingunlocked1812 6 років тому +3

    couldn't you simply do
    "button.setOnAction(e -> System.out.println(choiceBox.get value()));"
    instead???

    • @marker52
      @marker52 6 років тому +2

      yep I think he just made a new method to make it easier to understand(although I'm not sure it is).

    • @cubingunlocked1812
      @cubingunlocked1812 6 років тому

      hmmm

  • @apexwindowcleaningservices4457
    @apexwindowcleaningservices4457 8 років тому +3

    That is exactly how I remember to spell bananas too lol

  • @johanbengtsson3607
    @johanbengtsson3607 9 років тому +1

    ComboBox was faster for me. (For a list of 100+ countries.) Looks almost identical, but you get better scroll functionality which is almost a must if you have lots of values.

    • @AlexTechie
      @AlexTechie 7 років тому +1

      johan bengtsson agreed. Also, the drop down list looks horrible after a value has been set. I spent quite a few minutes researching what was wrong before I just youtube'd a few videos and realized it was default behavior. Terrible. I don't think there's any reason anyone should ever use choicebox over combobox.

  • @rohan_ray
    @rohan_ray 6 років тому

    Also, you can do without making methods,
    public class Main extends Application{
    public static void main(String[] args){
    launch(args);
    }
    @Override
    public void start(Stage primaryStage) {
    Stage st = new Stage();
    st.setTitle("Choice box");
    VBox vx = new VBox(20);
    ChoiceBox cb = new ChoiceBox();
    cb.getItems().addAll("Apple","Banana","Grapes","Leechi","Juice");
    Button B = new Button("Buy");
    vx.getChildren().addAll(new Label("Select the items you wan to buy"),cb ,B);
    st.setScene(new Scene(vx ,300 ,250));
    cb.setValue("Apple");
    B.setOnAction(e-> System.out.println("Orders are:
    " + cb.getValue()));
    st.show();
    }
    }

    • @rohan_ray
      @rohan_ray 6 років тому +1

      You can also change the satement
      cb.setValue("Apple");
      AS
      cb.getSelectionModel().select(0)
      by doing this you can always set the value as first option in choice box even there is some changes in the list:D

  • @unlink1649
    @unlink1649 6 років тому

    @thenewboston is there a way without the button? I know JavaFX is dying due to jdk11 but anyway

  • @brandonkuehn3969
    @brandonkuehn3969 4 роки тому

    How do you capture the data and use it in a different method instead of just printing what was clicked on?

  • @kiranacharya6504
    @kiranacharya6504 4 роки тому

    Hello guys, while searching, i found one more method FXML where we can easily drag and drop the fields, so im a bit confused which method i should use- JAVAFX or FXML? Pls Help

  • @frankchou4321
    @frankchou4321 4 роки тому

    Sorry, I have a question.
    If I set two ChoiceBox ,XChoiceBox and YChoiceBox.
    I add "a", "b", "c" in the XChoiceBox.
    I want YChoiceBox can display"1", "2", "3" when I Choice "a" in XChoiceBox, display "4", "5", "6" when I Choice "b" in XChoiceBox.
    How can I do in the code?
    Please forgive my poor English and hope someone can understand what I mean.

  • @Protocycle
    @Protocycle 7 років тому

    5:34 thank god you failed there so that I could know what would happen if I didn't put an existent value xD (just watching the vids before trying alone)

  • @kareemyounes7371
    @kareemyounes7371 4 роки тому

    Any idea how to stop the drop down menu from moving. It is hard to explain but see if you have 5 choices and you choose the 5th, and then click on the drop down menu again the menu will move up until the 5th choice. Best I got

  • @epiccmax1734
    @epiccmax1734 4 роки тому

    If I am executing your code and clicking on the ChoiceBox, then the frame closes and I get the following Message: A fatal error has been detected by the Java Runtime Environment:
    #
    # EXCEPTION_ILLEGAL_INSTRUCTION (0xc000001d) at pc=0x00007ff9151ccd21, pid=15820, tid=476
    #
    # JRE version: Java(TM) SE Runtime Environment (13.0.2+8) (build 13.0.2+8)
    # Java VM: Java HotSpot(TM) 64-Bit Server VM (13.0.2+8, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
    # Problematic frame:
    # C [d3d9.dll+0xacd21]
    #
    # No core dump will be written. Minidumps are not enabled by default on client versions of Windows
    #
    # An error report file with more information is saved as:
    # C:\Users\user\path_of_folder\hs_err_pid15820.log
    #
    # If you would like to submit a bug report, please visit:
    # bugreport.java.com/bugreport/crash.jsp
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.
    I searched the web for this, but didn't find anything...
    Edit: I found the solution --> I had to set the memory dumb to little memory dumbs!

  • @thecheesybocajlayon3425
    @thecheesybocajlayon3425 9 років тому +1

    lol.. if you reload the page yo will see the views go up!

  • @vasilpekar3609
    @vasilpekar3609 5 років тому

    Why no one dont show how to do this with FXML file?

  • @bltzbrg
    @bltzbrg 3 роки тому

    CheckBox.setValue now accepts every String

  • @dinkarinjosh
    @dinkarinjosh 4 роки тому

    2020 update: It was Corona Virus.

  • @iam_topg
    @iam_topg 5 років тому

    i wish you continue the videos using eclipse , the dark background really bad in these videos, appreciate it buky

  • @omarabdulazeez4298
    @omarabdulazeez4298 5 років тому

    Ctrl+D copies line in intellij :3

  • @harshitsinghai1395
    @harshitsinghai1395 7 років тому

    what's the difference between box1.setItems and box1.getItems ?

    • @annaphuong3260
      @annaphuong3260 7 років тому +2

      I just start learning to code, so I'm not 100% sure. I think the difference is "set" and "get". When you use get, you get the information, when you use set, you change/modify something (Google setter and getter methods to get more info)

  • @KarlooAudi
    @KarlooAudi 6 років тому

    *its apple.... ZZZZ* im dead

  • @LizardanNet
    @LizardanNet 9 років тому

    You can easily tell this guy is not a developer.

    • @ECCOWAFL
      @ECCOWAFL 9 років тому +2

      LizardanNet how so?

    • @ephraimbenet8881
      @ephraimbenet8881 9 років тому +8

      +LizardanNet If your one then how come your watching a this tutorial

    • @jackmurphy8341
      @jackmurphy8341 7 років тому +1

      Actually he is a project leader for a JAVA team of developers

    • @RazinShaikh
      @RazinShaikh 6 років тому +7

      yes because he works in the mines