Results 1 to 4 of 4
  1. #1
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default combo box date question

    I have 3 combo boxes: the first for days (Integer 1-31), the second for month(String jan-dec) and the third for year(integer 1970-2012).

    I was wondering how do I set the default date to today's date?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default Re: combo box date question

    Create a GregoreanCalendar with the no-args constructor; grab the day/month/year from it and set your combo boxes given these values.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: combo box date question

    Quote Originally Posted by JosAH View Post
    Create a GregoreanCalendar with the no-args constructor; grab the day/month/year from it and set your combo boxes given these values.

    kind regards,

    Jos

    Thanks for this.

    Sorry to post in the same thread but I have one more question.

    if i have :

    int x = 6;

    if( x < 10){

    String s = "0" +x;
    }

    System.out.print(s);


    it gives an error with 'create local variable x' could you explain this to me please?

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default Re: combo box date question

    Your String variable s is declared in the body of the if-statement and doesn't exist outside of that block; declare it before you start your if-statement.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. combo box comparison question
    By stuckonjava in forum New To Java
    Replies: 1
    Last Post: 03-16-2012, 07:43 PM
  2. Question on ActionListener in combo box
    By Levian in forum AWT / Swing
    Replies: 7
    Last Post: 07-05-2011, 09:28 AM
  3. Replies: 0
    Last Post: 04-27-2011, 10:34 AM
  4. dynamically populate the city combo box based on the values of state combo +ajax+jsp
    By sandy1000 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-29-2010, 10:00 AM
  5. creation of one combo box form another combo box
    By er.tyagigaurav in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-09-2008, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •