Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General Discussion #2

Open
BlakeTNC opened this issue Feb 20, 2016 · 130 comments
Open

General Discussion #2

BlakeTNC opened this issue Feb 20, 2016 · 130 comments

Comments

@BlakeTNC
Copy link
Contributor

This "issue" is a free-form place for people to talk about things related to LGoodDatePicker. You can write any thoughts, ideas, etc, without needing to frame the discussion into an issue unless that format is needed.

@Taurendil
Copy link

Thank you for the great instrument. It is realy light and usefull. If you do not mind some ideas:

  1. Is it possible to make the text field to be not editable, so user has to choose the date only from calendar, no manual writing?Something like .setEditable(false).
  2. It would be perfect if you can set format of the output date in the field. Like in SimpleDateFormat.
  3. Are you planning to add it to maven repository?

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Mar 3, 2016

Hello Taurendil,
You are welcome, thank you for the compliments of the project.

1 Is it possible to make the text field to be not editable, so user has to choose the date only from calendar, no manual writing?Something like .setEditable(false).

This is a good idea for flexibility. I added a feature request for this feature. See #7.

In case the intention is to make sure that the user cannot type invalid text: It's probably worth noting that the component does automatic validation, and the user cannot commit invalid text to the date picker. If the user types text that is not a parsable date, or is not a valid date, or is a vetoed date, then they receive feedback while they are typing in the form of visual font and color cues. If they leave the field while the text is not in a valid state, it is automatically reverted the last valid state.

2 It would be perfect if you can set format of the output date in the field. Like in SimpleDateFormat.

The date picker currently has the ability to set the date format. For a working example, see the demo application for the date that is labeled "Custom Date Format".

You can set the date format by changing one or both of these two variables to something different than the default values: "DatePickerSettings.formatForDatesCommonEra" and "DatePickerSettings.formatForDatesBeforeCommonEra".

3 Are you planning to add it to maven repository?

Yes I would like to do so, but there are hurdles. Maven Central and sonatype.org publish a list of requirements for adding projects the central repository, and there are a some items on that list that I've never done before. I was reading about the project requirements yesterday and it sounds like it would be a pretty big undertaking. If there was a developer who had published to maven central before who was helping to change the project to meet the requirements, it would go a little faster. Either way, I would guess that the project will eventually be added to maven central.

warm regards,
Blake

@Taurendil
Copy link

I added a feature request for this feature. See #7.

Super. This is usefull when the application has to be sure user would have no problems with dates.

The date picker currently has the ability to set the date format. For a working example, see the demo application for the date that is labeled "Custom Date Format".

Sorry, I have not studied demo application well enough. I've runned it and saw the month is written in the words instead of numbers, and I made wrond conclusions. My fault.

Another one question to you. Now I am migrating from Microba to LGoodDatePicker, but I found that in my application buttons to switch the month and year are not displayed full. I believe it is because of Nimbus style. When I switch it off, buttons appears well. Please look at two screenshots below. The first one is with NImbus style, second without any style. Sorry for Russian language, but it is the only language of the application.
Nimbus picture
Default style

It there any way to fix it?

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Mar 4, 2016

Taurendil,
Thank you for reporting this display bug within the Nimbus look and feel. I believe it is fixed now. See the release of LGoodDatePicker 2.4.3 for the new version.

By the way, it looks like the default button size is really large in the Nimbus look and feel (which is one reason they were displaying weird before hand). However, the Nimbus look and feel is unique in that it supports built-in resizing of the components. I have not tried the other Nimbus sizes with the date picker, but this page explains how to do it, in case it is of interest to you: Changing the Nimbus size variant.

Let me know if you have any other problems.
warm regards,
Blake

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Mar 5, 2016

Taurendil,
Feature request #7 has been implemented, with the release of LGoodDatePicker 3.1.1. Please let me know how the new feature works for you (or if you find any bugs). The new functionality required quite a lot of improvements.

Warm regards,
Blake

@Taurendil
Copy link

Blake,

super, it does work fine. Thank you very much. Now I see you have dependency on jgoodies. Is it a permanent solution?

@BlakeTNC
Copy link
Contributor Author

Taurendil,

I'm glad that the new features are meeting your needs.

I see you have dependency on jgoodies. Is it a permanent solution?

Yes, The project definitely needs jgoodies. There are some design specifications that require the jgoodies FormLayout. (For example, the columns that contain the forward and back month/year navigation buttons need to be grouped so they always have the same size, even across different swing looks and feel settings.)

Note: You don't need to manually include jgoodies in your projects. The jgoodies library is included and packaged with the LGoodDatePicker distribution jars using Maven Shade.

Also, the included jgoodies classes will not conflict with anyone who happens to use another version of jgoodies, because the shading process renames the required classes at the same time they are included. The code has not significantly increased the size of the LGoodDatePicker jar files, because only the jgoodies classes that are used, were included by Maven Shade.

By the way, I imagine that you'll want to start using LGoodDatePicker 4.1.2. Is a major upgrade from the previous versions. Two new components have been added to the original date picker: A TimePicker, and a DateTimePicker. The demo has also been updated to show the new features. Besides the new features, there were a number of bug fixes and improvements to the original code.

Screenshots of the new components are included at the bottom of the LGoodDatePicker front page.

warm regards,
Blake

@Taurendil
Copy link

Blake, thank you for explanation, I have nothing against JGoodies, I just wanted to know if it is final solutions. LGoodDatePicker is excelent light library. I've just added new jar to my maven local repository and everything goes well. So waiting for publication in Maven Central. If you need any help please write to me. But I have no publication in Maven Central.

TimePicker is excelent feature, thank you for your support.

BTW, what do you think about any icon at the button next to the field for DatePicker and TimePicker (like in Microba project)? I can draw icons for you if you need it as a small support from my side.

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Mar 12, 2016

This comment was replaced because it is out of date. The library now has the ability to add custom image icons. (This feature was added in LGoodDatePicker 5.4.1)

@BlakeTNC
Copy link
Contributor Author

Hi Taurendil,
The project has been officially added to Maven Central. I had to make some major changes to the project to meet their requirements. (Including changing all the package names and overhauling the Pom file). If you can create a test project that uses maven central to fill the dependency, (and let me know if the 4.3.1 release is working for you), that would be great. If not, that's fine too.

Here are the LGoodDatePicker project pages at Maven Central: Maven Central, or MVNRepository.

warm regards,
Blake

@Taurendil
Copy link

Hello Blake,

after running maven with -U command repo updated and found LGoodDatePicker. I have to update project to meet 4.3.1 as it has different namespace. If I has any error I'll contact you.

Thank you for perfect instrument!!! It really helps a lot, because there is only few good datepickers. Previously I used Microba, but it is rather old.

The only request is availability to change icon on button next to date field.

@karlmortensen
Copy link

Oh. Oops. I just opened an issue... Shall I close it? Anyway, the point is I love this date/time picker. I need seconds in my time picker though. I know it seems like a bad use case, but we're trying to match a date EXACTLY. Even milliseconds would be helpful, but not required. I really do need seconds though. How do I enable that? Is there any built-in option?

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Apr 1, 2016

Hello karlmortensen,
Yes, This capability does exist, though I never added it to the demo program until now. Internally, the time picker uses the java.time.LocalTime class, which has a precision down to the nanosecond. To use a high precision in your time picker, you'd need to set a "display format" and "menu format" in your TimePickerSettings which shows a time with seconds or fractional seconds.

I've added three new examples to the demo application which show how to use seconds, milliseconds, or nanoseconds precision in the time picker. You can see the new examples in the executable demo, in the the release section under LGoodDatePicker 4.3.2.

Here's an example of how you would enable millisecond precision.

    // Create a time picker with millisecond precision. (Using an ISO 24 hour format).
    TimePickerSettings timeSettings = new TimePickerSettings();
    timeSettings.setFormatForDisplayTime(PickerUtilities.createFormatterFromPatternString(
            "HH:mm:ss.SSS", timeSettings.getLocale()));
    timeSettings.setFormatForMenuTimes(PickerUtilities.createFormatterFromPatternString(
            "HH:mm", timeSettings.getLocale()));
    timePicker = new TimePicker(timeSettings);

To do the same thing with a DateTimePicker, you would create your time settings the same way, but you would pass the settings to the DateTimePicker constructor instead of a TimePicker constructor. If you need to create a custom or different time format, a description of all the available "pattern string" codes can be found in the javadocs for the DateTimeFormatter class.

Thank you for the compliments of this project. If you like, please add a "star" for the project on the top of the project page, to increase the project ratings. If you wish to be notified of any new releases, then you may also want to "watch" the project on the same page.

warm regards,
Blake

@karlmortensen
Copy link

Works perfectly. Thank you so much. You created the release of the example the same day I asked. That is awesome!

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Apr 1, 2016

karlmortensen, You're welcome!
~Blake

@gregkotsaftis
Copy link

I just came across your component and I have to say it really nails it! I have been using JCalendar for years and struggled with bugs, LocalDate support is a must! Thanks for that. There is however a requirement for multiple calendars inside a panel e.g. 2, 4 etc that behave as one for the external application caller. Think something like MS Outlook, which can have multiple calendars and pressing < or > changes all the shown calendars respectively. I am thinking I could use a panel to create a custom component for my needs, but you seem much more skilled and determined for the task... :)
Let me know your thoughts on this...

see these screens (in Greek, sorry!)
untitled-1
untitled-2

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Apr 10, 2016

*** Reply deleted because it is now out of date. See the post below for information about using multiple calendars in a single panel. (updated 25apr16) ***

@BlakeTNC
Copy link
Contributor Author

Hello gregkotsaftis,
With the release of LGoodDatePicker 5.2.2, the CalendarPanel component has been added to the library. This component allows the programmer to use the calendar panel controls independently from the DatePicker component. An example of using the independent calendar has also been added to the demo application and screenshots.

With this component, it would be possible for the programmer to show multiple calendars on a single panel (in a single interface), similar to the example you described above.
warm regards,
Blake

@Git-GT
Copy link

Git-GT commented Apr 30, 2016

Hi Blake,
first of all thank you for this component.
It seems very useful and I would like to use it in my next application.
This is is the very first time that I use it so sorry if my question is silly.
I would like to change the format of the JTextField that contains the date so that a date will be displayed as for example "30/05/2016" instead of "30 may 2016".
How can I do this? Is there a method that returns the JTextField component so that I can apply to it a custom formatter?
Thanks again, have a nice day.

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Apr 30, 2016

Hello Gittino,

You can apply custom formatters to your date picker in the DatePickerSettings class, (there is no need to retrieve the text field to change this setting). Here is the applicable example, as copied from FullDemo.java (the demo program):

    // Create a date picker: Custom Date Format.
    // When creating a date pattern string for BCE dates, use "u" instead of "y" for the year.
    // For more details about that, see: DatePickerSettings.setFormatForDatesBeforeCommonEra().
    // The various codes for the date pattern string are described at this link:
    // https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
    dateSettings = new DatePickerSettings();
    dateSettings.setFormatForDatesCommonEra("d MMM yyyy");
    dateSettings.setFormatForDatesBeforeCommonEra("d MMM uuuu");
    dateSettings.setInitialDateToToday();
    datePicker = new DatePicker(dateSettings);

To use other formatters besides the example in the demo, you'd replace the format strings with your own desired format. The codes for creating format strings are shown in the DateTimeFormatter javadocs.

I believe that the format strings for this format ("30/05/2016") would look like this:
"dd/MM/yyyy" for AD dates, and "dd/MM/uuuu" for BC dates.

Thank you for the compliments on the library, and have a great day.

Warm regards,
Blake

@Git-GT
Copy link

Git-GT commented Apr 30, 2016

Perfect, thanks a lot!
Have a great day you too! :)

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented May 2, 2016

** A section of this conversation has been moved to Issue 13. The moved conversation relates to adjusting the vertical and horizontal size of the DatePicker text field, as needed. Thank you. -Blake **

@gregkotsaftis
Copy link

Hello Blake and thank you very much!
The independent CalendarPanel component was a must!
But, will it be possible (when displaying 2 calendars) to select one date in one calendar only? (the other calendar panel should have null date while showing next month)?
In any case I guess I will have to override CalendarPanel, is this correct?

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented May 3, 2016

Hello gregkotsaftis,

From your description, is not clear to me what features of the calendar panel you would need or want. Your describe usage would probably be considered "advanced", since you would be basically using the calendar panel to create your own new multi-calendar component. Because of the complexity, I doubt that we could answer all significant questions before you started writing any code. I imagine you would need to start exploring the current source code and creating your new interface in order to pinpoint and define your specific needs. If you want your project to be visible to other developers, including me, you could consider keeping your source in a github repository.

I would not suggest overriding the class as a general solution for modifying the class behavior. If it turns out that there are features that you need that are not currently present (which is probably likely), then I would suggest incorporating those features into the LGoodDatePicker library. This could be accomplished by forking the repository and writing your own feature additions (and submitting pull requests for incorporating your changes), or by creating feature requests, which other developers could implement. Since this is an open source library, you're able to modify the code as desired.

To try to answer your questions, each calendar does have a concept of a selected date, but you are free to use or ignore that date as desired. The calendar does not currently have the ability to "ignore user input" (to become "read only") but that is a possible feature request or code addition that you could implement, if desired. And you are able to programmatically change the displayed month for "linked calendars", by calling setDisplayedYearMonth().

Warm regards,
Blake

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented May 3, 2016

Hello All,
LGoodDatePicker 5.3.1 has been released. With this release, the default minimum width for the date picker text field is now calculated dynamically. The default width is designed to match the "largest date" that can be displayed using the current DatePickerSettings. The settings used for calculating the default minimum width are the DatePicker locale, the date format (for CE dates), and the font for valid dates. The default width is set at construction, and updated any time that the specified DatePickerSettings are modified.

If desired, the default minimum width may also be overridden by the programmer, using DatePickerSettings.setSizeTextFieldMinimumWidth().

This release implements Feature Request #13, and should also fix the width related portion of the size problem described by @gittino. (The details of that conversation were moved to feature request #13).

Warm regards,
Blake

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented May 6, 2016

Hello All, Over the last two days, two major enhancements to the library were added to the Release Section. Here are the highlights:

  • Custom image icons can now be added to the DatePicker and the TimePicker (This completes the feature request made by @Taurendil.) Examples are in the demo.
  • The internal swing components for both pickers now have public accessors. This allows programmers to perform greater visual or behavioral customizations on the pickers, as desired.
  • The library now has parallel Backport Releases so that it can be used in projects which are built for the older Java versions, Java 6 and Java 7.

warm regards,
Blake

@Taurendil
Copy link

Hello Blake,

thank you for support of customs icons. You know, I found one problem. Could you explain it.
In recent release there is no possibilities to share datePickerSettings for several Pickers. But I found no clone method for DatePickerSettings. So if I want to make any kind of default settings for DatePickerSettings I have to extend the class. Previously I used one static variable as default settings to share among different Pickers.

@BlakeTNC
Copy link
Contributor Author

Hi @Taurendil,
I just looked through the DatePickerSettings class, and I don't see any obvious obstacles to implementing clone(). Even though the programming is simple enough, it would be relatively labor-intensive because there are so many variables in this class, and many of them are not primitive data types. I added a feature request for implementing clone, as issue #21.

An interim solution for your program would be to create and initialize your DatePickerSettings instances inside a loop. That way you can pump out as many duplicate customized instances as you would like. You can also create your DatePickers inside the same loop, if desired. If needed for storage and management, the multiple instances of the settings or the pickers could be added to an array list with each loop iteration.

warm regards,
Blake

@Taurendil
Copy link

Taurendil commented May 28, 2016

Hi @BlakeTNC,
you are right, there are a lot of solutions, I can use static method to generate defaults, I can use composition instead of inheritance and many other methods. All of them are good. But for security reasons Joshua Bloch and others always recommend to use clone inside library so after class initialization you can't infuence on it from outside class. Like

class A {
   private B intB;

   public A (B extB) {
      intB = extB==null ? null : extB.clone();
   } 
}

So intB and extB are different object and outside code has no effects on intB anymore.

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented May 28, 2016

Hi @Taurendil,
This feature is now implemented, as of LGoodDatePicker 7.3.3.

Note: The new function is not named DatePickerSettings.clone(), it is named DatePickerSettings.copySettings(). This is because the new function needs to work slightly differently from the general contract for Object.clone(). For additional information, see the Javadoc for DatePickerSettings.copySettings().

warm regards,
Blake

@TikiHardBop
Copy link

Thanks for that help! Great product!

@DanielSilva95
Copy link

That's a great tool, thank you and good job!
I was wondering, is there a way to use the calendar panel to select dates but only choosing between months and years? It'd be a panel where on top you have the year (As it is by default), the buttons, all default, but instead of days you'd have the months to pick?
Something like in the image below (This is a example image retrieved from Webix a javascript UI framework):

So then the user could select the month from the panel and maybe have spinner buttons to increase/decrease the months directly to the TextField (With a pattern like "MM/uuuu") or have the months in the panel switch between the month name or its number representation?

@ArchieBlack
Copy link
Contributor

Would it be possible to do another release version, and update the maven repositories? Thanks for maintaining this great tool!

@WiseEagleOwl
Copy link
Collaborator

@ArchieBlack
I am supporting @BlakeTNC in order to maintain this project and I have just released LGoodDatePicker v11.0.0 (some repositories will need time to mirror the new version). It would be great if you could test the new release and create issues if you encounter any problems.

The Maven Central Repository upgrade process had to be done manually up until now. I have setup some CI scripts that do this automatically from now on. As a result a new bugfix release can be created very easily.

@ArchieBlack
Copy link
Contributor

ArchieBlack commented Aug 10, 2020

Thanks. I'll let you know once I can pull the update.

@wtfoong
Copy link

wtfoong commented Aug 21, 2020

could i ask what should i do so that i could use this code....?

// Create a date picker: With date range limits.
// Notes:
// * If you only want to limit one side of the date range, you can optionally pass in null
// for one of the date limits.
// * Date range limits (and other types of veto policies) can only be set after constructing
// the date picker.
dateSettings = new DatePickerSettings();
datePicker = new DatePicker(dateSettings);
LocalDate today = LocalDate.now();
dateSettings.setDateRangeLimits(today.minusDays(20), today.plusDays(20));
panel.panel1.add(datePicker, getConstraints(1, (row * rowMultiplier), 1));
panel.addLabel(panel.panel1, 1, (row++ * rowMultiplier),
"Date 5, Limit date range (+/- 20 days):");

@jcadam14
Copy link

Hello, just downloaded this to try out in an app at work. Was curious if there is a way to set the text fields to be set the overwrite mode as true? We used to use javax.swing.text.DateFormatter and really like the overwrite behavior versus having to delete existing text.

Thanks!

@WiseEagleOwl
Copy link
Collaborator

@jcadam14 I'm not sure how the overwrite mode you are describing works in detail. One thing you can try is to customize your DatePicker instance by accessing the JTextField of the DatePicker via getComponentDateTextField() and adding a custom FocusListener that calls the selectAll() method of the TextField. Then every time you focus the DatePicker all contents are selected and will be overwritten if any keyboard input occurs.

@FrostyGelato
Copy link

FrostyGelato commented Oct 20, 2020

@BlakeTNC Hello, how do I set the font size of the time picker component of datetimepicker? I figured out how to set the font size of the date picker by looking at the code for the demo, but I couldn't figure it out for the time picker.

This is my code:

DatePickerSettings dateSettings = new DatePickerSettings();
TimePickerSettings timeSettings = new TimePickerSettings();
        
dateSettings.setAllowEmptyDates(false);
timeSettings.setAllowEmptyTimes(false);
        
dateSettings.setFontValidDate(new Font("Tahoma", Font.PLAIN, 16));
        
DateTimePicker deadlinePicker = new DateTimePicker(dateSettings, timeSettings);
deadlinePicker.getTimePicker().getComponentTimeTextField().setFont(standardFont);

The method .setFont isn't valid for timeSettings. I would appreciate any help.

@FiruzzZ
Copy link

FiruzzZ commented Oct 25, 2020

Hi, we started to use this lib a few weeks ago as a replacement of JCalendar (starting to move on from Date to Localdate/time, and moving projects to java 11) and we (my team) couldn't help to wonder why are you requesting ArrayList, do you really need this specific implementation of List in your API? obviously ArrayList is the most used but never is asked as parameter
Like when we try to set
.setFormatsForParsing( ..)
we can't simple use
Arrays.asList( DateTimeFormatter.ofPattern("dd/MM/yyyy"), DateTimeFormatter.ofPattern("dd.MM.yyyy"))
we have to cast it .setFormatsForParsing((ArrayList) Array.asList(...

@WiseEagleOwl
Copy link
Collaborator

Hi @FiruzzZ,
there is no deeper reason behind our setFormatsForParsing-API. It simply mirrors the way we represent the data internally.

If you have a better API in mind that would suit your purposes better you are very welcome to propose it via a pull request.
If you do so please make sure your changes are backwards compatible and provide small tests showing the new capabilities of the API and its backwards compatibility.

@FiruzzZ
Copy link

FiruzzZ commented Feb 19, 2021

Hi @FiruzzZ,
there is no deeper reason behind our setFormatsForParsing-API. It simply mirrors the way we represent the data internally.

That exactly my point, there no reason to ask (as parameter or return) for ArrayList when you just need a List
Like I pointed before, the API doesn't need an ArrayList, it doesn't make use of specific methods of that implementation of List
.setFormatsForParsing(new ArrayList<>(Arrays.asList(...)));
it could simply be
.setFormatsForParsing(Arrays.asList(...)); having a signature like setFormatsForParsing(List<DateTimeFormatter>)
likewise
public ArrayList<DateTimeFormatter> getFormatsForParsing()

If you have a better API in mind that would suit your purposes better you are very welcome to propose it via a pull request.
If you do so please make sure your changes are backwards compatible and provide small tests showing the new capabilities of the API and its backwards compatibility.

I would like to but sadly there is no way to guaranty backward compatibility because to make the API more flexible ("programming to an interface") the declaration of private ArrayList<DateTimeFormatter> formatsForParsing; must be changed, so the getter/setter and the getter could/will break if someone defined a code like ArrayList formats = DatePickerSettings.getFormatsForParsing() instead of just make List formats =

@WiseEagleOwl
Copy link
Collaborator

@FiruzzZ thank you for your detailed explanation. You are right, the change of the setter to setFormatsForParsing(List<DateTimeFormatter>) would be compatible but the consequential change of the getter to List<DateTimeFormatter> getFormatsForParsing() would be incompatible.

Nevertheless you could still prepare a PR with theses API changes, since this incompatibility of the getter is not very severe in my eyes. The only downside is that we can only ship this with the next major version v12.0.0. Which means you will have to wait a bit for your PR to be merged, same as PR#108

@immobilia
Copy link

Hi, I probably missed the right method, but i didn't find the way to show days theres outside the current month.

Require :
image

Actual :
image

Is there a way to fill red zone with day number?

@TedLarkenso
Copy link

Hi I’m Ted Larkenso
I am using JavaFX with Intellij to build an app. I’ve tried several date pickers with little success. I read that LGgoodDatePicker maybe what I require:

  1. To keep a calendar open so that users can pick and unpick multiple dates.
  2. Exclude ranges of dates and highlight the excluded dates, e.g. users cannot select dates before March 15 and after September 12, and the void dates shown in a color say red.
  3. Highlight selected dates in color, say blue for one type and green for another, determined by a field set by a radio button outside the date picker.
    Can anyone help please?

@salehrezq
Copy link

For two hours I am looking for any helpful section to guide me how to use LGoodDatePicker within my Java swing code, but couldn't find any hint!

How to use LGoodDatePicker?

From assets (https://github.com/LGoodDatePicker/LGoodDatePicker/releases), Which file should I download to include to my project that I can use it within my code.

Where is the usage section?

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented May 15, 2021

@salehrezq

Which file should I download to include to my project that I can use it within my code.

To include the datepicker library in your project, you would need to download "LGoodDatePicker-11.2.1.jar" (or the latest version). Alternatively, you could include the library as a maven dependency if you have a maven project.
How to include java libraries in your project is typically very similar for all java projects and libraries.

These links explain the process under various IDEs.
https://stackoverflow.com/questions/825521/how-do-you-use-a-java-library
https://stackoverflow.com/questions/4879903/how-to-add-a-jar-in-netbeans
https://stackoverflow.com/questions/396245/add-a-dependency-in-maven
https://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse

Where is the usage section?

Usage demos and examples are located here:
https://github.com/LGoodDatePicker/LGoodDatePicker/tree/master/Project/src/main/java/com/github/lgooddatepicker/demo

@BlakeTNC
Copy link
Contributor Author

@immobilia

Is there a way to fill red zone with day number?

I believe you can set the default display month, so that a different month than "today" will be shown when the datepicker is opened or clicked. Besides setting the default month, I don't believe the datepicker currently has a way to show the days "outside the edge" of the currently displayed month.

That could still be possible with extra work. This is an open source library, so a developer could optionally add the described capability, and submit it to the project as a pull request.

@CMFerrer
Copy link

hello
Is there any way to modify the "datepicker textfield" border? I want it not to appear or just put a bottom border. I tried with DatePicker.getComponentDateTextField().setBorder(myBorder); but it didn't work. The solution I found is to remove the visibility of the datepicker textfield with DatePickerSettings.setVisibleDateTextField(false); and add a JTextField over the datepicker and set it to listen with

DatePicker.addDateChangeListener(new DateChangeListener() {
            @Override
            public void dateChanged(DateChangeEvent dce) {
                
                JTextField.setText(DatePicker.getText());
            }
        });

In advance, thank you very much for your answers.

Translated with www.DeepL.com/Translator (free version)
border

@panappl3
Copy link

Hello Blake,
thank you for your awesome tool! I had a lot of fun learning about and implementing the calendar into my project. Unfortunately I have a few minor issues. I was hoping you could help me out with them.

I want to use the Datepicker inside my Jtable. Everything works fine except two things:

  1. Keyboard editing is still enabled although I explicitly disabled it.
  2. When selecting a date the default date format is displayed until the cell is not selected anymore. Then my custom date format is applied. I want to have my custom format to be applied all the time.

This is how I add the Datepicker inside my custom JTable class:

private void addDatePicker() {
DateTableEditor d = new DateTableEditor();
DatePickerSettings s = new DatePickerSettings();
s.setAllowKeyboardEditing(false);
s.setFormatForDatesCommonEra("EEEE, dd. LLL. yy");
d.getDatePicker().setSettings(s);
d.getDatePicker().setDateToToday();
this.setDefaultRenderer(LocalDate.class, d);
this.setDefaultEditor(LocalDate.class, new DateTableEditor());
TableColumn column = this.getColumnModel().getColumn(0);
column.setCellEditor(this.getDefaultEditor(LocalDate.class));
column.setCellRenderer(this.getDefaultRenderer(LocalDate.class));
}

Thank you in advance!

@panappl3
Copy link

I fixed it myself:

For the tables Default Editor I gave a new DateTableEditor object as parameter without my settings.
But when I used my DateTableEditor object with my custom settings for the DefaultRenderer and the DefaultEditor it gave me some weird visual issues.

My solution is to declare two DateTableEditor objects, with the same settings (but different settings objects) for the DefaultEditor and the DefaultRenderer. This might be redundant and unnecessary but I can't seem to find a better solution. This is my new code:

private void addDatePicker() {
DateTableEditor dR = new DateTableEditor();
DateTableEditor dE = new DateTableEditor();

DatePickerSettings sR = new DatePickerSettings();
DatePickerSettings sE = new DatePickerSettings();
sR.setAllowKeyboardEditing(false);
sR.setFormatForDatesCommonEra("EEEE, dd. LLL. yy");
sE.setAllowKeyboardEditing(false);
sE.setFormatForDatesCommonEra("EEEE, dd. LLL. yy");
dR.getDatePicker().setSettings(sR);
dR.getDatePicker().setDateToToday();
dE.getDatePicker().setSettings(sE);
dE.getDatePicker().setDateToToday();

this.setDefaultRenderer(LocalDate.class, dR);
this.setDefaultEditor(LocalDate.class, dE);

TableColumn column = this.getColumnModel().getColumn(0);
column.setCellEditor(this.getDefaultEditor(LocalDate.class));
column.setCellRenderer(this.getDefaultRenderer(LocalDate.class));

}

Any tips are still much appreciated!

john-dc252 added a commit to jn0102-stmpc-report-util/LGoodDatePicker that referenced this issue Dec 27, 2021
BlakeTNC pushed a commit that referenced this issue Dec 28, 2021
@BlakeTNC
Copy link
Contributor Author

@CMFerrer Modifying the textfield border color has now been implemented in the master branch. Thanks to @john-dc252.
(Pull request #146.) This change does not implement changing the border itself, but does allow modifying the border color. Changing or removing the border object would require creating a separate issue or pull request.

@Coelho42
Copy link

Coelho42 commented Jan 9, 2022

How can I set the language?

@BlakeTNC
Copy link
Contributor Author

BlakeTNC commented Jan 9, 2022

@Coelho42
The language is determined by the locale. The locale is set automatically using the java environment during the construction of the DatePickerSettings class. The locale can also be set manually. This can be done with the DatePickerSettings constructor (recommended), or by using DatePickerSettings.setLocale(). Below are some code clips from the DatePickerSettings class, with relevant javadocs.

  /**
   * Constructor with Default Locale, This constructs a date picker settings instance using the
   * system default locale and language. The constructor populates all the settings with default
   * values.
   */
  public DatePickerSettings() {
  /**
   * Constructor with Custom Locale, This constructs a date picker settings instance using the
   * supplied locale and language. The constructor populates all the settings with default values.
   */
  public DatePickerSettings(Locale pickerLocale) {
  /**
   * setLocale, This will set the locale for this DatePickerSettings instance, and will set all
   * other settings that depend on the locale to their default values.
   *
   * <p>Warning: Every setting whose default value depends on the locale, will be overwritten
   * whenever this function is called.
   *
   * <p>This is a list of all the settings which are overwritten by this function: locale,
   * translationArrayStandaloneLongMonthNames, translationArrayStandaloneShortMonthNames,
   * translationToday, translationClear, formatForTodayButton, formatForDatesCommonEra,
   * formatForDatesBeforeCommonEra, formatsForParsing, firstDayOfWeek, weekNumberRules.
   *
   * <p>For most applications, it is generally recommended to only set the locale from the
   * DatePickerSettings constructor. If you use setLocale() to change the locale after construction,
   * then you will overwrite any previously customized locale-specific settings.
   *
   * <p>Passing in "null" will apply the default locale for the current Java Virtual Machine.
   */
  public void setLocale(Locale locale) {

@NomadicDeveloper22
Copy link

It might be a good idea to enable the actual discussion section through repository settings

@BlakeTNC
Copy link
Contributor Author

It might be a good idea to enable the actual discussion section through repository settings

@TheRedSpy15 Done, thank you for mentioning it.

@sizoune
Copy link

sizoune commented May 20, 2023

hii, any references about how to use this lib in compose multiplatform ? especially for desktop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests