This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
56 lines (37 loc) · 2.06 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ir.fallahpoor.sample;
import ir.fallahpoor.jalalidatepicker.JalaliDatePicker;
import javax.swing.*;
import java.awt.*;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
JalaliDatePicker jalaliDatePicker = new JalaliDatePicker(frame);
// Use the following line to set the initial date of JalaliDatePicker
// JalaliDatePicker jalaliDatePicker = new JalaliDatePicker(frame, 1367, 8, 6);
// Use setDate to set the date of JalaliDatePicker
// jalaliDatePicker.setDate(1367, 6, 20);
// Use setDatePickerDialogSize to set the size of date picker dialog
jalaliDatePicker.setDatePickerDialogSize(600, 300);
// Use setDatePickerDialogMinimumSize to set the minimum size of date picker dialog
// jalaliDatePicker.setDatePickerDialogMinimumSize(450, 300);
// Use setDatePickerDialogResizable to set whether date picker dialog is resizable by user
// jalaliDatePicker.setDatePickerDialogResizable(false);
// Add a DateChangeListener to be notified when date is changed
jalaliDatePicker.addDateChangeListener((newYear, newMonth, newDay) ->
System.out.println("Date changed. New date is " + newYear + "/" + newMonth + "/" + newDay));
// Use setFont to set the default font of JalaliDatePicker
// jalaliDatePicker.setFont();
frame.add(jalaliDatePicker, BorderLayout.CENTER);
JButton resetDateButton = new JButton("Reset date");
resetDateButton.addActionListener(e -> jalaliDatePicker.resetDate());
frame.add(resetDateButton, BorderLayout.SOUTH);
frame.setSize(250, 100);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
});
}
}