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
here is the snapshot a drawing area should appear but only a window is appearing where i cant drawimport 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); } }
sorry "Norm"
Capture.JPG