简体   繁体   中英

How to change jspinner date min and max values from (database) variables?

Basically this is the problem, I pull some data set from the database, and populate combobox with it.

So like you can see in this shoot http://prntscr.com/7bscob . Min and max jspinner values SHOULD depend on comboBox selected item .

So what I've tried to do is to set a minimal value dynamically, but it sends an IllegalArgumentException at the line where I did that.

for(int i=0; i<turniri.size(); i++)
            {
                if (turniri.get(i).getNaziv().equals(selectedTurnir)) 
                {
                    t=turniri.get(i).getId();
                    long l = turniri.get(i).getDatumPocetka().getTime();
                    spinner.setModel(new SpinnerDateModel(new Date(1431986400000L), new Date(l), new Date(1433109600000L), Calendar.DAY_OF_YEAR));
                }       
            }

Looks like the long l = turniri.get(i).getDatumPocetka().getTime() is somehow incorrect.

According to the error value in the SpinnerDateModel must be between min and max.

new SpinnerDateModel(new Date(1431986400000L), new Date(l), new Date(1433109600000L), Calendar.DAY_OF_YEAR)

So your value is 1431986400000L

Min is l

and max is 1433109600000L

CHeck the numbers and adapt accordingly

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM