All pastes #202529 Raw Edit

Untitled

public text v1 · immutable
#202529 ·published 2006-10-14 15:57 UTC
rendered paste body
import java.awt.*;



import javax.swing.*;



public class MyFrame extends JFrame {



    private int mouseX, mouseY;

    

    private boolean mouseclicked = false;

    

    

    

	public MyFrame() {

		

        Container c = getContentPane();

        c.setLayout(new FlowLayout());

        setSize(800, 600); setVisible(true);

        setDefaultCloseOperation(EXIT_ON_CLOSE);

	}



    private void drawCircle2(Graphics drawingArea, int Xcentre, int yCentre, int radius){

    	//x,y,w,h

    	drawingArea.drawOval(Xcentre-(radius/2),yCentre-(radius/2),radius,radius);

    }

    

    public boolean mouseDown(Event e, int x, int y ) {

    	mouseX=x; mouseY=y;

    	mouseclicked = true;

    	repaint();

    	return true;

    }

    	

    public void paint( Graphics g ) {

    	g.setColor(Color.blue);

    	Graphics paper = this.getGraphics();

    	if (mouseclicked) {

    		drawCircle2(paper, mouseX, mouseY, 100);

    	    mouseclicked = false;

    	}

    }    

}