0% found this document useful (0 votes)
78 views

Practica 11

The document defines a Java class called Practica11 that creates a window frame for drawing graphics. It imports graphics and swing library classes. The main method creates an instance of Practica11 and makes it visible. The paint method draws concentric colored circles, outlines, and numbers 1-10 on the frame using graphics methods like fillOval, drawString, and setting the color.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Practica 11

The document defines a Java class called Practica11 that creates a window frame for drawing graphics. It imports graphics and swing library classes. The main method creates an instance of Practica11 and makes it visible. The paint method draws concentric colored circles, outlines, and numbers 1-10 on the frame using graphics methods like fillOval, drawString, and setting the color.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

package com.mycompany.

practica11;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import javax.swing.*;
import javax.swing.border.EmptyBorder;

/**
*
* @author Sergio
*/
public class Practica11 extends JFrame {

private JPanel contentPane;

public Practica11() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
setBounds(0, 0, 800, 600);
}

public static void main(String[] args) {


EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Practica11 frame = new Practica11();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

public void paint(Graphics g) {


super.paint(g);

/*
g.setColor(Color.blue);
g.drawLine(0, 70, 100, 70);
g.drawRect(150, 70, 50, 70);
g.drawRoundRect(250, 70, 50, 70, 6, 6);
g.drawOval(350, 70, 50, 70);
int[] vx1 = {500, 550, 450};
int[] vy1 = {70, 120, 120};
g.drawPolygon(vx1, vy1, 3);

g.setColor(Color.red);
g.fillRect(150, 270, 50, 70);
g.fillRoundRect(250, 270, 50, 70, 6, 6);
g.fillOval(350, 270, 50, 70);
int[] vx2 = {500, 550, 450};
int[] vy2 = {270, 320, 320};
g.fillPolygon(vx2, vy2, 3); */

//Fondo
g.setColor(Color.magenta);
g.fillRect(0, 0, 10000, 10000);

//Circulo exterior BLANCO


g.setColor(Color.white);
g.fillOval(50, 50, 1000, 1000);

//Segundo circulo NEGRO


g.setColor(Color.black);
g.fillOval(150, 150, 800, 800);

//Tercer circulo AZUL


g.setColor(Color.blue);
g.fillOval(250, 250, 600, 600);

//ROJO
g.setColor(Color.red);
g.fillOval(320, 320, 450, 450);

//AMARILLO
g.setColor(Color.yellow);
g.fillOval(415, 415, 270, 270);

//Linea blanco
g.setColor(Color.black);
g.drawOval(100, 100, 900, 900);

//Linea negra
g.setColor(Color.white);
g.drawOval(200, 200, 700, 700);

//Linea azul
g.setColor(Color.white);
g.drawOval(285, 285, 530, 530);

//Linea roja
g.setColor(Color.white);
g.drawOval(365, 365, 365, 365);

//Linea amarilla
g.setColor(Color.black);
g.drawOval(465, 465, 175, 175);

//Numero 10
g.setColor(Color.black);
g.drawString("10", 620, 560);
//Numero 9
g.setColor(Color.black);
g.drawString("9", 665, 560);
//Numero 8
g.setColor(Color.black);
g.drawString("8", 710, 560);
//Numero 7
g.setColor(Color.black);
g.drawString("7", 750, 560);
//Numero 6
g.setColor(Color.white);
g.drawString("6", 800, 560);
//Numero 5
g.setColor(Color.white);
g.drawString("5", 835, 560);
//Numero 4
g.setColor(Color.white);
g.drawString("4", 880, 560);
//Numero 3
g.setColor(Color.white);
g.drawString("3", 930, 560);
//Numero 2
g.setColor(Color.black);
g.drawString("2", 980, 560);
//Numero 1
g.setColor(Color.black);
g.drawString("1", 1040, 560);
}

You might also like