Presentation is loading. Please wait.

Presentation is loading. Please wait.

INSTITUTO TÉCNOLOGICO SUPERIOR DE LIBRES CARLA PATRICIA VIVANCO GARCÍA TOPICOS AVANZADOS DE PROGRAMACIÓN ELIZABETH DÍAZ OREA.

Similar presentations


Presentation on theme: "INSTITUTO TÉCNOLOGICO SUPERIOR DE LIBRES CARLA PATRICIA VIVANCO GARCÍA TOPICOS AVANZADOS DE PROGRAMACIÓN ELIZABETH DÍAZ OREA."— Presentation transcript:

1 INSTITUTO TÉCNOLOGICO SUPERIOR DE LIBRES CARLA PATRICIA VIVANCO GARCÍA TOPICOS AVANZADOS DE PROGRAMACIÓN ELIZABETH DÍAZ OREA

2 ¡Hola! ¿Cómo estas? ¡Hola mundo! Botón Calculadora Cardex Figuras Figuras con botones Cuadro

3 ¡Hola! ¿Cómo estas? import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; public class boton extends Applet implements ActionListener { TextField a,b,c; Button b1,b2; Label l,lb; public void init() { l=new Label("Pulsa botón"); lb=new Label(""); b1=new Button("Botón"); b1.addActionListener(this);

4 add(l); add(b1); add(lb); } public void actionPerformed(ActionEvent e) { String letrero="Diego"; int r=0; if(e.getSource()==b1){ r=0; letrero="¡Hola mundo! "; lb.setText(letrero); a.setText(r + " ");

5

6 ¡Hola mundo! import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; public class boton extends Applet implements ActionListener { TextField a,b,c; Button b1,b2; Label l,lb; public void init() { l=new Label("Pulsa botón"); lb=new Label(""); b1=new Button("Botón"); b1.addActionListener(this);

7 add(l); add(b1); add(lb); } public void actionPerformed(ActionEvent e) { String letrero="Diego"; int r=0; if(e.getSource()==b1){ r=0; letrero="¡Hola mundo! "; lb.setText(letrero); a.setText(r + " ");

8

9 Botón import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class AppletActionEvent extends Applet implements ActionListener { Button b; Label l; boolean modificado = false; public void init() { b=new Button("Presioname"); b.setActionCommand("Botón presioname"); add(b); b.addActionListener(this); l=new Label(" "); add(l); }

10 public void actionPerformed(ActionEvent e) { if(. modificado){ b
public void actionPerformed(ActionEvent e) { if(!modificado){ b.setLabel("Cancelar"); modificado=true; l.setText(b.getActionCommand()); }else{ b.setLabel("Oprimeme"); modificado=false; Button origen = (Button)e.getSource(); l.setText(origen.getLabel()); }

11

12 calculadora import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.Applet.*; public class Calculadora extends Applet implements ActionListener { TextField a,b,c; Button b1,b2,b3,b4; Label l,l1,l2,l3; public void init() { l=new Label("*****Calculadora*****"); l1 = new Label("Primer valor"); a=new TextField(20); l2=new Label("Segundo valor"); b=new TextField(20); b1=new Button("+"); b2=new Button("-"); b3=new Button("*");

13 b4=new Button("/"); l3=new Label("Resultado"); c=new TextField(20); b1
b4=new Button("/"); l3=new Label("Resultado"); c=new TextField(20); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); Panel p = new Panel(); p.setLayout(new GridLayout(5,2)); Panel p1 = new Panel (); p1.setLayout(new GridLayout(1,1)); add(p1); add(p); p1.add(l); p.add(l1); p.add(a); p.add(l2); p.add(b); p.add(b1);

14 p. add(b2); p. add(b3); p. add(b4); p. add(l3); p
p.add(b2); p.add(b3); p.add(b4); p.add(l3); p.add(c); } public void actionPerformed(ActionEvent e) { int v1=Integer.parseInt(a.getText()); int v2=Integer.parseInt(b.getText()); int r; if(e.getSource()==b1){ r=v1+v2; c.setText(r+""); if(e.getSource()==b2){ r=v1-v2;

15 if(e. getSource()==b3){ r=v1. v2; c. setText(r+""); } if(e
if(e.getSource()==b3){ r=v1*v2; c.setText(r+""); } if(e.getSource()==b4){ r=v1/v2;

16

17 cardex import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.Applet.*; import java.awt.Color.*; public class Cardex extends Applet implements ActionListener { TextField ma1,ma2,ma3, ma4, ma5, ma6,ma7,ma8,ma9,ma10,ma11,ma12,ma13,ma14,ma15, ma16,ma17,ma18,ma19,ma20,ma21,ma22, ma23,ma24,in1,in2,prom1,prom2,prom3,prom4,ingles,promg; Label m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16,m17 ,m18,m19,m20, m21,m22,m23,m24,i1,i2,ing,p1,p2,p3,p4,pg,titulo; Button ge, carla, roger, ge4, fin; public void init() { Label alumno = new Label ("Nombre"); Label num = new Label ("Número de control");

18 TextField nomb = new TextField (30); TextField n = new TextField (20); ge = new Button ("1° semestre"); carla = new Button ("2° semestre"); roger = new Button ("3° semestre"); ge4 = new Button ("4° semestre"); titulo = new Label ("Cardex"); m1 = new Label ("Taller de ética"); m2 = new Label ("Fund. de investigación"); m3 = new Label ("Cálculo diferencial"); m4 = new Label ("Matemáticas discretas"); m5 = new Label ("Fund. de programación"); m6 = new Label ("Taller de administración"); m7 = new Label ("Cálculo integral"); m8 = new Label ("Algebra lineal"); m9 = new Label ("Contabilidad "); m10 = new Label ("Quimica"); m11 = new Label ("Probabilidad y estadistica");

19 m12 = new Label ("POO"); m13 = new Label ("Cálculo vectorial"); m14 = new Label ("Sistemas operativos"); m15 = new Label ("Estructura de datos"); m16 = new Label ("Cultura empresarial"); m17 = new Label ("Investigación operacional"); m18 = new Label ("Fisica general"); m19 = new Label ("Ecuaciones diferenciales"); m20 = new Label ("Fund. de bases de datos"); m21 = new Label ("Taller de sistemas operativos"); m22 = new Label ("Métodos numéricos"); m23 = new Label ("Principios electricos"); m24 = new Label ("Topicos avanzados"); p1 = new Label ("Promedio 1° semestre"); p2 = new Label ("Promedio 2° semestre"); p3 = new Label ("Promedio 3° semestre"); p4 = new Label ("Promedio 4° semestre"); pg = new Label ("Promedio general");fin =new Button ("Promedio Final");

20 ma1 = new TextField (20); ma2 = new TextField (20); ma3 = new TextField (20); ma4 = new TextField (20); ma5 = new TextField (20); ma6 = new TextField (20); ma7 = new TextField (20); ma8 = new TextField (20); ma9 = new TextField (20); ma10 = new TextField (20); ma11 = new TextField (20); ma12 = new TextField (20); ma13 = new TextField (20); ma14 = new TextField (20); ma15 = new TextField (20); ma16 = new TextField (20); ma17 = new TextField (20); ma18 = new TextField (20); ma19 = new TextField (20);

21 ma20 = new TextField (20); ma21 = new TextField (20); ma22 = new TextField (20); ma23 = new TextField (20); ma24= new TextField (20); prom1 = new TextField (20); prom2 = new TextField (20); prom3 = new TextField (20); prom4 = new TextField (20); promg = new TextField (20); p1 = new Label ("Promedio 1° semestre"); p2 = new Label ("Promedio 2° semestre"); p3 = new Label ("Promedio 3° semestre"); p4 = new Label ("Promedio 4° semestre"); pg = new Label ("Promedio general");

22 Panel pan=new Panel (); pan
Panel pan=new Panel (); pan.setLayout(new GridLayout(5,3)); Panel pan2=new Panel (); pan2.setLayout(new GridLayout(5,3)); Panel pan3=new Panel (); pan3.setLayout(new GridLayout(5,3)); Panel pan4=new Panel (); pan4.setLayout(new GridLayout(5,3)); Panel pan1 = new Panel (); pan1.setLayout(new GridLayout(5,2)); Panel esp=new Panel (); esp.setLayout(new GridLayout(5,3)); Panel pan5=new Panel (); pan5.setLayout(new GridLayout(3,1)); add(pan1); add(pan); add(esp); add(pan2); add(pan3);

23 add(pan4); add(pan5); pan1. add(titulo); pan1. add(alumno); pan1
add(pan4); add(pan5); pan1.add(titulo); pan1.add(alumno); pan1.add(nomb); pan1.add(num); pan1.add(n); ge.addActionListener(this); carla.addActionListener(this); roger.addActionListener(this); ge4.addActionListener(this); pan.add(ge); pan.add(m1); pan.add(ma1); pan.add(m2); pan.add(ma2); pan.add(m3);

24 pan. add(ma3); pan. add(m4); pan. add(ma4); pan. add(m5); pan
pan.add(ma3); pan.add(m4); pan.add(ma4); pan.add(m5); pan.add(ma5); pan.add(m6); pan.add(ma6); pan.add(p1); pan.add(prom1); pan2.add(carla); pan2.add(m7); pan2.add(ma7); pan2.add(m8); pan2.add(ma8); pan2.add(m9); pan2.add(ma9); pan2.add(m10); pan2.add(ma10); pan2.add(m11);

25 pan2. add(ma11); pan2. add(m12); pan2. add(ma12); pan2. add(p2); pan2
pan2.add(ma11); pan2.add(m12); pan2.add(ma12); pan2.add(p2); pan2.add(prom2); pan3.add(roger); pan3.add(m13); pan3.add(ma13); pan3.add(m14); pan3.add(ma14); pan3.add(m15); pan3.add(ma15); pan3.add(m16); pan3.add(ma16); pan3.add(m17); pan3.add(ma17); pan3.add(m18); pan3.add(ma18); pan3.add(p3);

26 pan3.add(prom3); pan4.add(ge4); pan4.add(m19); pan4.add(ma19); pan4.add(m20); pan4.add(ma20); pan4.add(m21); pan4.add(ma21); pan4.add(m22); pan4.add(ma22); pan4.add(m23); pan4.add(ma23); pan4.add(m24); pan4.add(ma24); pan4.add(p4); pan4.add(prom4); pan5.add(fin); pan5.add(pg);

27 pan5.add(promg); } public void actionPerformed(ActionEvent e) { repaint(); if (e.getSource()==ge){ int r1=0; int v1=Integer.parseInt(ma1.getText()); int v2=Integer.parseInt(ma2.getText()); int v3=Integer.parseInt(ma3.getText()); int v4=Integer.parseInt(ma4.getText()); int v5=Integer.parseInt(ma5.getText()); int v6=Integer.parseInt(ma6.getText()); r1 = (v1+v2+v3+v4+v5+v6)/6; prom1.setText(r1+""); if (e.getSource()==carla){ int r2=0; int s1=Integer.parseInt(ma7.getText()); int s2=Integer.parseInt(ma8.getText());

28 int s3=Integer.parseInt(ma9.getText()); int s4=Integer.parseInt(ma10.getText()); int s5=Integer.parseInt(ma11.getText()); int s6=Integer.parseInt(ma12.getText()); r2 = (s1+s2+s3+s4+s5+s6)/6; prom2.setText(r2+""); } if(e.getSource()==roger){ int r3=0; int c1=Integer.parseInt(ma13.getText()); int c2=Integer.parseInt(ma14.getText()); int c3=Integer.parseInt(ma15.getText()); int c4=Integer.parseInt(ma16.getText()); int c5=Integer.parseInt(ma17.getText()); int c6=Integer.parseInt(ma18.getText()); r3 = (c1+c2+c3+c4+c5+c6)/6; prom3.setText(r3+""); if(e.getSource()==ge4){ int r4=0;

29 int g1=Integer. parseInt(ma19. getText()); int g2=Integer
int g1=Integer.parseInt(ma19.getText()); int g2=Integer.parseInt(ma20.getText()); int g3=Integer.parseInt(ma21.getText()); int g4=Integer.parseInt(ma22.getText()); int g5=Integer.parseInt(ma23.getText()); int g6=Integer.parseInt(ma24.getText()); r4 = (g1+g2+g3+g4+g5+g6)/6; prom4.setText(r4+""); } if(e.getSource()==fin ){ int promedio=0; int z1 =Integer.parseInt(prom1.getText()); int z2 =Integer.parseInt(prom2.getText()); int z3 =Integer.parseInt(prom3.getText()); int z4 =Integer.parseInt(prom4.getText()); promedio=(z1+z2+z3+z4)/4; promg.setText(promedio + ""); } } public void paint(Graphics g){ setBackground(Color.magenta); } }

30

31 figuras import java.applet.Applet; import java.applet.*; import java.awt.*; public class Figuras extends Applet { public void paint(Graphics g){ int[]x= {150,250,100}; int[]y= {120,200,200}; Polygon tri; tri = new Polygon (x,y,3); g.setColor(Color.blue); g.fillOval(500, 120,100, 100); g.setColor(Color.RED); g.fillPolygon(tri);

32 g. setColor(Color. green); g. drawLine(450, 350, 500, 350); g
g.setColor(Color.green); g.drawLine(450, 350, 500, 350); g.setColor(Color.ORANGE); g.fillRect(300, 150, 122, 60); g.setColor(Color.red); g.drawString("FIGURAS GEOMETRICAS", 250,50); g.drawArc(50, 100, 150, 100, 80, 80); }

33

34 Figuras con botones import java.applet.Applet; import java.awt.*; import java.applet.Applet.*; import java.awt.event.*; import java.awt.Color.*; public class Figuras extends Applet implements ActionListener { Button a,b,c,d; static int op; public void init() { a=new Button("Linea"); b=new Button("Triángulo"); c=new Button("Cuadrado"); d=new Button("Circulo"); a.addActionListener(this); b.addActionListener(this); c.addActionListener(this); d.addActionListener(this);

35 add(a); add(b); add(c); add(d);} public void actionPerformed(ActionEvent e) { repaint(); if(e.getSource()==a){ op=1; } if(e.getSource()==b){ op =2; if(e.getSource()==c){ op=3; if(e.getSource()==d){ op =4; }}

36 public void paint(Graphics g){ switch (op){ case 1: g. setColor(Color
public void paint(Graphics g){ switch (op){ case 1: g.setColor(Color.MAGENTA); g.drawLine(550, 350, 650, 350); break; case 2: int []x={150,250,100 }; int []y={120,200,200}; Polygon tra; tra = new Polygon (x,y,3); g.fillPolygon(tra);

37 case 3: g. setColor(Color. red); g
case 3: g.setColor(Color.red); g.fillRect(100,100,100,100); break; case 4: g.setColor(Color.MAGENTA); g.fillOval(200, 300,100,100); }

38

39

40 cuadro import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.awt.Color.*; public class C extends Applet implements ActionListener { Button b; public void init() { b= new Button ("<<Color>>"); b.addActionListener(this);; add(b); }

41 public void actionPerformed (ActionEvent e){ repaint(); } public void paint(Graphics g){ setBackground(Color.BLACK); g.setColor(new Color ((int)(Math.random()*255 +1), (int)(Math.random()* 255+1), (int) (Math.random()* 255+1))); g.fillRect(450, 120, 200, 200);

42


Download ppt "INSTITUTO TÉCNOLOGICO SUPERIOR DE LIBRES CARLA PATRICIA VIVANCO GARCÍA TOPICOS AVANZADOS DE PROGRAMACIÓN ELIZABETH DÍAZ OREA."

Similar presentations


Ads by Google