Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/12/2012, 07:11
Rasec101
 
Fecha de Ingreso: diciembre-2009
Ubicación: Santiago, Chile
Mensajes: 143
Antigüedad: 14 años, 4 meses
Puntos: 2
Respuesta: Como dividir este applet

acá esta la segunda classe

2-tarea1.java
Código java:
Ver original
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package Applet;
  6.  
  7. import java.applet.Applet;
  8. import java.awt.*;
  9.  
  10.  
  11. public class Tarea1 extends Applet {
  12.     Tarea1Cls t1=new Tarea1Cls();
  13.     int f=0;
  14.     TextField txt1,txt2,txt3;
  15.     Button b8;
  16.    
  17.  @Override
  18.     public void init() {
  19.        resize(600,600);    
  20.      
  21.         Button b1,b2,b3,b4,b5,b6,b7;
  22.  
  23.         setLayout(null);
  24.         b1=new Button("Choque");  
  25.         add(b1);
  26.         b1.setBounds(10, 10, 60, 20);
  27.        
  28.         b2=new Button("Flecha");  
  29.         add(b2);
  30.         b2.setBounds(80, 10, 60, 20);
  31.        
  32.         b3=new Button("Planeta");  
  33.         add(b3);
  34.         b3.setBounds(150, 10, 60, 20);
  35.        
  36.         b4=new Button("Cuadrado");  
  37.         add(b4);
  38.         b4.setBounds(220, 10, 60, 20);
  39.        
  40.         b5=new Button("Onda");  
  41.         add(b5);
  42.         b5.setBounds(290, 10, 60, 20);
  43.        
  44.         b6=new Button("Colores");  
  45.         add(b6);
  46.         b6.setBounds(360, 10, 60, 20);
  47.        
  48.         b7=new Button("Barras");  
  49.         add(b7);
  50.         b7.setBounds(430, 10, 60, 20);
  51.        
  52.         b8=new Button("Calcular");  
  53.         add(b8);
  54.         b8.setBounds(250, 40, 60, 20);
  55.        
  56.        
  57.          
  58.         txt1=new TextField("", 10);
  59.         add(txt1);
  60.         txt1.setBounds(10, 40, 50, 20);
  61.         txt1.setVisible(false);
  62.        
  63.         txt2=new TextField("", 10);
  64.         add(txt2);
  65.         txt2.setBounds(70, 40, 50, 20);
  66.         txt2.setVisible(false);
  67.        
  68.         txt3=new TextField("", 10);
  69.         add(txt3);
  70.         txt3.setBounds(130, 40, 50, 20);
  71.         txt3.setVisible(false);
  72.        
  73.         b8.setVisible(false);    
  74.     }
  75.    
  76.     @Override
  77.     public void paint(Graphics g) {
  78.        
  79.        if (f!=8 && f!=7) {
  80.             txt1.setVisible(false);
  81.             txt2.setVisible(false);
  82.             txt3.setVisible(false);
  83.             b8.setVisible(false);
  84.        }
  85.        
  86.        switch(f) {
  87.            case 0:
  88.                 break;
  89.            case 1:
  90.                t1.Pantalla_Tarea1(g);
  91.                break;
  92.            case 2:
  93.                t1.Pantalla_Tarea2(g);
  94.                break;
  95.            case 3:
  96.                t1.Pantalla_Tarea3(g);    
  97.                break;
  98.            case 4:
  99.                t1.Pantalla_Tarea4(g);
  100.                break;
  101.            case 5:
  102.                t1.Pantalla_Tarea5(g);              
  103.                break;              
  104.            case 6:
  105.                t1.Pantalla_Tarea6(g);              
  106.                break;
  107.            case 7:
  108.                 txt1.setVisible(true);
  109.                 txt2.setVisible(true);
  110.                 txt3.setVisible(true);
  111.                 b8.setVisible(true);
  112.                 txt1.setText("");
  113.                 txt2.setText("");
  114.                 txt3.setText("");                
  115.                break;  
  116.            case 8:
  117.                t1.Pantalla_Tarea7(g,txt1,txt2,txt3);              
  118.                break;                
  119.            default:
  120.                g.drawString("Función no implementada.",40,40);
  121.        }
  122.              
  123.        f=0;      
  124.    
  125.        
  126.        
  127.    }
  128.     @Override
  129.     public boolean action(Event evt, Object arg) {        
  130.        
  131.             if (arg== "Choque") {f=1;}
  132.             if (arg== "Flecha") {f=2;}
  133.             if (arg== "Planeta") {f=3;}  
  134.             if (arg== "Cuadrado") {f=4;}  
  135.             if (arg== "Onda") {f=5;}  
  136.             if (arg== "Colores") {f=6;}  
  137.             if (arg== "Barras") {f=7;}
  138.             if (arg== "Calcular") {f=8;}  
  139.            
  140.  
  141.             repaint();
  142.             return true;
  143.     }
  144.  
  145. }