Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Fubarable

Thread: I need help with JOption Panel!

  1. #1
    jakex69 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default I need help with JOption Panel!

    Write a program that reads a string for a date in the format month / day / year and displays it
    in the format day . month . year, which is a typical format used in Europe. For example, if the
    input is 06/17/08, the output should be 17.06.08. Your program should use JOptionPane for
    input and output.
    Note - Your program should create an output string from the input string and should include
    the following lines with appropriate Java statements at “…”

    __________________________________________________ ___

    import javax.swing.JOptionPane;
    public class DateDisplayer
    {
    public static void main(String[] args)
    {
    String dateString = JOptionPane.showInputDialog(
    "Enter a date in the format month/day/year .\n" +
    "I will output the date in the format
    day.month.year\n");
    String day, month, year;

    dateString = dateString.trim();
    int delimiter = dateString.indexOf("/");
    month = dateString.substring(…);

    //System.out.println("index is " + delimiter);
    //System.out.println("Month is " + month);

    String rest = dateString.substring(…).trim();
    //System.out.println("Rest is " + rest);

    delimiter = rest.indexOf("/");
    day = rest.substring(…);

    //System.out.println("index is " + delimiter);
    //System.out.println("day is " + day);

    year = rest.substring(…).trim();
    //System.out.println("year is " + year);

    JOptionPane.showMessageDialog(null, dateString +
    " converts to: " + day + "." + month + "." + year);
    System.exit(0);
    }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    jakex69 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: I need help with JOption Panel!

    Quote Originally Posted by Fubarable View Post
    So...

    what exactly is your question? Details are very important.
    I need help in filling the ... blanks

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: I need help with JOption Panel!

    Quote Originally Posted by jakex69 View Post
    I need help in filling the ... blanks
    It doesn't quite work that way here. You should try to solve it first and then if it still doesn't work, please show us what you've tried, any error messages you have received and any questions that you might have.
    DarrylBurke likes this.

Similar Threads

  1. Region and Language problem in Joption
    By rjain in forum New To Java
    Replies: 0
    Last Post: 11-04-2011, 11:19 AM
  2. Replies: 12
    Last Post: 10-22-2010, 07:52 AM
  3. Example of JOption
    By RanLineR in forum New To Java
    Replies: 4
    Last Post: 10-20-2010, 12:27 PM
  4. JOption pop up window is behind all other windows
    By biggmann in forum New To Java
    Replies: 3
    Last Post: 10-15-2010, 08:24 PM
  5. JOption Msgbox title help?
    By ZaabZ in forum New To Java
    Replies: 7
    Last Post: 08-26-2010, 09:12 PM

Tags for this Thread

Posting Permissions

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