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: new to forums help needed in paint program

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default new to forums help needed in paint program

    hello guys i am new to the forums and not able to rectify an error in a drawiing program that i made.
    here is the code
    import java.awt.Point;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionAdapter;
    import javax.swing.JPanel;
    public class PaintPanel extends JPanel
    {
    private int pointCount=0;
    private Point[] points=new Point[10000];
    public PaintPanel()
    {
    addMouseMotionListener (
    new MouseMotionAdapter()
    {
    public void mouseDragged( MouseEvent event)
    {
    if ( pointCount < points.length )
    {
    points[pointCount]=event.getPoint();
    pointCount++;
    repaint();
    }
    }
    }
    );
    }
    public void PaintComponent(Graphics g)
    {
    super.paintComponent(g);
    for(int i=0; i<pointCount;i++)
    g.fillOval(points[i].x,points[i].y,4,4 );
    }
    }



    and


    import java.awt.BorderLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class Painter
    {
    public static void main(String[]args)
    {
    JFrame application = new JFrame("Paint 1.0 by Saif");
    PaintPanel paintPanel = new PaintPanel();
    application.add(paintPanel, BorderLayout.CENTER);
    application.add(new JLabel("Drag da cursor to draw"),BorderLayout.SOUTH);
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    application.setSize(400,200);
    application.setVisible(true);
    }
    }
    here is the snapshot a drawing area should appear but only a window is appearing where i cant draw
    sorry "Norm"
    Capture.JPG
    Last edited by saifbaeg; May 27th, 2012 at 08:03 PM. Reason: explain error


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: new to forums help needed in paint program

    not able to rectify an error
    Please explain what the error is.
    If you are getting error messages, please copy and paste here the full text.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: new to forums help needed in paint program

    any please help...

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: new to forums help needed in paint program

    Your posted code does not have proper formatting making it hard to read.

    Try debugging the code by adding println statements to it to show program execution flow so you know what methods are being called and to show the values of variables as their values are changed and used.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Applet paint program frame work.
    By ShaunB in forum Java Swing Tutorials
    Replies: 4
    Last Post: October 31st, 2012, 08:44 AM
  2. Paint program adding classes to main method class
    By Maxfmc in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 15th, 2011, 07:01 PM
  3. Applet paint program frame work.
    By ShaunB in forum Java Code Snippets and Tutorials
    Replies: 3
    Last Post: May 5th, 2010, 06:35 PM
  4. HELP with Java Paint Program Code
    By CheekySpoon in forum AWT / Java Swing
    Replies: 1
    Last Post: April 5th, 2010, 12:03 PM
  5. Array program help needed
    By SCM in forum Loops & Control Statements
    Replies: 2
    Last Post: December 2nd, 2009, 11:28 PM

Tags for this Thread