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 2 of 2

Thread: Help incorporating a Joption Pane

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help incorporating a Joption Pane

    Hello, I'm trying to get the final product of this single code to have the inputs/outputs displayed with a JOption Pane. I'm unfamiliar with how to write and incorporate a separate getData class and wondering if someone could show me?

    This class accepts values until a negative value is entered and then averages without said negative value

    import javax.swing.JOptionPane;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    public class TestWindReadings{
        public static void main(String[] args){
        int min;
        int max;
        int count=0;
        int sum=0;
        Scanner scan=new Scanner(System.in);
        System.out.print("Enter wind speed reading ");
        System.out.print("Enter wind speed: ");
        int cmd=scan.nextInt();
        max=cmd;
        min=cmd;
        sum+=cmd;
        count++;
        while(cmd>=0){
            if(cmd<min){
               min=cmd;
            }
            else if(cmd>max){
               max=cmd;
            }
            sum+=cmd;
            count++;
            System.out.print("Enter windspeed: ");
            cmd=scan.nextInt();
        }
        if(count>1){
            System.out.println("High: " +max);
            System.out.println("Low: " +min);
            System.out.println("Count: "+ (count-1));
            System.out.println("Avg : " +sum/count);
        }
    }
    }


  2. #2
    Member
    Join Date
    Mar 2012
    Location
    United States
    Posts
    118
    My Mood
    Inspired
    Thanks
    1
    Thanked 33 Times in 31 Posts

    Default Re: Help incorporating a Joption Pane

    Check this out, it has all the information you need:
    JOptionPane (Java Platform SE 6)

Similar Threads

  1. JOption Output Message
    By richW in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 15th, 2012, 11:17 PM
  2. What exactly is a content pane?
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 2
    Last Post: December 7th, 2011, 09:07 AM
  3. GUI Class repaint or redoing a pane
    By gillaw06 in forum AWT / Java Swing
    Replies: 0
    Last Post: October 26th, 2011, 09:54 PM
  4. [SOLVED] I have a problem with this Joption programme.
    By Leprechaun_hunter in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 12th, 2011, 03:31 AM
  5. JOption Pane help
    By dallas1125 in forum AWT / Java Swing
    Replies: 5
    Last Post: November 18th, 2009, 05:08 PM