JavaFX Java GUI Tutorial - 18 - Simple TableView

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

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

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

    Needed to learn javafx in one night for school. This playlist is a life saver. Thank you so much for this videos!

  • @HWilliamson
    @HWilliamson 9 ปีที่แล้ว +92

    Could you show us how to connect to a database and use values from a table in javafx??

  • @adekorir
    @adekorir 9 ปีที่แล้ว +7

    I've implemented this in Connecting yo a database and I have to say JavaFX is the best thing t ever happen to Java... and lambdas!

  • @Meegoue
    @Meegoue 9 ปีที่แล้ว +6

    Wow, JavaFX tables are WAY easier to use than Swing tables. I remember my first time messing with them. I spent like 4 hours trying to make it all work.

  • @kristenjacobsen831
    @kristenjacobsen831 9 ปีที่แล้ว +1

    All of these tutorials helped so much, easy to follow, informative and you are a good teacher! plus i get a pretty good laugh when you go off track talking about things haha thank you so much man!

  • @Joreleme
    @Joreleme 8 ปีที่แล้ว

    Searched google for an hour....Didn't get the concept. After your tutorial I checked the concept behind data model and TableView and I could implement one table on my own. THANKS! :)

  • @dbznappa
    @dbznappa 6 ปีที่แล้ว

    Literally the only TH-camr I disable adblocker for.

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

    bro, THANK YOU for existing

  • @vuongtiennguyen3268
    @vuongtiennguyen3268 4 ปีที่แล้ว

    you can also adding object to ObservableList simply by doing this: ObservableList student = FXCollections.observableArrayList(data.showDb());

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

    mi fai morire dalle risate ogni volta

  • @maartentbm
    @maartentbm 9 ปีที่แล้ว +5

    How come the quantity column sorts like an integer column (11:02) while the data type of the column is actually (accidentally) set to String? I would expect the sorted order to be like "12", "198", "20", "74", "856". (Now I also wonder how a column would sort if the data type is not Comparable)

    • @hossamnasser9717
      @hossamnasser9717 4 ปีที่แล้ว

      Hi, did u find out ?

    • @ModelbaanTBM
      @ModelbaanTBM 4 ปีที่แล้ว

      @@hossamnasser9717 I don't think I did 😅

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

      @@ModelbaanTBM A user @Tobias Vidal Diaz
      already answered that, 2 years ago. I can't seem to link the comment. It's here, though.

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

    Awesome tutorials, thanks so much! Concise, clear, and funny. Subd

  • @ben8140
    @ben8140 5 ปีที่แล้ว

    Bruh you save my life for a school project!

  • @MrCrayfishMinecraft
    @MrCrayfishMinecraft 9 ปีที่แล้ว +25

    Curse them fruit cups!

    • @Ele20002
      @Ele20002 7 ปีที่แล้ว +1

      I didn't expect to see you here...
      ...but your presence has made my day

  • @MsFerid567
    @MsFerid567 4 ปีที่แล้ว

    your an actual legend, thanks man

  • @Mafranny
    @Mafranny 7 ปีที่แล้ว

    Man... you saved my day. Thank you very much for your help.

  • @ДиогенСинопский-т4с
    @ДиогенСинопский-т4с 3 ปีที่แล้ว

    Hey ya, you are the best. Thanks for guides.

  • @zulucharlie5244
    @zulucharlie5244 7 ปีที่แล้ว

    Really great tutorial video - thanks for posting.

  • @chaabounimohamed7065
    @chaabounimohamed7065 8 ปีที่แล้ว +2

    Thanks a lot ! Bro ! :D you're the best i was stacked in displaying my data for 3 days

  • @christianlisangola9383
    @christianlisangola9383 8 ปีที่แล้ว +5

    In the Production class,the type of the quantity is an int,but why in the instruction: TableColumn QuantityColumn=new TableColumn("Quantity"); the type you've used isn't Intégrer?

    • @Imrankhan-nn5kp
      @Imrankhan-nn5kp 8 ปีที่แล้ว

      Yu can pass Integer too,,
      TableColumn quantityColumn=new TableColumn("Quantity");

    • @RohitAwate
      @RohitAwate 7 ปีที่แล้ว

      Generic classes in Java do not accept primitive data types in their type arguments. Hence, the int in Product class will automatically be promoted to Integer.

    • @Billywong
      @Billywong 6 ปีที่แล้ว

      @theChris yea I have spotted the same problem

    • @Billywong
      @Billywong 6 ปีที่แล้ว

      @Rohit Awate. "Generic classes in Java do not accept primitive data types in their type arguments. Hence, the int in Product class will automatically be promoted to Integer."
      do you mean since int is an primitive type argument, it cannot be passed into a function?
      then why "Integer" will be accepted? aren't int and Integer the same thing?

    • @FUUUUU1111
      @FUUUUU1111 6 ปีที่แล้ว

      They aren't, you should read about unboxing and autoboxing in java.

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

    (4:21) "corns and toilets boys, come and getem!" 😂

  • @kyosiris
    @kyosiris 9 ปีที่แล้ว

    Go to Settings > Editor > General > Auto Import and add "javax.swing" to get ride of swing in auto-completion. ^^

  • @nshusa99
    @nshusa99 9 ปีที่แล้ว

    Love your videos I've learned a lot. Keep it up.

  • @Billywong
    @Billywong 6 ปีที่แล้ว +1

    I tried to follow the tutorial and the source-code on Buckys website but I cannot compile. I have the following error:"
    Main18.java:62: error: cannot find symbol
    ObservableList products = FXCollecions.observableArrayList();
    "
    but I am sure I have already imported FXCollections at the top. why is this?
    at the top of my Main.java:
    "import javafx.collections.FXCollections;"

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

    Hi, I'm doing these, and I get to the " nameColumn.setCellFactory(new PropertyValueFactory("name"));" part, but I'm using SDK 15 and I get an error in the part of the code.

  • @GuNsDaW
    @GuNsDaW ปีที่แล้ว

    Thank you! Very useful

  • @sumedhakarunarathna426
    @sumedhakarunarathna426 4 ปีที่แล้ว

    This was really helpful.. Thank you very much

  • @gabob6992
    @gabob6992 2 ปีที่แล้ว +1

    grüße gehen an fabian satybaldy-ulu

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

    I wonder how you get the private properties of the Product class in the table by using the "name" of the property without invoking the getters ?

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

      Actually it is dependent on the getter. it gotta be (get + attribute with capitalized first letter). Otherwise you would get an Exception

  • @danielmontes6882
    @danielmontes6882 4 ปีที่แล้ว

    Hey! What if I have an Array or an ArrayList of float data in the product class? How can I fill a cell of the column with a number that is contained in an Array?

  • @cRsregeLt
    @cRsregeLt 4 ปีที่แล้ว

    Is there a way to dynamically change the width of a column to wrap the biggest content of a cell of this column?

  • @mr.RAND5584
    @mr.RAND5584 5 ปีที่แล้ว

    How about sir more than one table query to display on tableview? Do i have to create tablecolumn and class model? Such as a query of one patient has lots of visits query.

  • @jeremymcclellan474
    @jeremymcclellan474 7 ปีที่แล้ว

    You rule Bucky!

  • @master0612
    @master0612 8 ปีที่แล้ว +1

    @edit now i get it.. get function must be like getPytanie not like i had getpytanie.. ^^ one small letter big difference ehh
    meh i tried this and it shows me right colums but values are empty..
    ObservableList lista_danych = FXCollections.observableArrayList(lista_pytan); lista_pytan is my ArrayList with Szablon_bazy objects.. i ve 30 objects there and when i show TableView its even show 30 rows but all are empty..
    ObservableList has this elements, i just tried to print them with foreach. I ve no idea why table wont show me them..

  • @MatthewDHayworth
    @MatthewDHayworth 7 ปีที่แล้ว +2

    Can someone explain to me why "Double" in the Price column begins with an uppercase "d"?

    • @hurlok
      @hurlok 7 ปีที่แล้ว +8

      This may be too late for you but in case someone else is wondering:
      Lists and such can't have primitive types (so no List, , , etc! google primitive types if you don't understand), because the List methods are defined to receive Objects.
      To work around this, there's this thing called "wrappers", which are classes dedicated to each of the 8 primitive data types. These wrappers basically transform the primitive variable/value into an object so it can be passed around as one. The wrapper for doubles is Double, so you write "List".
      Hope it helps someone, for a more detailed explanation, google "Java wrappers".

    • @MatthewDHayworth
      @MatthewDHayworth 7 ปีที่แล้ว

      Thank you :)

  • @ikarosouza9505
    @ikarosouza9505 6 ปีที่แล้ว

    in my Product class, i've placed a Supplier object as one of the product's properties. in the table i want to show the supplier's name, how would i do that without changing the getSupplier method?

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

    How do I do this with user input into an ArrayList e.g. Enter name, enter account number and enter balance. Like how would I get the data to show in the TableView?

  • @todoros676
    @todoros676 7 ปีที่แล้ว

    Great job Bucky, thank you!!
    I got one question, how can I print that TableView with a printer?

    • @cgme9535
      @cgme9535 6 ปีที่แล้ว

      Might be late, but you'd need to use a printer API for that. I don't think JavaFX has built in functionality for printing out to a printer. I'd look up "Java printer API" and see what you get.

  • @dxintelligence
    @dxintelligence 7 ปีที่แล้ว

    Why is the key Product showing error? am I using the wrong kind of class, I used java class as there is no javafx class without a main class?

  • @anubis9139
    @anubis9139 6 ปีที่แล้ว

    The < and > are called chevrons. Yes, like the gas station. If you look at their logo, it even has 2 chevrons in it. A chevron is also the black and yellow signs with multiple repeating arrows pointing to the direction of the flow of traffic (see example here ). Lastly, it is the shape of the back legs of goats and dear.

  • @CheyziEdits
    @CheyziEdits 4 ปีที่แล้ว

    how could i display the keys and values of a hashmap in a tableview?

  • @chimichangas7621
    @chimichangas7621 4 ปีที่แล้ว

    how would you get the total price of all the items in the price column?

  • @claytonlawrencebeato1774
    @claytonlawrencebeato1774 6 ปีที่แล้ว

    Hey guys i've copy pasted the code from the gitHub since my orignal written code didnt run, but the codes from gitHub also didnt run. Both had no error whatsoever. Any idea why?

  • @Protocycle
    @Protocycle 7 ปีที่แล้ว

    How does PropertyValueFactory() know how to get the specified values? I don't see how just putting "name" helps the compiler know where to get the info D: or could it be that it all happens at table.setItems(getProduct()); and the ObservableList organizes the data in a manner such that the variable (field) 'name' in the Product class is passed as a "string" or a property name somewhat similar to how JSON works and at the end uses something like a JSON.parse() to convert and get the values?

    • @vladbuhoci6512
      @vladbuhoci6512 7 ปีที่แล้ว

      Read about the Reflection API and you will understand. :)

    • @Protocycle
      @Protocycle 7 ปีที่แล้ว

      I'll check that out then, thanks :D

    • @vladbuhoci6512
      @vladbuhoci6512 7 ปีที่แล้ว

      Anytime :)

  • @AstonMargolis-Dias
    @AstonMargolis-Dias 8 หลายเดือนก่อน

    DIID YOU EVER KNOW THAT YOURE MY HEERROOO 🎶🎶

  • @Aegs01
    @Aegs01 5 ปีที่แล้ว

    SIR! HOW TO MAKE A SAME PROGRAM WITH ADD BUTTON WHERE YOU CAN ADD DATA YOU WANT AND THE TABLE COLUMN IS AUTO GENERATED (SO IT MEANS THAT IF THERE IS NO DATA THERE'S ALSO NO TABLE COLUMN) THANKS HOPE YOU NOTICE I REALLY NEED ANSWER

  • @srikarmadhavapeddy8683
    @srikarmadhavapeddy8683 6 ปีที่แล้ว

    Can we save the output in a file (Excel file)?

  • @jsmarks01
    @jsmarks01 8 ปีที่แล้ว +1

    Why was a string used for the Quantity?

    • @michaelpicker9862
      @michaelpicker9862 8 ปีที่แล้ว +5

      use Integer instead -its a copy-pasting oversight

  • @DaEmperah
    @DaEmperah 7 ปีที่แล้ว +2

    any idea why my tableView is blank not even showing the cells?

    • @elfenblut
      @elfenblut 7 ปีที่แล้ว +2

      make your getter and setter "public"

  • @PRONOOBSPAK
    @PRONOOBSPAK 5 ปีที่แล้ว

    what if i want to multiply table column with quantity string

  • @xephecoh
    @xephecoh 5 ปีที่แล้ว

    how to populate table with arraylist of primitive type of data?
    what should be inside of >>> Tablenumber.cellValueFactoryProperty(new PropertyValueFactory();

  • @mr.RAND5584
    @mr.RAND5584 5 ปีที่แล้ว

    How to have auto resize column? Thanks in advance

  • @msv900
    @msv900 7 ปีที่แล้ว

    im geting this error
    type argument Box is not within bounds of type-variable S
    where S is a type-variable:

  • @pro-user255
    @pro-user255 7 ปีที่แล้ว

    my doesn't show any table elements but column name only, why?

  • @absoluz7
    @absoluz7 8 ปีที่แล้ว

    How can I put data from Arrays or HashMaps inside the ObservableList?

    • @kolslaw94
      @kolslaw94 8 ปีที่แล้ว +1

      The FXCollections class has static methods where you can pass in a Collection object to create an Observable with that Collection's data. I don't remember seeing one where you could pass in an array, but you can convert an array into a Collection pretty simply as well.

  • @AlejandroRodriguez-jo9kg
    @AlejandroRodriguez-jo9kg 9 ปีที่แล้ว

    For some reason my code it's not showing the quantity(in my case inventory) in the table.
    //Main.java
    public class Main extends Application{
    Stage window;
    Scene scene1,scene2;
    VBox panel;
    TableView table;
    public static void main(String[] args){
    launch(args);
    }
    @Override
    public void start(Stage stage) throws Exception {
    window = stage;
    window.setTitle("Aplicacion de Prueba - Alejandro Rodriguez");
    TableColumn name_c = new TableColumn("Resource Name");
    name_c.setMinWidth(200);
    name_c.setCellValueFactory( new PropertyValueFactory("Name"));
    TableColumn price_c = new TableColumn("Resource Price");
    price_c.setMinWidth(125);
    price_c.setCellValueFactory( new PropertyValueFactory("Price"));
    TableColumn inventory_c = new TableColumn("Resource Inventory");
    inventory_c.setMinWidth(125);
    inventory_c.setCellValueFactory( new PropertyValueFactory("Inventory"));
    table = new TableView();
    table.getColumns().addAll(name_c, price_c, inventory_c);
    table.setItems(getResources());
    panel = new VBox();
    panel.getChildren().add(table);
    // Scene
    Scene scene = new Scene(panel,500,250);
    window.setScene(scene);
    window.show();
    }
    public ObservableList getResources(){
    ObservableList res = FXCollections.observableArrayList();
    res.add( new Resources("Wood", 9.99, 100));
    res.add( new Resources("Iron", 12.85, 70));
    res.add( new Resources("Cotton", 3.16, 200));
    res.add( new Resources("Marble", 20.75, 50));
    res.add( new Resources("Glass", 5.99, 175));
    return res;
    }
    //Resources.java
    public class Resources {
    private String name;
    private double price;
    private int inventory;
    public Resources(){
    this.name = "";
    this.price = 0;
    this.inventory = 0;
    }
    public Resources(String n,double p,int i){
    this.name = n;
    this.price = p;
    this.inventory = i;
    }
    public String getName() {
    return name;
    }
    public void setName(String nm) {
    this.name = nm;
    }
    public double getPrice() {
    return price;
    }
    public void setPrice(double pr) {
    this.price = pr;
    }
    public int getInvetory() {
    System.out.println(inventory);
    return inventory;
    }
    public void setInvetory(int inv) {
    this.inventory = inv;
    }
    }

  • @erickcabral
    @erickcabral 7 ปีที่แล้ว

    Fuck Yeah! Great Video Man!

  • @ericfricke4512
    @ericfricke4512 4 ปีที่แล้ว

    Fruit cups have tons of added sugar.

  • @RonSpwan11
    @RonSpwan11 5 ปีที่แล้ว

    AWESOME!

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

    how to prevent insert duplicate number like Item_ID

  • @nurlanungarbaev1410
    @nurlanungarbaev1410 6 ปีที่แล้ว

    Hello I also have another result please help name.setCellValueFactory how to write a correct code so that the result is correct please write the text of the code correct

  • @MyAvi92
    @MyAvi92 8 ปีที่แล้ว

    thnks for your video it helped me a lot.
    I want know how to display data from an excel sheet in the tableView. plz help me!
    I can retrieve the data and display it on the console but can't display it on the GUI.

  • @jtl2914
    @jtl2914 5 ปีที่แล้ว

    I'm so sorry, I laughed out loud in front of my co workers when watching your deleting the code at 9:13

    • @goldiemusic8394
      @goldiemusic8394 5 ปีที่แล้ว +2

      you must be really smart, you fuck.

  • @AstonMargolis-Dias
    @AstonMargolis-Dias 8 หลายเดือนก่อน

    ty so god damn much

  • @jorgee5693
    @jorgee5693 4 ปีที่แล้ว

    THANK YOU

  • @paninapo813
    @paninapo813 ปีที่แล้ว

    Thank youu!!!

  • @csandreas1
    @csandreas1 9 ปีที่แล้ว

    is this similar to c++?

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

      csandreas1 The syntax is similar, but both programming languages are different enough to have their own room.
      For Example:
      Java does use a GarbageCollector.
      C++ does not.
      C++ classes mostly do need a destructor method, because there is no GarbageCollector.
      Java code is compiled into Java ByteCode, this code does run everywhere, where a Java Virtual Machine does run.
      C++ code is compiled natively, its compiled binary does run directly on the systems CPU architecture and must be recompiled for other CPU architectures. You can't use the same compiled binarys on all CPU architectures.
      That's one of the reasons why C++ is known as a system programming language.
      You wouldn't use Java as a system programming language.
      Java has a great standard library. The standard library from C++ is much smaller, which means, that you normally use 3rd party librarys in the C++ world or write everything on your own, which results in extra work.
      But all in all, they differ so much, that you won't use only one of those languages. If you take programming seriously, you will learn both of them.
      The choice for the one or the other language really depends on what software you are planing to write.
      The workload is also not the same. To programme an application where both languages are suitable for, programming it in Java, means that Java will often require you to invest less time into the programming to get the application done.
      C++ on the other side is much more expressive. The same task can be done very differently and with C++ you will more likely shoot yourself in the foot, but if performance is very important, C++ is in most times the way to go. But this does not mean, that Java would be slow. Its performance is good enough for most of the appilcations you might want to write.

  • @purple_gemini
    @purple_gemini ปีที่แล้ว

    7:02 please ignore... personal comment

  • @theb1524
    @theb1524 5 ปีที่แล้ว

    is this still up to date ?

  • @maxfactor4209
    @maxfactor4209 4 ปีที่แล้ว

    why no FXML? this is messy

  • @granim32
    @granim32 6 ปีที่แล้ว

    would love to see this down with an cvs file instead.

    • @TurskoVideos
      @TurskoVideos 6 ปีที่แล้ว +1

      Just parse your information from the file into ArrayLists inside of an Object

  • @ayoutubecommenter2674
    @ayoutubecommenter2674 8 ปีที่แล้ว

    How did he call the product class?
    Or is it called in the getProduct() method?

  • @AlexisSniffer
    @AlexisSniffer 8 ปีที่แล้ว

    Gracias

  • @bm510
    @bm510 5 ปีที่แล้ว

    Awesome tutorial
    Man, I cringe at these so called "real languages" when it comes to desktop apps and GUIs. App development must take decades lol.
    I'll use VBA, build a fully functional UI, connect to a database, and jam the data into the UI in about 20 lines of code lol

  • @اماديرأمان
    @اماديرأمان 6 ปีที่แล้ว

    Thanks lot

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

    This isn’t working in javaFX

  • @nurlanungarbaev1410
    @nurlanungarbaev1410 6 ปีที่แล้ว

    I found a mistake thanks

  • @alexandersage7035
    @alexandersage7035 5 ปีที่แล้ว

    cheese burgers, toilets and computers are the first thing you thought of for products to sell. I hope that doesn't represent your life.

  • @giulio7288
    @giulio7288 ปีที่แล้ว

    Mac M1, Java19, i got the table but empty and following error: ""javafx.scene.control.cell.PropertyValueFactory getCellDataReflectively WARNING: Can not retrieve property 'Name' in PropertyValueFactory: javafx.scene.control.cell.PropertyValueFactory@384a9e7a with provided class type: class application.Product....."... suggestions?