Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 12 12311 ... LastLast
Results 1 to 25 of 284

Thread: library or component for Hijra date chooser

  1. #1

    Thumbs up library or component for Hijra date chooser

    i need a library or component for Hijra date chooser (Islamic date chooser) but i cant find it Do you know a library for that in java swing?


    --- Update ---



    now you can use this class or component
    https://s19.picofile.com/file/843319...onent.jar.html click on red button for download
    https://gofile.io/d/EXDW1v
    download link
     
    /*
     * Many thanks to Norm from the www.javaprogrammingforums.com that knew more than me.put more time and energy to create this component 
     * Maysam Soleymani Qorabaee www.programsfuture.com  * 
     */
    /**
     *
     * @author Admin
     */
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.Frame;
    import java.awt.GridBagLayout;
    import java.awt.GridLayout;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowFocusListener;
    import java.io.IOException;
    import java.text.DateFormat;
    import java.text.Format;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.time.LocalDate;
    import java.time.chrono.HijrahChronology;
    import java.time.chrono.HijrahDate;
    import java.time.format.DateTimeFormatter;
     
    import java.util.Date;
    import java.util.Locale;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.imageio.ImageIO;
    import javax.swing.GroupLayout;
    import javax.swing.ImageIcon;
     
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFormattedTextField;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSpinner;
    import javax.swing.JTextField;
    import javax.swing.SpinnerNumberModel;
    import javax.swing.SwingConstants;
    import javax.swing.SwingUtilities;
    import javax.swing.border.LineBorder;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import javax.swing.JPanel;
    import javax.swing.SpringLayout;
    import javax.swing.text.DefaultFormatter;
     
    public class HijrahextendsJPanel extends JPanel {
     
        int ye;
        int mo;
        int da;
     
        String[] moonNames = {"ٱلْمُحَرَّم‎", "صَفَر‎", "رَبِيع ٱلْأَوَّل‎", "رَبِيع ٱلثَّانِي", "جُمَادَىٰ ٱلْأُولَىٰ", "جُمَادَىٰ ٱلثَّانِيَة", "رَجَب‎", "شَعْبَان‎", "رَمَضَان", "شَوَّال", "ذُو ٱلْقَعْدَة", "ذُو ٱلْحِجَّة"};
        //String[] moonNames = {"al-Muḥarram", "Ṣafar", "Rabīʿ al-ʾAwwal", "Rabīʿ ath-Thānī", "Jumadā al-ʾŪlā", "Jumādā ath-Thāniyah", "Rajab", "Shaʿbān", "Ramaḍān", "Shawwāl", "Ḏū al-Qaʿdah", "Ḏū al-Ḥijjah"};
        String colname[] = {"سب", "اح", "ثن", "ثل", "ار", "خم", "جم"};
    //            String colname[] = {"Sa", "sun", "Mon", "Tu", "We", "Th", "Fr"};
        JLabel cell;
        JLabel monthNameLabel = new JLabel();  // get name from array
     
        Image img;
     
        private static String DEFAULT_DATE_FORMAT = "yyyy/MM/dd";
        private static final int DIALOG_WIDTH = 270;
        private static final int DIALOG_HEIGHT = 230;
     
        private SimpleDateFormat dateFormat;
        private HijrahextendsJPanel.DatePanel datePanel = null;
        private JDialog dateDialog = null;
     
        private JButton choosdate = new JButton();
        private JFormattedTextField datetext = new JFormattedTextField();
     
        private JPanel datePanels = new JPanel();
        String formatted;
     
    //    String alldate;
        //Build a block to give a value to the year and month and day when the class loads
        public void hdate() {
            HijrahDate hijrahDate = HijrahDate.now();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT);
            formatted = formatter.format(hijrahDate); // 1442/10/14 
            ye = Integer.parseInt(formatted.substring(0, 4));
            mo = Integer.parseInt(formatted.substring(5, 7));
            da = Integer.parseInt(formatted.substring(8, 10));
        }
     
        public HijrahextendsJPanel(String dateFormatPattern, Date date) {
            this();
            DEFAULT_DATE_FORMAT = dateFormatPattern;
        }
     
        public HijrahextendsJPanel() {
     
            hdate();
     
            setdateformatString();
     
            javax.swing.GroupLayout datePanelsLayout = new javax.swing.GroupLayout(datePanels);
            datePanels.setLayout(datePanelsLayout);
            datePanelsLayout.setHorizontalGroup(
                    datePanelsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(datePanelsLayout.createSequentialGroup()
                            .addComponent(datetext, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(choosdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE))
            );
            datePanelsLayout.setVerticalGroup(
                    datePanelsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(datePanelsLayout.createSequentialGroup()
                            .addGroup(datePanelsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(datetext, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(choosdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 0, Short.MAX_VALUE))
            );
     
            add(datePanels);
     
            try {
                img = ImageIO.read(getClass().getResource("cleander.png"));
                choosdate.setIcon(new ImageIcon(img));
            } catch (IOException ex) {
            }
     
            setDate();
            choosdate.setCursor(new Cursor(Cursor.HAND_CURSOR));
            datePanels.add(datetext);
            datePanels.add(choosdate);
            choosdate.setVisible(true);
     
            choosdate.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
     
     
     
                    if (datePanel == null) {
     
                        setdateformatString();
                        datePanel = new DatePanel();
     
                    } else {
     
                        setdateformatString();
                        getHDateString();
                        datetext.setText(getHDateString());
                    }
     
                    Point point = getLocationOnScreen();
                    point.y = point.y + 30;
                    showDateDialog(datePanel, point);
     
                }
            });
     
        }
     
        private void showDateDialog(DatePanel dateChooser, Point position) {
     
            Frame owner = (Frame) SwingUtilities
                    .getWindowAncestor(HijrahextendsJPanel.this);
            if (dateDialog == null || dateDialog.getOwner() != owner) {
                dateDialog = createDateDialog(owner, dateChooser);
            }
            dateDialog.setLocation(getAppropriateLocation(owner, position));
            dateDialog.setVisible(true);
     
        }
     
        private JDialog createDateDialog(Frame owner, JPanel contentPanel) {
     
            JDialog dialog = new JDialog(owner, "Date Selected", false);// Non-modal
    //        JDialog dialog = new JDialog(owner, "Date Selected", true);
            dialog.setUndecorated(true);
            dialog.getContentPane().add(contentPanel, BorderLayout.CENTER);
            dialog.pack();
            dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
     
            dialog.addWindowFocusListener(new WindowFocusListener() {
                public void windowLostFocus(WindowEvent e) {
    //                datetext.setText(getHDateString());
                    dialog.setVisible(false);
     
                }
     
                public void windowGainedFocus(WindowEvent e) {
    //                alldate=getHDateString();
                }
            });
     
            return dialog;
     
        }
     
        private Point getAppropriateLocation(Frame owner, Point position) {
            Point result = new Point(position);
            Point p = owner.getLocation();
            int offsetX = (position.x + DIALOG_WIDTH) - (p.x + owner.getWidth());
            int offsetY = (position.y + DIALOG_HEIGHT) - (p.y + owner.getHeight());
     
            if (offsetX > 0) {
                result.x -= offsetX;
            }
     
            if (offsetY > 0) {
                result.y -= offsetY;
            }
     
            return result;
        }
     
    //    private SimpleDateFormat getDefaultDateFormat() {
    //        if (dateFormat == null) {
    //
    //            dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
    //        }
    //        return dateFormat;
    //    }
        public HijrahDate getDate() {
     
            HijrahDate today = HijrahChronology.INSTANCE.date(ye, mo, da);
            return today;
        }
     
        public void setText() {
            setDate();
        }
     
        public void setDate() {
            datetext.setText(getHDateString());   //<<<<< Changed
     
        }
     
     
     
        public void setText(String settext) {
     
            setdateformatString();
    //        reflushWeekAndDay();
            datetext.setText(settext);
     
        }
     
        public void setDate(Date date) {
            DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
            datetext.setText(dateFormat.format(date));
        }
     
        public String getText() {
     
            if (datetext.getText().equals("    /  /  ")) {
                try {
                    datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter(null)));
                } catch (java.text.ParseException ex) {
                    ex.printStackTrace();
                }
                datetext.setText(null);
            } else if (datetext.getText().equals("    -  -  ")) {
                try {
                    datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter(null)));
                } catch (java.text.ParseException ex) {
                    ex.printStackTrace();
                }
                datetext.setText(null);
            } else {
     
                datetext.getText();
            }
            return datetext.getText();
        }
     
        public void setdateformatString() {
            if (DEFAULT_DATE_FORMAT.equals("yy/MM/dd")) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yy/MM/dd"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals("yyyy/MM/dd")) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yyyy/MM/dd"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals("dd/MM/yyyy")) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals("dd/MM/yy")) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yy"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals("MM/dd/yy")) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("MM/dd/yy"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals("MM/dd/yyyy")) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("MM/dd/yyyy"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals(null)) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yyyy/MM/dd"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals("")) {
     
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yyyy/MM/dd"))));
     
            } else if (DEFAULT_DATE_FORMAT.equals("yy-MM-dd")) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yy-MM-dd"))));
            } else if (DEFAULT_DATE_FORMAT.equals("yyyy-MM-dd")) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yyyy-MM-dd"))));
            } else if (DEFAULT_DATE_FORMAT.equals("dd-MM-yyyy")) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd-MM-yyyy"))));
            } else if (DEFAULT_DATE_FORMAT.equals("dd-MM-yy")) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd-MM-yy"))));
            } else if (DEFAULT_DATE_FORMAT.equals("MM-dd-yy")) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("MM-dd-yy"))));
            } else if (DEFAULT_DATE_FORMAT.equals("MM-dd-yyyy")) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("MM-dd-yyyydd"))));
            } else if (DEFAULT_DATE_FORMAT.equals(null)) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yyyy-MM-dd"))));
            } else if (DEFAULT_DATE_FORMAT.equals("")) {
                datetext.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("yyyy-MM-dd"))));
            } else {
                if (datetext.getFormatter() instanceof DefaultFormatter) {
                    DefaultFormatter f = (DefaultFormatter) datetext.getFormatter();
                    f.setAllowsInvalid(true);
                }
            }
     
        }
     
        public void setDateFormatString(String dateformat) {
            DEFAULT_DATE_FORMAT = dateformat;
            setdateformatString();
    //         return string;
     
        }
     
        private class DatePanel extends JPanel implements ChangeListener {
     
            int startYear = 1;
            int lastYear = 9999;
     
            Color backGroundColor = Color.gray;
            Color palletTableColor = Color.white;
            Color todayBackColor = Color.orange;
            Color weekFontColor = Color.blue;
            Color dateFontColor = Color.black;
            Color weekendFontColor = Color.red;
     
            Color controlLineColor = Color.GREEN;
            Color controlTextColor = new java.awt.Color(153, 0, 153);
            Color controlMoonnameTextColor = Color.BLUE;
     
            JSpinner yearSpin;
            JSpinner monthSpin;
            JButton[][] daysButton = new JButton[8][7];
     
            // Fill the days of the month in the buttons on the desired day
            DatePanel() {
     
                setLayout(new BorderLayout());
                setBorder(new LineBorder(backGroundColor, 2));
                setBackground(backGroundColor);
     
                JPanel topYearAndMonth = createYearAndMonthPanal();
                add(topYearAndMonth, BorderLayout.NORTH);
                JPanel centerWeekAndDay = createWeekAndDayPanal();
                add(centerWeekAndDay, BorderLayout.CENTER);
     
                reflushWeekAndDay();
            }
     
            //Build a panel for daylight months and sppiners and labels
            private JPanel createYearAndMonthPanal() {
                Font font = new Font("Tahoma", Font.BOLD, 10);
     
                JPanel panel = new JPanel();
                panel.setLayout(new FlowLayout());
                panel.setBackground(controlLineColor);
                JLabel yearLabel = new JLabel("السنة");
                yearLabel.setForeground(controlTextColor);
                yearLabel.setHorizontalAlignment(SwingConstants.CENTER);
                yearLabel.setVerticalAlignment(SwingConstants.CENTER);
                yearLabel.setFont(font);
     
                panel.add(yearLabel);
                yearSpin = new JSpinner(new SpinnerNumberModel(ye,
                        startYear, lastYear, 1));
     
                yearSpin.setPreferredSize(new Dimension(60, 30));
                yearSpin.setName("Year");
                yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
                yearSpin.addChangeListener(this);
                panel.add(yearSpin);
                monthSpin = new JSpinner(new SpinnerNumberModel(mo, 1,
                        12, 1));
     
                monthSpin.setPreferredSize(new Dimension(45, 30));
                monthSpin.setName("Month");
                monthSpin.addChangeListener(this);
                monthNameLabel.setPreferredSize(new Dimension(65, 20));
                monthNameLabel.setForeground(controlTextColor);
                monthNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
                monthNameLabel.setVerticalAlignment(SwingConstants.CENTER);
                monthNameLabel.setFont(font);
                monthNameLabel.setText(moonNames[(Integer) monthSpin.getValue() - 1]);  // get name from array
                panel.add(monthNameLabel);
     
                panel.add(monthSpin);
     
                JLabel monthLabel = new JLabel("الشهر");
                monthLabel.setForeground(controlTextColor);
                monthLabel.setHorizontalAlignment(SwingConstants.CENTER);
                monthLabel.setVerticalAlignment(SwingConstants.CENTER);
                monthLabel.setFont(font);
                panel.add(monthLabel);
     
                return panel;
            }
     
            //Fill the days of the month in the buttons on the desired day
            private JPanel createWeekAndDayPanal() {
     
                JPanel panel = new JPanel();
                panel.setFont(new Font("Tahoma", Font.PLAIN, 10));
                panel.setLayout(new GridLayout(7, 7));
                panel.setBackground(Color.white);
     
                for (int i = 0; i < 7; i++) {
                    cell = new JLabel(colname[i]);
                    cell.setHorizontalAlignment(JLabel.CENTER);
                    if (i == 6) {
                        cell.setForeground(weekendFontColor);
                    } else {
                        cell.setForeground(weekFontColor);
                    }
                    panel.add(cell);
                }
     
                int actionCommandId = 0;
                for (int i = 0; i < 6; i++) {
     
                    for (int j = 0; j < 7; j++) {
                        JButton numBtn = new JButton();
                        numBtn.setBorder(null);
                        numBtn.setHorizontalAlignment(SwingConstants.CENTER);
                        numBtn.setActionCommand(String.valueOf(actionCommandId));
                        numBtn.setBackground(palletTableColor);
                        numBtn.setForeground(dateFontColor);
                        numBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent event) {
     
                                JButton source = (JButton) event.getSource();
     
                                if (source.getText().length() == 0) {
                                    numBtn.setForeground(dateFontColor);
     
                                    return;
                                }
     
                                numBtn.setBackground(palletTableColor);
                                numBtn.setForeground(dateFontColor);
                                source.setForeground(todayBackColor);
     
                                int newDay = Integer.parseInt(source.getText());
                                da = newDay;
     
                                setDate();
                                dayColorUpdate(true);
                                dateDialog.setVisible(false);
                            }
                        });
     
                        daysButton[i][j] = numBtn;
                        panel.add(numBtn);
                        actionCommandId++;
                        if (j == 6) {
                            numBtn.setForeground(weekendFontColor);
                        } else {
                            numBtn.setForeground(dateFontColor);
                        }
                    }
                }
     
                return panel;
            }
     
            private HijrahDate getCalendar() {
     
                HijrahDate today = HijrahChronology.INSTANCE.date(ye, mo, da);
     
                return today;
            }
     
            private int getSelectedYear() {
                return ((Integer) yearSpin.getValue()).intValue();
            }
     
            private int getSelectedMonth() {
                return ((Integer) monthSpin.getValue()).intValue();
            }
     
            // Paint the days of the week and today
            public void dayColorUpdate(boolean isOldDay) {
     
                String s = String.valueOf(da);
                for (int a = 0; a < 6; a++) {
                    for (int b = 0; b < 7; b++) {
                        daysButton[a][b].setForeground(dateFontColor);
                        daysButton[a][6].setForeground(weekendFontColor);
     
                        if (daysButton[a][b].getText().equals(s)) {
     
                            daysButton[a][b].setForeground(todayBackColor);
     
                        }
                    }
                }
            }
    // Specify the number of days of a cat and start on what day and end on what day
     
            private void reflushWeekAndDay() {
     
                ye = (Integer) yearSpin.getValue();
                mo = (Integer) monthSpin.getValue();
     
                Locale ar = new Locale("ar");
     
                DateTimeFormatter dayOfweekNum = DateTimeFormatter.ofPattern("c", ar);
                HijrahDate hijrahDate = HijrahChronology.INSTANCE.date(ye, mo, 1);
     
                String WeekdayNum = hijrahDate.format(dayOfweekNum);
                DateTimeFormatter dayOfMonth = DateTimeFormatter.ofPattern("d", ar);
                String MonthdayNum = hijrahDate.format(dayOfMonth);
     
                int WeekdayNumb = Integer.parseInt(WeekdayNum);
     
                int moondaysnumber = hijrahDate.lengthOfMonth();
     
                int maxDayNo = moondaysnumber;
     
                int dayNo = 2 - WeekdayNumb;//set days in are in place
     
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 7; j++) {
                        String s = "";
                        if (dayNo >= 1 && dayNo <= maxDayNo) {
                            s = String.valueOf(dayNo);
                        }
                        daysButton[i][j].setText(s);
                        dayNo++;
                        if (daysButton[i][j].getText().equals("")) {
                            daysButton[i][j].setVisible(false);
                        } else {
                            daysButton[i][j].setVisible(true);
     
                        }
     
                    }
     
                }
                dayColorUpdate(false);
            }
     
            // set year when click on jdialog button's and spinner and textfild
            public void stateChanged(ChangeEvent e) {
                dayColorUpdate(true);
                JSpinner source = (JSpinner) e.getSource();
                if (source.getName().equals("Year")) {
                    ye = (getSelectedYear());
                } else {
                    mo = (getSelectedMonth());
                }
                getCalendar();
                reflushWeekAndDay();
                setDate();
                mothnam();
            }
     
        }
     
        // set month when click on jdialog button's and spinner and textfild
        public void mothnam() {
            monthNameLabel.setText(moonNames[mo - 1]);
        }
     
        //set date for jtext and jdialog....
        String getHDateString() {                  //  ADDED
    //        if(!datetext.getText().equals(null)||!datetext.getText().equals("")||!datetext.getText().equals("    /  /  ")||!datetext.getText().equals("    -  -  ")||!datetext.getText().equals("  -  -  ")||!datetext.getText().equals("  -  -    ")||!datetext.getText().equals("  -    -  ")){
     
     
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT);
            HijrahDate today = HijrahChronology.INSTANCE.date(ye, mo, da);
            String formatted = formatter.format(today); // 1442/10/14
     
            return formatted.toString(); //<<<<<< ADDED
        }
    }
    Last edited by cnmeysam; May 9th, 2021 at 04:13 PM.

  2. #2

    Default Re: library for Hijra date chooser

    with this class i can create a component for date picker

     
     
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.Frame;
    import java.awt.GridLayout;
    import java.awt.Point;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.text.Format;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.time.LocalDate;
    import java.time.chrono.HijrahDate;
    import java.time.format.DateTimeFormatter;
    import java.util.Calendar;
    import java.util.Date;
     
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSpinner;
    import javax.swing.JTextField;
    import javax.swing.SpinnerNumberModel;
    import javax.swing.SwingConstants;
    import javax.swing.SwingUtilities;
    import javax.swing.border.LineBorder;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
     
    public class DateTextField extends JTextField {
     
        private static String DEFAULT_DATE_FORMAT = "yyyy/MM/dd";
        private static final int DIALOG_WIDTH = 210;
        private static final int DIALOG_HEIGHT = 210;
     
        private SimpleDateFormat dateFormat;
        private DatePanel datePanel = null;
        private JDialog dateDialog = null;
     
        public DateTextField() {
            this(new Date());
        }
     
        public DateTextField(String dateFormatPattern, Date date) {
            this(date);
            DEFAULT_DATE_FORMAT = dateFormatPattern;
        }
     
        public DateTextField(Date date) {
            setDate(date);
            setEditable(false);
            setCursor(new Cursor(Cursor.HAND_CURSOR));
            addListeners();
        }
     
        private void addListeners() {
            addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent paramMouseEvent) {
                    if (datePanel == null) {
                        datePanel = new DatePanel();
                    }
                    Point point = getLocationOnScreen();
                    point.y = point.y + 30;
                    showDateDialog(datePanel, point);
                }
            });
        }
     
        private void showDateDialog(DatePanel dateChooser, Point position) {
            Frame owner = (Frame) SwingUtilities
                    .getWindowAncestor(DateTextField.this);
            if (dateDialog == null || dateDialog.getOwner() != owner) {
                dateDialog = createDateDialog(owner, dateChooser);
            }
            dateDialog.setLocation(getAppropriateLocation(owner, position));
            dateDialog.setVisible(true);
        }
     
        private JDialog createDateDialog(Frame owner, JPanel contentPanel) {
            JDialog dialog = new JDialog(owner, "Date Selected", true);
            dialog.setUndecorated(true);
            dialog.getContentPane().add(contentPanel, BorderLayout.CENTER);
            dialog.pack();
            dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
            return dialog;
        }
     
        private Point getAppropriateLocation(Frame owner, Point position) {
            Point result = new Point(position);
            Point p = owner.getLocation();
            int offsetX = (position.x + DIALOG_WIDTH) - (p.x + owner.getWidth());
            int offsetY = (position.y + DIALOG_HEIGHT) - (p.y + owner.getHeight());
     
            if (offsetX > 0) {
                result.x -= offsetX;
            }
     
            if (offsetY > 0) {
                result.y -= offsetY;
            }
     
            return result;
        }
     
        private SimpleDateFormat getDefaultDateFormat() {
            if (dateFormat == null) {
                dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
            }
            return dateFormat;
        }
     
        public void setText(Date date) {
            setDate(date);
        }
     
        public void setDate(Date date) {
            super.setText(getDefaultDateFormat().format(date));
        }
     
        public Date getDate() {
            try {
                return getDefaultDateFormat().parse(getText());
            } catch (ParseException e) {
                return new Date();
            }
        }
     
        private class DatePanel extends JPanel implements ChangeListener {
     
            int startYear = 1380;
            int lastYear = 3050;
     
            Color backGroundColor = Color.gray;
            Color palletTableColor = Color.white;
            Color todayBackColor = Color.orange;
            Color weekFontColor = Color.blue;
            Color dateFontColor = Color.black;
            Color weekendFontColor = Color.red;
     
            Color controlLineColor = Color.pink;
            Color controlTextColor = Color.white;
     
            JSpinner yearSpin;
            JSpinner monthSpin;
            JButton[][] daysButton = new JButton[6][7];
     
            DatePanel() {
                setLayout(new BorderLayout());
                setBorder(new LineBorder(backGroundColor, 2));
                setBackground(backGroundColor);
     
                JPanel topYearAndMonth = createYearAndMonthPanal();
                add(topYearAndMonth, BorderLayout.NORTH);
                JPanel centerWeekAndDay = createWeekAndDayPanal();
                add(centerWeekAndDay, BorderLayout.CENTER);
     
                reflushWeekAndDay();
            }
     
            private JPanel createYearAndMonthPanal() {
                Calendar cal = getCalendar();
                int currentYear = cal.get(Calendar.YEAR);
                int currentMonth = cal.get(Calendar.MONTH) + 1;
     
                JPanel panel = new JPanel();
                panel.setLayout(new FlowLayout());
                panel.setBackground(controlLineColor);
     
                yearSpin = new JSpinner(new SpinnerNumberModel(currentYear,
                        startYear, lastYear, 1));
                yearSpin.setPreferredSize(new Dimension(60, 30));
                yearSpin.setName("Year");
                yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
                yearSpin.addChangeListener(this);
                panel.add(yearSpin);
     
                JLabel yearLabel = new JLabel("Year");
                yearLabel.setForeground(controlTextColor);
                panel.add(yearLabel);
     
                monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1,
                        12, 1));
                monthSpin.setPreferredSize(new Dimension(45, 30));
                monthSpin.setName("Month");
                monthSpin.addChangeListener(this);
                panel.add(monthSpin);
     
                JLabel monthLabel = new JLabel("Month");
                monthLabel.setForeground(controlTextColor);
                panel.add(monthLabel);
     
                return panel;
            }
     
            private JPanel createWeekAndDayPanal() {
                String colname[] = {"sun", "Mon", "Tu", "We", "Th", "Fr", "Sa"};
                JPanel panel = new JPanel();
                panel.setFont(new Font("Arial", Font.PLAIN, 10));
                panel.setLayout(new GridLayout(7, 7));
                panel.setBackground(Color.white);
     
                for (int i = 0; i < 7; i++) {
                    JLabel cell = new JLabel(colname[i]);
                    cell.setHorizontalAlignment(JLabel.CENTER);
    //                if (i == 0 || i == 6) {
                        if (i == 5) {
                        cell.setForeground(weekendFontColor);
                    } else {
                        cell.setForeground(weekFontColor);
                    }
                    panel.add(cell);
                }
     
                int actionCommandId = 0;
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 7; j++) {
                        JButton numBtn = new JButton();
                        numBtn.setBorder(null);
                        numBtn.setHorizontalAlignment(SwingConstants.CENTER);
                        numBtn.setActionCommand(String
                                .valueOf(actionCommandId));
                        numBtn.setBackground(palletTableColor);
                        numBtn.setForeground(dateFontColor);
                        numBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent event) {
                                JButton source = (JButton) event.getSource();
                                if (source.getText().length() == 0) {
                                    return;
                                }
                                dayColorUpdate(true);
                                source.setForeground(todayBackColor);
                                int newDay = Integer.parseInt(source.getText());
                                Calendar cal = getCalendar();
                                cal.set(Calendar.DAY_OF_MONTH, newDay);
                                setDate(cal.getTime());
     
                                dateDialog.setVisible(false);
                            }
                        });
     
    //                    if (j == 0 || j == 6) {
                            if (j == 5) {
                            numBtn.setForeground(weekendFontColor);
                        } else {
                            numBtn.setForeground(dateFontColor);
                        }
                        daysButton[i][j] = numBtn;
                        panel.add(numBtn);
                        actionCommandId++;
                    }
                }
     
                return panel;
            }
     
            private Calendar getCalendar() {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(getDate());
                return calendar;
            }
     
            private int getSelectedYear() {
                return ((Integer) yearSpin.getValue()).intValue();
            }
     
            private int getSelectedMonth() {
                return ((Integer) monthSpin.getValue()).intValue();
            }
     
            private void dayColorUpdate(boolean isOldDay) {
                Calendar cal = getCalendar();
                int day = cal.get(Calendar.DAY_OF_MONTH);
                cal.set(Calendar.DAY_OF_MONTH, 1);
                int actionCommandId = day - 2 + cal.get(Calendar.DAY_OF_WEEK);
                int i = actionCommandId / 7;
                int j = actionCommandId % 7;
                if (isOldDay) {
                    daysButton[i][j].setForeground(dateFontColor);
                } else {
                    daysButton[i][j].setForeground(todayBackColor);
                }
            }
     
            private void reflushWeekAndDay() {
                Calendar cal = getCalendar();
                cal.set(Calendar.DAY_OF_MONTH, 1);
                int maxDayNo = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                int dayNo = 2 - cal.get(Calendar.DAY_OF_WEEK);
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 7; j++) {
                        String s = "";
                        if (dayNo >= 1 && dayNo <= maxDayNo) {
                            s = String.valueOf(dayNo);
                        }
                        daysButton[i][j].setText(s);
                        dayNo++;
                    }
                }
                dayColorUpdate(false);
            }
     
            public void stateChanged(ChangeEvent e) {
                dayColorUpdate(true);
     
                JSpinner source = (JSpinner) e.getSource();
                Calendar cal = getCalendar();
                if (source.getName().equals("Year")) {
                    cal.set(Calendar.YEAR, getSelectedYear());
                } else {
                    cal.set(Calendar.MONTH, getSelectedMonth() - 1);
                }
                setDate(cal.getTime());
                reflushWeekAndDay();
            }
        }
    }

    and with this command i can find hijri date
    https://docs.oracle.com/javase/8/doc...ijrahDate.html
     
    import java.time.chrono.HijrahChronology;
     
            LocalDate dt = LocalDate.of(2021, 04, 25);
            HijrahDate hijrahDate = HijrahDate.from(dt);
            System.out.println("hijrahDate " + hijrahDate);
     
    Locale ar = new Locale("ar");
            DateTimeFormatter dayOfWeekFormatter = DateTimeFormatter.ofPattern("EEEE", ar);
            HijrahDate today = HijrahChronology.INSTANCE.date(1442, 9, 13);
            System.out.println("Chronology: " + today.getChronology());
            String dayName = today.format(dayOfWeekFormatter);
            System.out.println("Day Name " + dayName);
     
            DateTimeFormatter MoonOfWeekFormatter = DateTimeFormatter.ofPattern("MMMM", ar);
            String MonName = today.format(MoonOfWeekFormatter);
            System.out.println("Moon Name " + MonName);
     
    //hijrahDate Hijrah-umalqura AH 1442-09-13
    //Day Name الأحد
    //Moon Name رمضان

    How can I replace the Gregorian calendar with the Hijri calendar in this class?
    Last edited by cnmeysam; April 24th, 2021 at 11:44 PM.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    Can you make and post a small, simple class with a main method that creates the components needed for testing your textfield class?
    If you don't understand my answer, don't ignore it, ask a question.

  4. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 25th, 2021)

  5. #4

    Default Re: library for Hijra date chooser

    Clean and build the DateTextField class, then add it to the palette and add it to the form Then you can use it

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    I do not have an IDE that does that.
    If you don't understand my answer, don't ignore it, ask a question.

  7. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 25th, 2021)

  8. #6

    Default Re: library for Hijra date chooser

    I'm sorry but i don't no how i must create a small, simple class for use this class. maybe this work fist you create DateTextField class and then use this

     
     
    public class NewJFrame extends javax.swing.JFrame {
     
        public NewJFrame() {
            initComponents();
        }
     
     
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            dateTextField1 = new DateTextField();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(58, 58, 58)
                    .addComponent(dateTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(217, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(58, 58, 58)
                    .addComponent(dateTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(222, Short.MAX_VALUE))
            );
     
            pack();
        }// </editor-fold>                        
     
     
        public static void main(String args[]) {
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
     
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify                     
        private DateTextField dateTextField1;
        // End of variables declaration                   
    }
    Last edited by cnmeysam; April 25th, 2021 at 12:58 PM.

  9. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    I do not have the fonts needed for the print out. All I get is ???s when I execute the code for the hijri date.

    Here is what I see in the textfield:
    2021/04/15 Hijrah-umalqura AH 1442-09-13 رمضان الأحد

    from this statement at the end of the code for he hijri date put into a method named testMethod:
     
            super.setText(getDefaultDateFormat().format(date) + " " + testMethod());   //<<<<< Changed
    ...
       String testMethod() {                  //  ADDED
          ...  your code
            return hijrahDate.toString() + " " + MonName + " " + dayName; //<<<<<< ADDED
        }
    If you don't understand my answer, don't ignore it, ask a question.

  10. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 25th, 2021)

  11. #8

    Default Re: library for Hijra date chooser

    if you use command line you cant see Persian or Arabic or any Asian language
    i think you use console's
    but no problem you send me your class i can test it in IDE
    or you can add new font like Arial or Tahoma in command prompt (for support Persian or Arabic)

    --- Update ---

    Your output its true

  12. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    The JVM appears to have the font. See my last post.
    If you don't understand my answer, don't ignore it, ask a question.

  13. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 25th, 2021)

  14. #10

    Default Re: library for Hijra date chooser

    can you send all class? i need all date in dateDialog just show hijri date
    and when focus lost dateDialog is close
    Last edited by cnmeysam; April 25th, 2021 at 02:06 PM.

  15. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    I have only copied what you have posted. I do not any any new classes.
    I only added/changed the statements I posted above.
    If you don't understand my answer, don't ignore it, ask a question.

  16. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 25th, 2021)

  17. #12

    Default Re: library for Hijra date chooser

    Unfortunately You do not understand what I mean
    I want the Hijri date to be loaded in the dialog box, and when I click on a day, only that date, like the Gregorian date, will be displayed in the text. and start day from Saturday and when click outside of dialog box its close

  18. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    Yes, That is the code you are going to have to write.
    My code was just to test if I have the font so I could see the characters, not just ????s
    If you don't understand my answer, don't ignore it, ask a question.

  19. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 25th, 2021)

  20. #14

    Default Re: library for Hijra date chooser

    this is my code now
     
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
     
     
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.Frame;
    import java.awt.GridLayout;
    import java.awt.Point;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.text.Format;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.time.LocalDate;
    import java.time.chrono.HijrahDate;
    import java.time.format.DateTimeFormatter;
    import java.util.Calendar;
    import java.util.Date;
     
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSpinner;
    import javax.swing.JTextField;
    import javax.swing.SpinnerNumberModel;
    import javax.swing.SwingConstants;
    import javax.swing.SwingUtilities;
    import javax.swing.border.LineBorder;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import java.time.chrono.HijrahChronology;
    import java.util.Locale;
     
    public class NewClass extends JTextField {
     
        String testMethod() {                  //  ADDED
           LocalDate dt = LocalDate.of(2021, 04, 25);
            HijrahDate hijrahDate = HijrahDate.from(dt);
            System.out.println("hijrahDate " + hijrahDate);
     
    Locale ar = new Locale("ar");
            DateTimeFormatter dayOfWeekFormatter = DateTimeFormatter.ofPattern("EEEE", ar);
            HijrahDate today = HijrahChronology.INSTANCE.date(1442, 9, 13);
            System.out.println("Chronology: " + today.getChronology());
            String dayName = today.format(dayOfWeekFormatter);
            System.out.println("Day Name " + dayName);
     
            DateTimeFormatter MoonOfWeekFormatter = DateTimeFormatter.ofPattern("MMMM", ar);
            String MonName = today.format(MoonOfWeekFormatter);
            System.out.println("Moon Name " + MonName);
     
    //hijrahDate Hijrah-umalqura AH 1442-09-13
    //Day Name الأحد
    //Moon Name رمضان
            return hijrahDate.toString() + " " + MonName + " " + dayName; //<<<<<< ADDED
        }
        private static String DEFAULT_DATE_FORMAT = "yyyy/MM/dd";
        private static final int DIALOG_WIDTH = 210;
        private static final int DIALOG_HEIGHT = 210;
     
        private SimpleDateFormat dateFormat;
        private DatePanel datePanel = null;
        private JDialog dateDialog = null;
     
        public NewClass() {
            this(new Date());
     
        }
     
        public NewClass(String dateFormatPattern, Date date) {
            this(date);
            DEFAULT_DATE_FORMAT = dateFormatPattern;
     
        }
     
        public NewClass(Date date) {
            setDate(date);
            setEditable(false);
            setCursor(new Cursor(Cursor.HAND_CURSOR));
            addListeners();
     
     
        }
     
        public void listener(){
    //        pannel. 
    //        dateDialog.setVisible(false);
            addFocusListener(new FocusAdapter() {
                public void focusGained(java.awt.event.FocusEvent evt) {
                    panelFocusGained(evt);
                }
                public void focusLost(java.awt.event.FocusEvent evt) {
                    panelFocusLost(evt);
                }
     
                    private void panelFocusGained(FocusEvent evt) {
                    System.out.println("panel : Focus Gained");
     
     
                    }
     
                    private void panelFocusLost(FocusEvent evt) {
                    System.out.println("panel : Focus Lost");
     
     
                    }
            });
        }
        private void addListeners() {
            addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent paramMouseEvent) {
                    if (datePanel == null) {
                        datePanel = new DatePanel();
                    }
                    Point point = getLocationOnScreen();
                    point.y = point.y + 30;
                    showDateDialog(datePanel, point);
                }
            });
        }
     
        private void showDateDialog(DatePanel dateChooser, Point position) {
     
            Frame owner = (Frame) SwingUtilities
                    .getWindowAncestor(NewClass.this);
            if (dateDialog == null || dateDialog.getOwner() != owner) {
                dateDialog = createDateDialog(owner, dateChooser);
            }
            dateDialog.setLocation(getAppropriateLocation(owner, position));
            dateDialog.setVisible(true);
     
        }
     
        private JDialog createDateDialog(Frame owner, JPanel contentPanel) {
            JDialog dialog = new JDialog(owner, "Date Selected", true);
            dialog.setUndecorated(true);
            dialog.getContentPane().add(contentPanel, BorderLayout.CENTER);
            dialog.pack();
            dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
     
            return dialog;
     
        }
     
        private Point getAppropriateLocation(Frame owner, Point position) {
            Point result = new Point(position);
            Point p = owner.getLocation();
            int offsetX = (position.x + DIALOG_WIDTH) - (p.x + owner.getWidth());
            int offsetY = (position.y + DIALOG_HEIGHT) - (p.y + owner.getHeight());
     
            if (offsetX > 0) {
                result.x -= offsetX;
            }
     
            if (offsetY > 0) {
                result.y -= offsetY;
            }
     
            return result;
        }
     
        private SimpleDateFormat getDefaultDateFormat() {
            if (dateFormat == null) {
                dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
            }
            return dateFormat;
        }
     
        public void setText(Date date) {
            setDate(date);
        }
     
        public void setDate(Date date) {
            super.setText(getDefaultDateFormat().format(date) + " " + testMethod());   //<<<<< Changed
        }
     
        public Date getDate() {
            try {
                return getDefaultDateFormat().parse(getText());
            } catch (ParseException e) {
                return new Date();
            }
        }
     
        private class DatePanel extends JPanel implements ChangeListener {
     
     
     
            int startYear = 1380;
            int lastYear = 3050;
     
            Color backGroundColor = Color.gray;
            Color palletTableColor = Color.white;
            Color todayBackColor = Color.orange;
            Color weekFontColor = Color.blue;
            Color dateFontColor = Color.black;
            Color weekendFontColor = Color.red;
     
            Color controlLineColor = Color.pink;
            Color controlTextColor = Color.white;
     
            JSpinner yearSpin;
            JSpinner monthSpin;
            JButton[][] daysButton = new JButton[6][7];
     
            DatePanel() {
                setLayout(new BorderLayout());
                setBorder(new LineBorder(backGroundColor, 2));
                setBackground(backGroundColor);
     
                JPanel topYearAndMonth = createYearAndMonthPanal();
                add(topYearAndMonth, BorderLayout.NORTH);
                JPanel centerWeekAndDay = createWeekAndDayPanal();
                add(centerWeekAndDay, BorderLayout.CENTER);
     
                reflushWeekAndDay();
            }
     
            private JPanel createYearAndMonthPanal() {
                Calendar cal = getCalendar();
                int currentYear = cal.get(Calendar.YEAR);
                int currentMonth = cal.get(Calendar.MONTH) + 1;
     
                JPanel panel = new JPanel();
                panel.setLayout(new FlowLayout());
                panel.setBackground(controlLineColor);
     
                yearSpin = new JSpinner(new SpinnerNumberModel(currentYear,
                        startYear, lastYear, 1));
                yearSpin.setPreferredSize(new Dimension(60, 30));
                yearSpin.setName("Year");
                yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
                yearSpin.addChangeListener(this);
                panel.add(yearSpin);
     
                JLabel yearLabel = new JLabel("Year");
                yearLabel.setForeground(controlTextColor);
                panel.add(yearLabel);
     
                monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1,
                        12, 1));
                monthSpin.setPreferredSize(new Dimension(45, 30));
                monthSpin.setName("Month");
                monthSpin.addChangeListener(this);
                panel.add(monthSpin);
     
                JLabel monthLabel = new JLabel("Month");
                monthLabel.setForeground(controlTextColor);
                panel.add(monthLabel);
     
                return panel;
            }
     
            private JPanel createWeekAndDayPanal() {
                String colname[] = {"sun", "Mon", "Tu", "We", "Th", "Fr", "Sa"};
                JPanel panel = new JPanel();
                panel.setFont(new Font("Arial", Font.PLAIN, 10));
                panel.setLayout(new GridLayout(7, 7));
                panel.setBackground(Color.white);
     
     
     
     
                for (int i = 0; i < 7; i++) {
                    JLabel cell = new JLabel(colname[i]);
                    cell.setHorizontalAlignment(JLabel.CENTER);
    //                if (i == 0 || i == 6) {
                        if (i == 5) {
                        cell.setForeground(weekendFontColor);
                    } else {
                        cell.setForeground(weekFontColor);
                    }
                    panel.add(cell);
                }
     
                int actionCommandId = 0;
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 7; j++) {
                        JButton numBtn = new JButton();
                        numBtn.setBorder(null);
                        numBtn.setHorizontalAlignment(SwingConstants.CENTER);
                        numBtn.setActionCommand(String
                                .valueOf(actionCommandId));
                        numBtn.setBackground(palletTableColor);
                        numBtn.setForeground(dateFontColor);
                        numBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent event) {
                                JButton source = (JButton) event.getSource();
                                if (source.getText().length() == 0) {
                                    return;
                                }
                                dayColorUpdate(true);
                                source.setForeground(todayBackColor);
                                int newDay = Integer.parseInt(source.getText());
                                Calendar cal = getCalendar();
                                cal.set(Calendar.DAY_OF_MONTH, newDay);
                                setDate(cal.getTime());
     
                                dateDialog.setVisible(false);
                            }
                        });
     
    //                    if (j == 0 || j == 6) {
                            if (j == 5) {
                            numBtn.setForeground(weekendFontColor);
                        } else {
                            numBtn.setForeground(dateFontColor);
                        }
                        daysButton[i][j] = numBtn;
                        panel.add(numBtn);
                        actionCommandId++;
                    }
                }
     
     
                return panel;
            }
     
            private Calendar getCalendar() {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(getDate());
                return calendar;
            }
     
            private int getSelectedYear() {
                return ((Integer) yearSpin.getValue()).intValue();
            }
     
            private int getSelectedMonth() {
                return ((Integer) monthSpin.getValue()).intValue();
            }
     
            private void dayColorUpdate(boolean isOldDay) {
                Calendar cal = getCalendar();
                int day = cal.get(Calendar.DAY_OF_MONTH);
                cal.set(Calendar.DAY_OF_MONTH, 1);
                int actionCommandId = day - 2 + cal.get(Calendar.DAY_OF_WEEK);
                int i = actionCommandId / 7;
                int j = actionCommandId % 7;
                if (isOldDay) {
                    daysButton[i][j].setForeground(dateFontColor);
                } else {
                    daysButton[i][j].setForeground(todayBackColor);
                }
            }
     
            private void reflushWeekAndDay() {
                Calendar cal = getCalendar();
                cal.set(Calendar.DAY_OF_MONTH, 1);
                int maxDayNo = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                int dayNo = 2 - cal.get(Calendar.DAY_OF_WEEK);
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 7; j++) {
                        String s = "";
                        if (dayNo >= 1 && dayNo <= maxDayNo) {
                            s = String.valueOf(dayNo);
                        }
                        daysButton[i][j].setText(s);
                        dayNo++;
                    }
                }
                dayColorUpdate(false);
            }
     
            public void stateChanged(ChangeEvent e) {
                dayColorUpdate(true);
     
                JSpinner source = (JSpinner) e.getSource();
                Calendar cal = getCalendar();
                if (source.getName().equals("Year")) {
                    cal.set(Calendar.YEAR, getSelectedYear());
                } else {
                    cal.set(Calendar.MONTH, getSelectedMonth() - 1);
                }
                setDate(cal.getTime());
                reflushWeekAndDay();
            }
     
     
        }
     
    }

    and i see this
    https://s18.picofile.com/file/8431830776/Untitled_1.jpg

  21. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    Ok, so you know what you want, now write the code for it.

    My code is not useful for your objective.
    If you don't understand my answer, don't ignore it, ask a question.

  22. #16

    Default Re: library for Hijra date chooser

    yes i now know
    and i fix some parts of my code
    now i need fix days in dialog box
    in hiji date 1442/09/14 is Monday but now show Friday and start day must start from Saturday
    how i must fix it?

    https://s18.picofile.com/file/8431831834/Capture.JPG

    and how i must say if focus lost dialog box is close and go to today?

    it is my new class code

     
     
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.Frame;
    import java.awt.GridLayout;
    import java.awt.Point;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.FocusAdapter;
    import java.awt.event.FocusEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.text.Format;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.time.LocalDate;
    import java.time.LocalDateTime;
    import java.time.chrono.HijrahDate;
    import java.time.format.DateTimeFormatter;
    import java.util.Calendar;
    import java.util.Date;
     
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSpinner;
    import javax.swing.JTextField;
    import javax.swing.SpinnerNumberModel;
    import javax.swing.SwingConstants;
    import javax.swing.SwingUtilities;
    import javax.swing.border.LineBorder;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import java.time.chrono.HijrahChronology;
    import java.util.Locale;
     
    public class NewClass extends JTextField {
     
        String testMethod() {                  //  ADDED
            Date dt = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String setText = (sdf.format(dt));
            String yearsubstr = "";
            String year = setText;
            String monsubstr = "";
            String mon = setText;
            String daysubstr = "";
            String day = setText;
            yearsubstr = year.substring(0, 4);
            monsubstr = mon.substring(5, 7);
            daysubstr = day.substring(8, 10);
            int y = Integer.parseInt(yearsubstr);
            int m = Integer.parseInt(monsubstr);
            int d = Integer.parseInt(daysubstr);
     
            LocalDate dts = LocalDate.of(y, m, d);
            HijrahDate hijrahDate = HijrahDate.from(dts);
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
            String formatted = formatter.format(hijrahDate); // 07/03/1439
            System.out.println("hijrahDate " + formatted);
            return formatted.toString(); //<<<<<< ADDED
        }
        private static String DEFAULT_DATE_FORMAT = "yyyy/MM/dd";
        private static final int DIALOG_WIDTH = 210;
        private static final int DIALOG_HEIGHT = 210;
     
        private SimpleDateFormat dateFormat;
        private DatePanel datePanel = null;
        private JDialog dateDialog = null;
     
        public NewClass() {
            this(new Date());
     
        }
     
        public NewClass(String dateFormatPattern, Date date) {
            this(date);
            DEFAULT_DATE_FORMAT = dateFormatPattern;
     
        }
     
        public NewClass(Date date) {
            setDate(date);
            setEditable(false);
            setCursor(new Cursor(Cursor.HAND_CURSOR));
            addListeners();
     
        }
     
        public void listener() {
    //        pannel. 
    //        dateDialog.setVisible(false);
            addFocusListener(new FocusAdapter() {
                public void focusGained(java.awt.event.FocusEvent evt) {
                    panelFocusGained(evt);
                }
     
                public void focusLost(java.awt.event.FocusEvent evt) {
                    panelFocusLost(evt);
                }
     
                private void panelFocusGained(FocusEvent evt) {
                    System.out.println("panel : Focus Gained");
     
                }
     
                private void panelFocusLost(FocusEvent evt) {
                    System.out.println("panel : Focus Lost");
     
                }
            });
        }
     
        private void addListeners() {
            addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent paramMouseEvent) {
                    if (datePanel == null) {
                        datePanel = new DatePanel();
                    }
                    Point point = getLocationOnScreen();
                    point.y = point.y + 30;
                    showDateDialog(datePanel, point);
                }
            });
        }
     
        private void showDateDialog(DatePanel dateChooser, Point position) {
     
            Frame owner = (Frame) SwingUtilities
                    .getWindowAncestor(NewClass.this);
            if (dateDialog == null || dateDialog.getOwner() != owner) {
                dateDialog = createDateDialog(owner, dateChooser);
            }
            dateDialog.setLocation(getAppropriateLocation(owner, position));
            dateDialog.setVisible(true);
     
        }
     
        private JDialog createDateDialog(Frame owner, JPanel contentPanel) {
            JDialog dialog = new JDialog(owner, "Date Selected", true);
            dialog.setUndecorated(true);
            dialog.getContentPane().add(contentPanel, BorderLayout.CENTER);
            dialog.pack();
            dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
     
            return dialog;
     
        }
     
        private Point getAppropriateLocation(Frame owner, Point position) {
            Point result = new Point(position);
            Point p = owner.getLocation();
            int offsetX = (position.x + DIALOG_WIDTH) - (p.x + owner.getWidth());
            int offsetY = (position.y + DIALOG_HEIGHT) - (p.y + owner.getHeight());
     
            if (offsetX > 0) {
                result.x -= offsetX;
            }
     
            if (offsetY > 0) {
                result.y -= offsetY;
            }
     
            return result;
        }
     
        private SimpleDateFormat getDefaultDateFormat() {
            if (dateFormat == null) {
                dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
            }
            return dateFormat;
        }
     
        public void setText(Date date) {
            setDate(date);
        }
     
        public void setDate(Date date) {
    //        super.setText(getDefaultDateFormat().format(date) + " " + testMethod());   //<<<<< Changed
            super.setText(testMethod());   //<<<<< Changed
        }
     
        public Date getDate() {
            try {
                return getDefaultDateFormat().parse(getText());
            } catch (ParseException e) {
                return new Date();
            }
        }
     
        private class DatePanel extends JPanel implements ChangeListener {
     
            int startYear = 1380;
            int lastYear = 3050;
     
            Color backGroundColor = Color.gray;
            Color palletTableColor = Color.white;
            Color todayBackColor = Color.orange;
            Color weekFontColor = Color.blue;
            Color dateFontColor = Color.black;
            Color weekendFontColor = Color.red;
     
            Color controlLineColor = Color.pink;
            Color controlTextColor = Color.white;
     
            JSpinner yearSpin;
            JSpinner monthSpin;
            JButton[][] daysButton = new JButton[6][7];
     
            DatePanel() {
                setLayout(new BorderLayout());
                setBorder(new LineBorder(backGroundColor, 2));
                setBackground(backGroundColor);
     
                JPanel topYearAndMonth = createYearAndMonthPanal();
                add(topYearAndMonth, BorderLayout.NORTH);
                JPanel centerWeekAndDay = createWeekAndDayPanal();
                add(centerWeekAndDay, BorderLayout.CENTER);
     
                reflushWeekAndDay();
            }
     
            private JPanel createYearAndMonthPanal() {
                Calendar cal = getCalendar();
                int currentYear = cal.get(Calendar.YEAR);
                int currentMonth = cal.get(Calendar.MONTH) + 1;
     
                JPanel panel = new JPanel();
                panel.setLayout(new FlowLayout());
                panel.setBackground(controlLineColor);
     
                yearSpin = new JSpinner(new SpinnerNumberModel(currentYear,
                        startYear, lastYear, 1));
                yearSpin.setPreferredSize(new Dimension(60, 30));
                yearSpin.setName("Year");
                yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
                yearSpin.addChangeListener(this);
                panel.add(yearSpin);
     
                JLabel yearLabel = new JLabel("Year");
                yearLabel.setForeground(controlTextColor);
                panel.add(yearLabel);
     
                monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1,
                        12, 1));
                monthSpin.setPreferredSize(new Dimension(45, 30));
                monthSpin.setName("Month");
                monthSpin.addChangeListener(this);
                panel.add(monthSpin);
     
                JLabel monthLabel = new JLabel("Month");
                monthLabel.setForeground(controlTextColor);
                panel.add(monthLabel);
     
                return panel;
            }
     
            private JPanel createWeekAndDayPanal() {
                String colname[] = {"sun", "Mon", "Tu", "We", "Th", "Fr", "Sa"};
                JPanel panel = new JPanel();
                panel.setFont(new Font("Arial", Font.PLAIN, 10));
                panel.setLayout(new GridLayout(7, 7));
                panel.setBackground(Color.white);
     
                for (int i = 0; i < 7; i++) {
                    JLabel cell = new JLabel(colname[i]);
                    cell.setHorizontalAlignment(JLabel.CENTER);
    //                if (i == 0 || i == 6) {
                    if (i == 5) {
                        cell.setForeground(weekendFontColor);
                    } else {
                        cell.setForeground(weekFontColor);
                    }
                    panel.add(cell);
                }
     
                int actionCommandId = 0;
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 7; j++) {
                        JButton numBtn = new JButton();
                        numBtn.setBorder(null);
                        numBtn.setHorizontalAlignment(SwingConstants.CENTER);
                        numBtn.setActionCommand(String
                                .valueOf(actionCommandId));
                        numBtn.setBackground(palletTableColor);
                        numBtn.setForeground(dateFontColor);
                        numBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent event) {
                                JButton source = (JButton) event.getSource();
                                if (source.getText().length() == 0) {
                                    return;
                                }
                                dayColorUpdate(true);
                                source.setForeground(todayBackColor);
                                int newDay = Integer.parseInt(source.getText());
                                Calendar cal = getCalendar();
                                cal.set(Calendar.DAY_OF_MONTH, newDay);
                                setDate(cal.getTime());
     
                                dateDialog.setVisible(false);
                            }
                        });
     
    //                    if (j == 0 || j == 6) {
                        if (j == 5) {
                            numBtn.setForeground(weekendFontColor);
                        } else {
                            numBtn.setForeground(dateFontColor);
                        }
                        daysButton[i][j] = numBtn;
                        panel.add(numBtn);
                        actionCommandId++;
                    }
                }
     
                return panel;
            }
     
            private Calendar getCalendar() {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(getDate());
                return calendar;
            }
     
            private int getSelectedYear() {
                return ((Integer) yearSpin.getValue()).intValue();
            }
     
            private int getSelectedMonth() {
                return ((Integer) monthSpin.getValue()).intValue();
            }
     
            private void dayColorUpdate(boolean isOldDay) {
                Calendar cal = getCalendar();
                int day = cal.get(Calendar.DAY_OF_MONTH);
                cal.set(Calendar.DAY_OF_MONTH, 1);
                int actionCommandId = day - 2 + cal.get(Calendar.DAY_OF_WEEK);
                int i = actionCommandId / 7;
                int j = actionCommandId % 7;
                if (isOldDay) {
                    daysButton[i][j].setForeground(dateFontColor);
                } else {
                    daysButton[i][j].setForeground(todayBackColor);
                }
            }
     
            private void reflushWeekAndDay() {
                Calendar cal = getCalendar();
                cal.set(Calendar.DAY_OF_MONTH, 1);
                int maxDayNo = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                int dayNo = 2 - cal.get(Calendar.DAY_OF_WEEK);
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 7; j++) {
                        String s = "";
                        if (dayNo >= 1 && dayNo <= maxDayNo) {
                            s = String.valueOf(dayNo);
                        }
                        daysButton[i][j].setText(s);
                        dayNo++;
                    }
                }
                dayColorUpdate(false);
            }
     
            public void stateChanged(ChangeEvent e) {
                dayColorUpdate(true);
     
                JSpinner source = (JSpinner) e.getSource();
                Calendar cal = getCalendar();
                if (source.getName().equals("Year")) {
                    cal.set(Calendar.YEAR, getSelectedYear());
                } else {
                    cal.set(Calendar.MONTH, getSelectedMonth() - 1);
                }
                setDate(cal.getTime());
                reflushWeekAndDay();
            }
     
        }
     
    }
    Last edited by cnmeysam; April 25th, 2021 at 05:47 PM.

  23. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    You have listed several changes you want to make. Pick one and work on that. When it is fixed, move to the next one.

    my new class code
    What has been changed in that new code?
    If you don't understand my answer, don't ignore it, ask a question.

  24. #18

    Default Re: library for Hijra date chooser

    ok first how close dialog box when click outside of that and date show last date selected before?
    Last edited by cnmeysam; April 25th, 2021 at 06:51 PM.

  25. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    how close dialog box when click outside
    Take a look at this: https://stackoverflow.com/questions/...ide-of-jdialog
    If you don't understand my answer, don't ignore it, ask a question.

  26. #20

    Default Re: library for Hijra date chooser

    i use this code but not working
    public void listener() {
    //        pannel. 
    //        dateDialog.setVisible(false);
           addFocusListener(new FocusAdapter() {
                public void focusGained(java.awt.event.FocusEvent evt) {
                    dateDialogFocusGained(evt);
                }
     
                public void focusLost(java.awt.event.FocusEvent evt) {
                    dateDialogFocusLost(evt);
                }
     
                private void dateDialogFocusGained(FocusEvent evt) {
                    System.out.println("dateDialog : Focus Gained");
     
                }
     
                private void dateDialogFocusLost(FocusEvent evt) {
                    System.out.println("dateDialog : Focus Lost");
                    dateDialog.setVisible(false);
     
                }
            });
        }
    Last edited by cnmeysam; April 25th, 2021 at 08:05 PM.

  27. #21
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    What component was that listener added to?
    If you don't understand my answer, don't ignore it, ask a question.

  28. #22

    Default Re: library for Hijra date chooser

    I don't know
    Last edited by cnmeysam; April 25th, 2021 at 08:05 PM.

  29. #23
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    showDateDialog is the name of a method, not a Component. Component is a base class for many GUI classes.
    What Component was that focus listener added to?
    If you don't understand my answer, don't ignore it, ask a question.

  30. #24

    Default Re: library for Hijra date chooser

    I do not know how to explain
    But when I click on the date text, a box opens. I want the box to be closed when I click outside it.

  31. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: library for Hijra date chooser

    Try working with the focus to see if you can understand how it works and when it is gained and lost.

    I'm done for tonight. I'll be back tomorrow.
    If you don't understand my answer, don't ignore it, ask a question.

  32. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 25th, 2021)

Page 1 of 12 12311 ... LastLast

Similar Threads

  1. Splitting date string by date and time and assigning it to 2 variables
    By KaranSaxena in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 17th, 2014, 05:58 AM
  2. Start Date should be exactly 1 week before to End Date
    By bhanuchandar in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 26th, 2013, 08:07 AM
  3. Java Date Format in Date Object
    By Ashr Raza in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 13th, 2012, 10:47 AM
  4. Replies: 1
    Last Post: July 22nd, 2011, 07:08 AM