I have 2 JDateChooser controls and 7 JCheckBox
controls. The date choosers will set a range between two dates, and the 7 checkboxes will filter the dates.
The 7 checkboxes are: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
For example:
The output will be all Mondays and Tuesdays in the dates range Oct 01, 2021 - Oct 08, 2021.
I searched everywhere but no answer and I don't even know where to begin.
Obviously schoolwork, so I'll be brief, enough to point you in the right direction while letting you actually do your own assignent yourself.
Seems obvious that you would use checkbox widgets for the days of the week, not combobox.
Use LocalDate
class for the date. Use the plusDays
method to move from one date to another. Test each using getDayOfWeek
to match against DayOfWeek
objects. Use EnumSet
and its contains
method for that check.
Use an ArrayList< LocalDate >
to collect the dates you want to remember.
In advanced Java we might do something like this untested code.
List< LocalDate > dates =
LocalDate.of( 2021 , 10 , 1 )
.datesUntil( LocalDate.of( 2021 , 10 , 8 ) )
.filter(
localDate -> EnumSet.of( DayOfWeek.TUESDAY , DayOfWeek.THURSDAY ).contains( localDate.getDayOfWeek() )
)
.toList()
;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.