All pastes #420830 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-02 12:54 UTC
rendered paste body
import java.awt.Graphics;



import javax.swing.JPanel;



public class Circulo extends JPanel {

	/**

	 *

	 */

	private static final long serialVersionUID = 6787599365941305525L;



	private int choice;



	public int x, y = 1;



	public Circulo(int userChoice, int x2, int y2) {

		choice = userChoice;

		x = x2;

		y = y2;

	}



	public void paintComponent(Graphics g) {

		super.paintComponent(g);



		switch (choice) {

		case 1:

			g.drawOval(10 + x * 10, 10 + y * 10, 50 + x * 10, 50 + y * 10);

			break;

		case 2: {

			int[] p = { 0, 0, getWidth(), getHeight() };

			int r = Math.min(getWidth(), getHeight()) / 10 / 2;

			

			for (int i = 1; i <= 10; i++) {

				g.drawOval(

						(p[2] / 2) - r * i,

						(p[3] / 2) - r * i,

						2 * r * i, 

						2 * r * i);

			}

			break;

		}

		}



	}

}