Results 1 to 2 of 2
  1. #1
    Compexec is offline Member
    Join Date
    Sep 2013
    Rep Power

    Default Plotting a Point

    Hi, I'm very very very new to Java, taking my first course right now. We were tasked with creating a few different things, the first of which was plotting an X, Y value into some kind of display. So far I decided to try a JFrame route but given that I've never worked with JFrames (or Java in general) I've hit a road block. Right now my code will ask for the 2 values, (X and Y) and then puts them neatly in a print out. Then it opens the JFrame, from here I am not sure how to go about pulling the point from the code and putting it on the JFrame. Any help would be greatly appreciated, again, first week ever using Java so speak slowly and maybe use pictures...

    /**First attempt at creating a program the plots a Vertex**/
    import java.util.Scanner;
    import javax.swing.JFrame;
    import javax.swing.WindowConstants;

    public class JW_Vertex {
    int xvalue=0;
    int yvalue=0;

    //object builder
    public JW_Vertex(int x, int y) {

    public void display(){
    System.out.print(", ");
    public static void main(String[] args) {

    System.out.print("Please enter your X and Y value seperated by a space:");
    Scanner kb = new Scanner(;
    int x = kb.nextInt();
    int y = kb.nextInt();
    JW_Vertex v = new JW_Vertex(x,y);

    JFrame myFrame = new JFrame ("This is your point plotted");
    myFrame.setDefaultCloseOperation(WindowConstants.E XIT_ON_CLOSE);


  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Plotting a Point

    A JFrame is simply that: a frame. What you need is to add a panel to the frame and then you can draw on that panel.

Similar Threads

  1. Plotting a function
    By Cruel Hand in forum AWT / Swing
    Replies: 1
    Last Post: 06-08-2012, 04:33 PM
  2. Help regarding 3D graph plotting...
    By Megatron in forum New To Java
    Replies: 1
    Last Post: 05-21-2009, 04:26 PM
  3. Help! Plotting a function
    By cvubando in forum New To Java
    Replies: 14
    Last Post: 02-20-2009, 07:34 AM
  4. graph plotting
    By sirine in forum New To Java
    Replies: 5
    Last Post: 01-25-2009, 03:34 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