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: Java Bar graph takes user input to create graph?

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Bar graph takes user input to create graph?

    I am trying to copy the elements of an array input by the user starting at position 2 into another array called value and using that input starting a position 2 to create a graph.
    public static void main(String[] args) {
    for (int i = 0; i < args.length; i++){
    //Grabs the first 2 elements of the users input
    int width = Integer.parseInt(args[0]);
    int height = Integer.parseInt(args[1]);
     
    //Controls the Height and Width of the frame
    JFrame frame = new JFrame();
    frame.setSize(height, width);
     
    double[] value = new double[6];
    String[] languages = new String[6];
     
    //Controls the
    value[0] = 50;
    languages[0] = "Visual Basic";
     
    value[1] = 2.5;
    languages[1] = "PHP";
     
    value[2] = 3;
    languages[2] = "C++";
     
    value[3] = 4;
    languages[3] = "C";
     
    value[4] = 5;
    languages[4] = "Java";
     
    value[5] = 6;
    languages[5] = "Java";
     
    frame.getContentPane().add(new SimpleBarChart(value, languages, "ProjectOne"));
     
    WindowListener winListener = new WindowAdapter() {
    public void windowClosing(WindowEvent event) {
    System.exit(0);
    }
    };
     
    frame.addWindowListener(winListener);
    frame.setVisible(true);
    }
    }
    }
    Last edited by KevinWorkman; March 31st, 2011 at 07:35 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: Java Bar graph takes user input to create graph?

    When posting code, make sure you use code or highlight tags. I added them for you this time, but please be more mindful in the future.

    What does your program do instead? Do you see an Exception? Some strange behavior? Something else?

    Why do you have that in a for loop for each argument?
    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. Completely lost, creating a bar graph
    By lairel in forum Object Oriented Programming
    Replies: 1
    Last Post: February 28th, 2011, 07:18 AM
  2. Help with Polynomial Graph Plotter and its scaling
    By sojharo in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 23rd, 2011, 06:04 PM
  3. Issue Building Graph in Adjacency Matrix
    By mike.s in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 22nd, 2010, 02:44 PM
  4. How to make a graph like this
    By sugarhigh in forum AWT / Java Swing
    Replies: 1
    Last Post: August 27th, 2010, 09:05 AM
  5. Replies: 1
    Last Post: October 7th, 2008, 07:35 AM