JavaFX DatePicker 📅

Поділитися
Вставка
  • Опубліковано 21 сер 2024

КОМЕНТАРІ • 25

  • @BroCodez
    @BroCodez  3 роки тому +7

    // ************** Controller.java **************
    package application;
    import java.time.LocalDate;
    import java.time.format.DateTimeFormatter;
    import javafx.event.ActionEvent;
    import javafx.fxml.FXML;
    import javafx.scene.control.DatePicker;
    import javafx.scene.control.Label;
    public class Controller {

    @FXML
    private DatePicker myDatePicker;
    @FXML
    private Label myLabel;

    public void getDate(ActionEvent event) {

    LocalDate myDate = myDatePicker.getValue();
    String myFormattedDate = myDate.format(DateTimeFormatter.ofPattern("MMM-dd-yyyy"));
    myLabel.setText(myFormattedDate);
    }
    }

    • @ChrisssZero
      @ChrisssZero Рік тому

      How do a text of DataPicker read only?

  • @notoppland
    @notoppland Рік тому +1

    Your videos are my go-to source when learning about a new JavaFX-element. Thank you for your fantastic work!

  • @bredleyrojas3555
    @bredleyrojas3555 3 роки тому +1

    En 4 minutos este señor me enseño lo que no hizo mi profe en 4 meses, ty man u saved me

  • @greekrapindustry
    @greekrapindustry 4 місяці тому

    i cant believe u even showed how to change the date format, ure awesome!!

  • @markvandenberg8548
    @markvandenberg8548 3 роки тому +1

    Nice video, clear explanation, not to long. Said just what it needed to. You just got yourself a sub!

  • @williammonge8319
    @williammonge8319 3 роки тому +1

    You've helped me A LOT with my OOP final project! keep it up bro!

  • @chemso_1
    @chemso_1 4 місяці тому

    da best

  • @hippiestafarii
    @hippiestafarii 2 роки тому

    Loving the series Bro.
    Thanks a lot from Portugal ;-)

  • @mansiontech1265
    @mansiontech1265 2 роки тому

    Thank you he is helped me alot.
    Great Video Keep Going

  • @cpu5468
    @cpu5468 3 роки тому +3

    Are you going to teach us how we can export our javafx project so that we can run it without any start.bat file?
    P.S: Why are some of the javafx videos not listed?

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

    omg it is amazing

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

    Nice!

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

    THIS IS COOL

  • @pillow3627
    @pillow3627 3 роки тому +2

    Hey, Bro. I was just wondering if you could make a tutorlal for advanced c# windorms?

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

    Bro, thanks for being such a bro!
    Thx for the explanations
    From a fellow bro :P

  • @ecopharm6838
    @ecopharm6838 Рік тому

    Thanks bro

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

    Hey bro, could you make a video explaining how Github and Git works with Eclipse/Java?

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

    Can you guide for some basic java project for Resume as a fresher The ping pong one seems to be too complicated for fresher 😅

  • @LatifaDidouche
    @LatifaDidouche 8 місяців тому

    Hi guys how know haw can work with time piccker

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

    But only I code on cellphone, because I do not have Laptop, or Desktop.

  • @ChrisssZero
    @ChrisssZero Рік тому

    How do a text of DataPicker read only?

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

    comment for the algo :)

  • @user-vz5li1ny9c
    @user-vz5li1ny9c 7 місяців тому

    Prompt text didn't work i added the below to the controller:
    public void initialize() {
    myDatePicker.getEditor().setText("Select a date");
    }

  • @nikhilchowdary8146
    @nikhilchowdary8146 6 місяців тому

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class DatePicker {
    int month = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH);
    int year = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR);
    JLabel l = new JLabel("", JLabel.RIGHT);
    String day = "";
    JDialog d;
    JButton[] button = new JButton[49];
    public DatePicker(JPanel parent) {
    d = new JDialog();
    d.setModal(true);
    String[] header = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
    float BTN_SIZE = 11f;
    JPanel p1 = new JPanel(new GridLayout(7, 7));
    for (int x = 0; x < button.length; x++) {
    final int selection = x;
    button[x] = new JButton();
    button[x].setFont(button[x].getFont().deriveFont(Font.BOLD, BTN_SIZE));
    button[x].setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    button[x].setBackground(Color.WHITE);
    if (x > 6) {
    button[x].addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    day = button[selection].getActionCommand();
    d.dispose();
    }
    });
    }
    if (x < 7) {
    button[x].setText(header[x]);
    button[x].setForeground(Color.red);
    }
    p1.add(button[x]);
    }
    JPanel p2 = new JPanel();
    p2.setBackground(Color.WHITE);
    // Last year button
    JButton lastYear = new JButton("");
    nextYear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    nextYear.setBackground(Color.WHITE);
    nextYear.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    year++;
    displayDate();
    }
    });
    p2.add(nextYear);
    d.add(p1, BorderLayout.CENTER);
    d.add(p2, BorderLayout.NORTH);
    d.pack();
    d.setLocationRelativeTo(parent);
    displayDate();
    d.setVisible(true);
    }
    public void displayDate() {
    for (int x = 7; x < button.length; x++) {
    button[x].setText("");
    }
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.set(year, month, 1);
    int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
    int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
    for (int x = 6 + dayOfWeek, day = 1; day