Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: JOptionPane output assistance

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JOptionPane output assistance

    I am writting a program that asks a user what the year and month are. After the user inputs the information the results needs to be displayed into a global string using JOptionPane GUI. I have been able to succesfully create the dialog boxes for the year and month but ahve been unsucessful with the output of the calendar. what am I missing?

    [code] public class PrintCalendar {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    String EnterYear = JOptionPane.showInputDialog("Enter a year:");
    int year = Integer.parseInt(EnterYear);

    String EnterMonth = JOptionPane.showInputDialog("Enter month in number between 1 and 12:");
    int month = Integer.parseInt(EnterMonth);
    printMonth(year, month);
    }

    public static void printMonth(int year, int month) {
    printMonthTitle(year, month);
    printMonthBody(year, month);
    JOptionPane.showMessageDialog(null, month, + year, JOptionPane.PLAIN_MESSAGE);

    }


    public static void printMonthTitle(int year, int month) {
    System.out.println(" " + getMonthName(month)
    + " " + year);
    System.out.println("-----------------------------");
    System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
    }
    [code]
    Last edited by dtooth71; October 10th, 2012 at 10:42 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: JOptionPane output assistance

    When posting code, please use the highlight tags to preserve formatting. Otherwise your code is pretty hard to read.

    What exactly is the problem? What does the program do that you don't expect? What does it not do that you expect it to?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JOptionPane output assistance

    I will keep posting in mind moving forward, I was trying to see how to post.

    the problem is to have a user input year and month and produce the results in a GUI format, not text. currently, I have GUI (JOptionPane) inputs but my output is text - the output needs to be GUI also. I did not post the entire code, if needed I will.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: JOptionPane output assistance

    You can check out other posts here and use the quote feature to see how they wrap their code. It's pretty impossible to read unformatted code, so I would edit your post and do that if I were you.

    What line of code does your outputting? What have you done to try to turn it into a GUI?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] for loop assistance
    By Kseidel in forum Loops & Control Statements
    Replies: 3
    Last Post: September 17th, 2012, 08:10 PM
  2. Need some assistance please
    By JavaPhish in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 25th, 2012, 10:00 AM
  3. New to the complmunity, need some assistance please.
    By nakedtriple in forum What's Wrong With My Code?
    Replies: 12
    Last Post: October 7th, 2011, 06:14 AM
  4. NEED ASSISTANCE W/ JAVA PROGRAM
    By Neddrick in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 29th, 2010, 08:20 PM
  5. FileReader need assistance
    By tazjaime in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: November 8th, 2009, 01:12 AM

Tags for this Thread