I have problem incrementing this by one per click.
class window extends JPanel implements MouseListener{
int a=0;
public void paint(Graphics g){
super.paint();
g.drawLine(5, 5, 200, 200); // TEST draw
}
@Override
public void mousePressed(MouseEvent e) {
a++; // increment by one
System.out.println(a);// print out
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
}
class drawSpline_frame extends JFrame {
public drawSpline_frame(){
setSize(500,500);
setTitle("Spline");
Container cp = this.getContentPane(); // EDITED
cp.add(window, BorderLayout.CENTER );
window.addMouseListener(window);
}
}
class drawSpline{
public static void main(String[] args) {
JFrame frame = new drawSpline_frame();
frame.setVisible(true);
}
}