SlideShare una empresa de Scribd logo
1 de 12
Descargar para leer sin conexión
import java.awt.Button;
import java.awt.event.ItemListener;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Color;
import java.awt.Event;
import java.awt.Graphics;
import java.awt.Image;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class poke extends Applet{
Image imagen1,imagen2;
Button B1,B2,B3,B4;
String cad="";
Label CuerpoEtiq,OjosEtiq,BocaEtiq, rellenoEtiq;
Color Cuerpo=new Color(255,153,255);
Color Ojos=new Color(0,200,160);
Color boca=new Color(255,102,153);
CheckboxGroup Radio;
Checkbox a,b,c;
Checkbox relleno,relleno2;
Choice selector;
public void init()
{
imagen1 = getImage (getDocumentBase(),"imagen1.JPG");
imagen2 = getImage (getDocumentBase(),"imagen2.JPG");
CuerpoEtiq= new Label ("Color del cuerpo");
OjosEtiq= new Label ("Color del ojos");
BocaEtiq=new Label("Color de boca");
rellenoEtiq= new Label("Imagen");
B1 = new Button( " " );
B2 = new Button( " " );
B3 = new Button( " " );
B4 = new Button( " " );
this.add(CuerpoEtiq);
this.add( B1 );
this.add( B2 );
this.add( B3 );
this.add( B4 );
this.add(OjosEtiq);
selector = new Choice();
selector.addItem("Azul");
selector.addItem("Gris");
selector.addItem("Naranja");
selector.addItem("Original");
add(selector);
add(BocaEtiq);
Radio=new CheckboxGroup();
a=new Checkbox("Rojo", Radio,false);
b=new Checkbox("Amarillo", Radio,false);
c= new Checkbox("Negro", Radio,false);
add(a);
add(b);
add(c);
relleno= new Checkbox("Imagen1");
relleno2= new Checkbox("Imagen2");
add(rellenoEtiq);
add(relleno);
add(relleno2);
}
String valor;
public boolean action (Event evt, Object obj)
{
valor=selector.getSelectedItem().toString();
if(evt.target instanceof Choice)
{
if(valor=="Azul")
{
Ojos=Color.blue;
}
if(valor=="Gris")
{
Ojos= Color.gray;
}
if(valor=="Naranja")
{
Ojos=Color.orange;
}
if(valor=="Original")
{
Ojos=new Color(0,200,160);
}
}
if(evt.target.equals (B1))
{
Cuerpo=Color.yellow;
}
if(evt.target.equals (B2))
{
Cuerpo=Color.blue;
}
if(evt.target.equals (B3))
{
Cuerpo=Color.red;
}
if(evt.target.equals (B4))
{
Cuerpo=new Color(255,153,255);
}
if(evt.target instanceof Checkbox)
{
Checkbox radio=Radio.getSelectedCheckbox();
if(radio.equals(a) ) {
boca=Color.red;
}
if(radio.equals(b) ) {
boca=Color.yellow;
}
if(radio.equals(c) ) {
boca=Color.black;
}
}
if(evt.target instanceof Checkbox)
{
Checkbox radio=Radio.getSelectedCheckbox();
if(radio.equals(imagen1) ) {
boca=Color.red;
}
if(radio.equals(imagen2) ) {
boca=Color.yellow;
}
if(radio.equals(c) ) {
boca=Color.black;
}
}
repaint();
return true;
}//action
public void paint(Graphics g)
{
setSize(1100,600);
g.drawImage(imagen1, 10, 10, 150, 190, this);
g.drawImage(imagen2, 100, 100, 200, 300, this);
CuerpoEtiq.setLocation(700, 50);
B1.setLocation(810, 50);
B2.setLocation(845, 50);
B3.setLocation(880, 50);
B4.setLocation(915, 50);
OjosEtiq.setLocation(700, 100);
selector.setLocation(810, 100);
BocaEtiq.setLocation(700, 150);
a.setLocation(810, 150);
b.setLocation(870, 150);
c.setLocation(940, 150);
rellenoEtiq.setLocation(700,200);
relleno.setLocation(810, 200);
relleno2.setLocation(890, 200);
super.paint( g ); // llamar al método paint de la superclase
B1.setBackground(Color.yellow);
B2.setBackground(Color.blue);
B3.setBackground(Color.RED);
B4.setBackground(new Color(255,153,255));
g.setColor(Cuerpo);
g.fillOval(210, 480, 150, 60);
g.setColor(Color.BLACK);
g.drawOval(209, 481, 150, 60);//pie izquierdo
g.setColor(Cuerpo);
g.fillOval(490, 480, 150, 60);
g.setColor(Color.BLACK);
g.drawOval(489, 481, 150, 60);//pie derecho
// dibuja polígono relleno Rosa Orejas Fondo
g.setColor(Cuerpo);
int x[]={375,210,226};
int y[]={105,40,210};
g.fillPolygon(x, y, 3);
g.setColor(Color.black);
g.drawPolygon(x, y, 3);
g.setColor(Cuerpo);
int x3[]={610,580,400};
int y3[]={200,35,110};
g.fillPolygon(x3, y3, 3);
g.setColor(Color.black);
int x4[]={610,580,400};
int y4[]={200,35,110};
g.drawPolygon(x4, y4, 3);
// dibuja polígono relleno con objeto Polygon
g.setColor(Color.BLACK);
int x1[]={300,230,260};
int y1[]={120,70,220};
g.fillPolygon(x1, y1, 3);
g.setColor(Color.BLACK);
int x2[]={580,570,410};
int y2[]={150,60,120};
g.fillPolygon(x2, y2, 3);
g.setColor(Color.BLACK);
g.drawOval(199, 79, 451, 451);
g.setColor(Cuerpo);
g.fillOval(200, 80, 450, 450); //Cuerpo
g.setColor(Color.BLACK);
g.drawOval(279, 199, 96, 96);
g.setColor(Color.WHITE);
g.fillOval(280, 200, 95, 95);//Ojo Izquierdo Fondo
g.setColor(Ojos);
g.fillOval(287, 207, 80, 80); //Ojo Verde
g.setColor(Color.BLACK);
g.drawOval(286, 206, 81, 81);
g.setColor(Color.WHITE);
g.fillOval(290, 217, 40, 40);
g.setColor(Color.BLACK);
g.drawOval(289, 216, 41, 41);
g.setColor(Color.BLACK);
g.drawOval(419, 199, 101, 101);
g.setColor(Color.WHITE);
g.fillOval(420, 200, 100, 100);//Ojo derecho Fondo
g.setColor(Ojos);
g.fillOval(427, 207, 85, 85); // Verde
g.setColor(Color.BLACK);
g.drawOval(426, 206, 86, 86);
g.setColor(Color.WHITE);
g.fillOval(430, 217, 44, 44);
g.setColor(Color.BLACK);
g.drawOval(429, 216, 45, 45);
g.setColor(boca);//Boca
g.fillArc(350, 280, 90, 90, 180, 180);
g.setColor(Color.BLACK);
g.drawArc(349, 279, 91, 91, 180, 180);
g.drawLine(440, 325, 350, 325);
g.setColor( Color.BLACK );
g.drawArc( 450, 290, 90, 170, -5, -150 );
g.drawArc( 270, 290, 90, 170, -20, -150 );
}
}
dibujo jigglypuff en java

Más contenido relacionado

Más de Anel Sosa

Metodologia incremental
Metodologia incrementalMetodologia incremental
Metodologia incrementalAnel Sosa
 
Paradigmas de programacion
Paradigmas de programacion Paradigmas de programacion
Paradigmas de programacion Anel Sosa
 
Escenario socioeconomico
Escenario socioeconomicoEscenario socioeconomico
Escenario socioeconomicoAnel Sosa
 
Investigacion calculo derivadas e integrales
Investigacion calculo derivadas e integralesInvestigacion calculo derivadas e integrales
Investigacion calculo derivadas e integralesAnel Sosa
 
Lenguajes de simulacion
Lenguajes de simulacionLenguajes de simulacion
Lenguajes de simulacionAnel Sosa
 
maquinas de turing jflap
maquinas de turing jflapmaquinas de turing jflap
maquinas de turing jflapAnel Sosa
 
Panuco Veracruz
Panuco Veracruz Panuco Veracruz
Panuco Veracruz Anel Sosa
 
que es un Curriculum
que es un Curriculumque es un Curriculum
que es un CurriculumAnel Sosa
 
maquinas de turing
maquinas de turingmaquinas de turing
maquinas de turingAnel Sosa
 
automatas finitos
 automatas finitos automatas finitos
automatas finitosAnel Sosa
 
Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regularesAnel Sosa
 
ESPRESIONES REGULARES
ESPRESIONES REGULARESESPRESIONES REGULARES
ESPRESIONES REGULARESAnel Sosa
 
investigacion introduccion a los lenguajes y automatas
investigacion introduccion a los lenguajes y automatasinvestigacion introduccion a los lenguajes y automatas
investigacion introduccion a los lenguajes y automatasAnel Sosa
 
programa pelotas java
programa pelotas javaprograma pelotas java
programa pelotas javaAnel Sosa
 
Programacion concurrente
Programacion concurrenteProgramacion concurrente
Programacion concurrenteAnel Sosa
 
Programa en java circulos
Programa en java circulosPrograma en java circulos
Programa en java circulosAnel Sosa
 
investigacion topicos avanzados de programacion unidad dos interfaz grafica
investigacion topicos avanzados de programacion unidad dos interfaz graficainvestigacion topicos avanzados de programacion unidad dos interfaz grafica
investigacion topicos avanzados de programacion unidad dos interfaz graficaAnel Sosa
 
DIBUJO EN JFRAME CASA
DIBUJO EN JFRAME CASADIBUJO EN JFRAME CASA
DIBUJO EN JFRAME CASAAnel Sosa
 
investigacion unidad tres componentes y librerias
investigacion unidad tres componentes y libreriasinvestigacion unidad tres componentes y librerias
investigacion unidad tres componentes y libreriasAnel Sosa
 

Más de Anel Sosa (20)

SIMMAN 3G
SIMMAN 3GSIMMAN 3G
SIMMAN 3G
 
Metodologia incremental
Metodologia incrementalMetodologia incremental
Metodologia incremental
 
Paradigmas de programacion
Paradigmas de programacion Paradigmas de programacion
Paradigmas de programacion
 
Escenario socioeconomico
Escenario socioeconomicoEscenario socioeconomico
Escenario socioeconomico
 
Investigacion calculo derivadas e integrales
Investigacion calculo derivadas e integralesInvestigacion calculo derivadas e integrales
Investigacion calculo derivadas e integrales
 
Lenguajes de simulacion
Lenguajes de simulacionLenguajes de simulacion
Lenguajes de simulacion
 
maquinas de turing jflap
maquinas de turing jflapmaquinas de turing jflap
maquinas de turing jflap
 
Panuco Veracruz
Panuco Veracruz Panuco Veracruz
Panuco Veracruz
 
que es un Curriculum
que es un Curriculumque es un Curriculum
que es un Curriculum
 
maquinas de turing
maquinas de turingmaquinas de turing
maquinas de turing
 
automatas finitos
 automatas finitos automatas finitos
automatas finitos
 
Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regulares
 
ESPRESIONES REGULARES
ESPRESIONES REGULARESESPRESIONES REGULARES
ESPRESIONES REGULARES
 
investigacion introduccion a los lenguajes y automatas
investigacion introduccion a los lenguajes y automatasinvestigacion introduccion a los lenguajes y automatas
investigacion introduccion a los lenguajes y automatas
 
programa pelotas java
programa pelotas javaprograma pelotas java
programa pelotas java
 
Programacion concurrente
Programacion concurrenteProgramacion concurrente
Programacion concurrente
 
Programa en java circulos
Programa en java circulosPrograma en java circulos
Programa en java circulos
 
investigacion topicos avanzados de programacion unidad dos interfaz grafica
investigacion topicos avanzados de programacion unidad dos interfaz graficainvestigacion topicos avanzados de programacion unidad dos interfaz grafica
investigacion topicos avanzados de programacion unidad dos interfaz grafica
 
DIBUJO EN JFRAME CASA
DIBUJO EN JFRAME CASADIBUJO EN JFRAME CASA
DIBUJO EN JFRAME CASA
 
investigacion unidad tres componentes y librerias
investigacion unidad tres componentes y libreriasinvestigacion unidad tres componentes y librerias
investigacion unidad tres componentes y librerias
 

dibujo jigglypuff en java

  • 1. import java.awt.Button; import java.awt.event.ItemListener; import java.awt.Checkbox; import java.awt.CheckboxGroup; import java.awt.Color; import java.awt.Event; import java.awt.Graphics; import java.awt.Image; import java.applet.Applet; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; public class poke extends Applet{ Image imagen1,imagen2; Button B1,B2,B3,B4; String cad=""; Label CuerpoEtiq,OjosEtiq,BocaEtiq, rellenoEtiq; Color Cuerpo=new Color(255,153,255); Color Ojos=new Color(0,200,160); Color boca=new Color(255,102,153); CheckboxGroup Radio; Checkbox a,b,c; Checkbox relleno,relleno2; Choice selector;
  • 2. public void init() { imagen1 = getImage (getDocumentBase(),"imagen1.JPG"); imagen2 = getImage (getDocumentBase(),"imagen2.JPG"); CuerpoEtiq= new Label ("Color del cuerpo"); OjosEtiq= new Label ("Color del ojos"); BocaEtiq=new Label("Color de boca"); rellenoEtiq= new Label("Imagen"); B1 = new Button( " " ); B2 = new Button( " " ); B3 = new Button( " " ); B4 = new Button( " " ); this.add(CuerpoEtiq); this.add( B1 ); this.add( B2 ); this.add( B3 ); this.add( B4 ); this.add(OjosEtiq);
  • 3. selector = new Choice(); selector.addItem("Azul"); selector.addItem("Gris"); selector.addItem("Naranja"); selector.addItem("Original"); add(selector); add(BocaEtiq); Radio=new CheckboxGroup(); a=new Checkbox("Rojo", Radio,false); b=new Checkbox("Amarillo", Radio,false); c= new Checkbox("Negro", Radio,false); add(a); add(b); add(c); relleno= new Checkbox("Imagen1"); relleno2= new Checkbox("Imagen2"); add(rellenoEtiq); add(relleno); add(relleno2);
  • 4. } String valor; public boolean action (Event evt, Object obj) { valor=selector.getSelectedItem().toString(); if(evt.target instanceof Choice) { if(valor=="Azul") { Ojos=Color.blue; } if(valor=="Gris") { Ojos= Color.gray; }
  • 5. if(valor=="Naranja") { Ojos=Color.orange; } if(valor=="Original") { Ojos=new Color(0,200,160); } } if(evt.target.equals (B1)) { Cuerpo=Color.yellow; } if(evt.target.equals (B2)) { Cuerpo=Color.blue; } if(evt.target.equals (B3)) { Cuerpo=Color.red; } if(evt.target.equals (B4)) { Cuerpo=new Color(255,153,255); }
  • 6. if(evt.target instanceof Checkbox) { Checkbox radio=Radio.getSelectedCheckbox(); if(radio.equals(a) ) { boca=Color.red; } if(radio.equals(b) ) { boca=Color.yellow; } if(radio.equals(c) ) { boca=Color.black; } } if(evt.target instanceof Checkbox) { Checkbox radio=Radio.getSelectedCheckbox(); if(radio.equals(imagen1) ) { boca=Color.red; } if(radio.equals(imagen2) ) { boca=Color.yellow; } if(radio.equals(c) ) {
  • 7. boca=Color.black; } } repaint(); return true; }//action public void paint(Graphics g) { setSize(1100,600); g.drawImage(imagen1, 10, 10, 150, 190, this); g.drawImage(imagen2, 100, 100, 200, 300, this); CuerpoEtiq.setLocation(700, 50); B1.setLocation(810, 50); B2.setLocation(845, 50); B3.setLocation(880, 50); B4.setLocation(915, 50);
  • 8. OjosEtiq.setLocation(700, 100); selector.setLocation(810, 100); BocaEtiq.setLocation(700, 150); a.setLocation(810, 150); b.setLocation(870, 150); c.setLocation(940, 150); rellenoEtiq.setLocation(700,200); relleno.setLocation(810, 200); relleno2.setLocation(890, 200); super.paint( g ); // llamar al método paint de la superclase B1.setBackground(Color.yellow); B2.setBackground(Color.blue); B3.setBackground(Color.RED); B4.setBackground(new Color(255,153,255)); g.setColor(Cuerpo); g.fillOval(210, 480, 150, 60); g.setColor(Color.BLACK); g.drawOval(209, 481, 150, 60);//pie izquierdo g.setColor(Cuerpo); g.fillOval(490, 480, 150, 60);
  • 9. g.setColor(Color.BLACK); g.drawOval(489, 481, 150, 60);//pie derecho // dibuja polígono relleno Rosa Orejas Fondo g.setColor(Cuerpo); int x[]={375,210,226}; int y[]={105,40,210}; g.fillPolygon(x, y, 3); g.setColor(Color.black); g.drawPolygon(x, y, 3); g.setColor(Cuerpo); int x3[]={610,580,400}; int y3[]={200,35,110}; g.fillPolygon(x3, y3, 3); g.setColor(Color.black); int x4[]={610,580,400}; int y4[]={200,35,110}; g.drawPolygon(x4, y4, 3); // dibuja polígono relleno con objeto Polygon g.setColor(Color.BLACK); int x1[]={300,230,260}; int y1[]={120,70,220}; g.fillPolygon(x1, y1, 3);
  • 10. g.setColor(Color.BLACK); int x2[]={580,570,410}; int y2[]={150,60,120}; g.fillPolygon(x2, y2, 3); g.setColor(Color.BLACK); g.drawOval(199, 79, 451, 451); g.setColor(Cuerpo); g.fillOval(200, 80, 450, 450); //Cuerpo g.setColor(Color.BLACK); g.drawOval(279, 199, 96, 96); g.setColor(Color.WHITE); g.fillOval(280, 200, 95, 95);//Ojo Izquierdo Fondo g.setColor(Ojos); g.fillOval(287, 207, 80, 80); //Ojo Verde g.setColor(Color.BLACK); g.drawOval(286, 206, 81, 81); g.setColor(Color.WHITE); g.fillOval(290, 217, 40, 40); g.setColor(Color.BLACK); g.drawOval(289, 216, 41, 41); g.setColor(Color.BLACK); g.drawOval(419, 199, 101, 101); g.setColor(Color.WHITE); g.fillOval(420, 200, 100, 100);//Ojo derecho Fondo
  • 11. g.setColor(Ojos); g.fillOval(427, 207, 85, 85); // Verde g.setColor(Color.BLACK); g.drawOval(426, 206, 86, 86); g.setColor(Color.WHITE); g.fillOval(430, 217, 44, 44); g.setColor(Color.BLACK); g.drawOval(429, 216, 45, 45); g.setColor(boca);//Boca g.fillArc(350, 280, 90, 90, 180, 180); g.setColor(Color.BLACK); g.drawArc(349, 279, 91, 91, 180, 180); g.drawLine(440, 325, 350, 325); g.setColor( Color.BLACK ); g.drawArc( 450, 290, 90, 170, -5, -150 ); g.drawArc( 270, 290, 90, 170, -20, -150 ); } }