47199

How to set date picker initial value?

Question:

I have a date_picker from toedter.com from jcalendar package which are swing components. How can I set an initial value to it? I'm using netbeans.

I added the date_picker on design view and tried this on my source code :

UtilDateModel model = new UtilDateModel(); model.setDate(2014, 8, 24); model.setSelected(true);

but I've been playing around where to put it still doesn't seem to work.

Any idea guys?

Answer1:

You can try this out :

String dateValue = "initial date value"; // must be in (yyyy- mm- dd ) format Date date = new SimpleDateFormat("yyyy-mm-dd").parse(dateValue); jDateChooser.setDate(date);

Answer2:

This should solve it:

UtilDateModel model = new UtilDateModel(); model.setDate( 2014, 8, 24 ); startDatePicker = new JDatePickerImpl( new JDatePanelImpl( model ), new DateLabelFormatter() );

Recommend

  • oracle add_months function differs from Java
  • UICollectionView Enable deselecting cells while allowsMultipleSelection is disabled
  • Highlight ListView item at creation time via code
  • Set the date to raddatepicker by using Javascript
  • Firebase Save Notification to DB not working when app is not running
  • how can I compare dates in array to find the earliest one?
  • ckeditor and jquery UI dialog not working
  • Vuejs: Lifecycle hooks of child routerview components using keep alive
  • What causes the runtime difference in this trivial fortran code?
  • Retrieve IP address of device
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • Can I programmatically choose the Android layout folder?
  • Implicit joins and Where in Doctrine - how?
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • Adding elements to a huge XML file
  • How to define and use opencv mat of user type
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Counter field in MS Access, how to generate?
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Controls, properties, events and timers running in design time
  • Cassandra Data Model
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Javascript + PHP Encryption with pidCrypt
  • Websockets service method fails during R startup
  • Cannot Parse HTML Data Using Android / JSOUP
  • Acquiring multiple attributes from .xml file in c#
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Getting Messege Twice Using IMvxMessenger
  • How to stop GridView from loading again when I press back button?
  • How can I remove ASP.NET Designer.cs files?
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal
  • How to load view controller without button in storyboard?