You are on page 1of 4

1)              NUM1= Float.parseFloat(N1.

getText()); 
import java.awt.*;              NUM2= Float.parseFloat(N2.getText()); 
import java.awt.event.*;              T_RESULT= NUM1 ‐ NUM2; 
import javax.swing.*;    
public class ARITMETICA extends JFrame               RES.setText(String.valueOf(T_RESULT)); 
{               T_RES.setText("LA RESTA ES"); 
    public JLabel T1,T2,T_RES;          } 
    public JTextField N1,N2,RES;          catch(Exception E) 
    public JButton SUMAR,RESTAR;          { 
               T_RES.setText("ERROR AL RESTAR"); 
    public ARITMETICA()          } 
    {      } 
        super("ARITMETICA EN JAVA");      } 
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      ); 
        setSize(510,460);    } 
     public static void main(String[] ARGUMENTOS) 
        T1 = new JLabel("PRIMER NUMERO  ");    { 
        T2 = new JLabel("SEGUNDO NUMERO ");          ARITMETICA MI_INTERFAZ = new ARITMETICA(); 
        T_RES = new JLabel("RESULTADO");          MI_INTERFAZ.setResizable(true); 
           MI_INTERFAZ.setLayout(null); 
        N1 = new JTextField(10);          MI_INTERFAZ.setVisible(true); 
        N2 = new JTextField(10);    } 
        RES = new JTextField(10);  } 
        RES.setEditable(false);  2) import java.awt.*; 
   import java.awt.event.*; 
        SUMAR = new JButton("SUMAR");  import java.awt.Graphics; 
        RESTAR = new JButton("RESTAR");  import javax.swing.*; 
          public class MATRICES_SWING extends JFrame  
        FlowLayout DISTRIBUIDOR = new FlowLayout();  { 
    public JLabel L1,TIT; 
        this.setLayout(DISTRIBUIDOR); 
    public JTextField T1; 
  
    public JButton MAGICO,ESPIRAL,TRIANGULAR; 
        add(T1);T1.setBounds(50,80,100,30);      public   int  mat[][],n,i,j; 
        add(N1);N1.setBounds(200,80,100,30);      public MATRICES_SWING() 
        add(T2);T2.setBounds(50,150,150,30);      { 
        add(N2);N2.setBounds(200,150,100,30);          super("GENERAR MATRICES"); 
        add(T_RES);T_RES.setBounds(50,250,150,30);          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
        add(RES);RES.setBounds(200,250,100,30);          setSize(700,700); 
        add(SUMAR);SUMAR.setBounds(50,300,100,30);          mat = new int [20][20];     
        add(RESTAR);RESTAR.setBounds(180,300,100,30);              L1 = new JLabel("INGRESE DIMENSION "); 
              T1 = new JTextField(10); 
         
        MAGICO = new JButton("MAGICO"); 
    SUMAR.addActionListener( new ActionListener(){ 
        ESPIRAL = new JButton("ESPIRAL"); 
    public void  actionPerformed(ActionEvent EVENTO) 
        TRIANGULAR = new JButton("TRIANGULAR"); 
    { 
                   
        float NUM1,NUM2,T_RESULT;          add(L1);L1.setBounds(20,20,130,30); 
        try          add(T1);T1.setBounds(170,20,60,30); 
        {   
            NUM1= Float.parseFloat(N1.getText());          add(MAGICO);MAGICO.setBounds(270,20,100,30); 
            NUM2= Float.parseFloat(N2.getText());          add(ESPIRAL);ESPIRAL.setBounds(380,20,100,30); 
            T_RESULT= NUM1 + NUM2;          add(TRIANGULAR);TRIANGULAR.setBounds(490,20,100,30);     
        
            RES.setText(String.valueOf(T_RESULT));      MAGICO.addActionListener( new ActionListener(){ 
             T_RES.setText("LA SUMA ES");      public void  actionPerformed(ActionEvent E) 
        }      { int con=0,f=0,c=0,k=0,s=0; 
      n=Integer.parseInt(T1.getText()); 
        catch(Exception E) 
      c=(n)/2; 
        { 
      do{ con++; 
            T_RES.setText("ERROR AL SUMAR");            mat[f][c]=con; 
        }           if (con%n==0) 
    }            { 
    }              f++; 
    );            }   
                else   
    RESTAR.addActionListener( new ActionListener(){            if (f==0) 
    public void  actionPerformed(ActionEvent EVENTO)            { 
    {              f=n‐1; 
        float NUM1,NUM2,T_RESULT;              c++; 
        try            }    
          else   
        { 
          if (c==n‐1)      ); 
          {   } 
            c=0;   
            f‐‐;    public static void main(String[] ARGUMENTOS) 
          }    { 
          else          MATRICES_SWING MI_MAT = new MATRICES_SWING(); 
          {          MI_MAT.setResizable(true); 
          c++;          MI_MAT.setLayout(null); 
            f‐‐;          MI_MAT.setVisible(true); 
          }           } 
      }    
      while(con<=n*n);   public void paint (Graphics g) 
      repaint();      {    
    }         g.clearRect(0,120,700,700); 
    }         g.setColor(Color.blue); 
    );    Font fuente=new Font("Algerian", Font.BOLD, 36); 
                       g.setFont(fuente); 
          for (i=0;i<n;i++) 
    ESPIRAL.addActionListener( new ActionListener(){        { 
    public void  actionPerformed(ActionEvent E)          for (j=0;j<n;j++)   
    { int p,f,c,num_vuel=0,con=1;          { 
      n=Integer.parseInt(T1.getText());                     g.drawString(" "+mat[i][j],50+j*65,150+i*65);                       
      num_vuel=(n+1)/2;          }   
      for (p=0;p<num_vuel;p++)        }   
      {      }   
       for (f=p;f<n‐p;f++)  } 
        {   
          mat[p][f]=con++;      3) 
        }  //CLASE PRINCIPAL ARCHIVOS_AWT 
        for (c=p+1;c<n‐p;c++)    import java.awt.event.*; 
        {  import java.awt.*; 
          mat[c][n‐p‐1]=con++;      import java.io.*; 
       } 
import javax.swing.*; 
        for (f=n‐p‐2;f>=p;f‐‐) 
public class ARCHIVOS_AWT extends JFrame 
       { 
         mat[n‐p‐1][f]=con++;      {   INGRESO_DATOS ar = new INGRESO_DATOS();  
        }      public JMenu MENU_ARCHIVO,MENU_REPORTE; 
         for (c=n‐p‐2;c>p;c‐‐)      public JMenuItem ITEM_INGRESO,ITEM_VER,ITEM_SALIR; 
        {      public JMenuBar MENU_BAR; 
         mat[c][p]=con++;        public ARCHIVOS_AWT() throws IOException 
        }      {   super("MANEJO DE ARCHIVOS"); 
     }          this.setSize(600,400); 
     repaint();          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    }          this.ITEM_INGRESO = new JMenuItem("INGRESO_DATOS"); 
    }          this.ITEM_VER = new JMenuItem("VER_DATOS"); 
    ); 
        this.ITEM_SALIR = new JMenuItem("SALIR"); 
     
        this.MENU_ARCHIVO = new JMenu("ARCHIVO"); 
    TRIANGULAR.addActionListener( new ActionListener(){ 
        this.MENU_ARCHIVO.add(this.ITEM_INGRESO); 
    public void  actionPerformed(ActionEvent E) 
    {           this.MENU_ARCHIVO.add(this.ITEM_VER); 
      n=Integer.parseInt(T1.getText());          this.MENU_ARCHIVO.addSeparator(); 
      for (i=0;i<n;i++)          this.MENU_ARCHIVO.add(this.ITEM_SALIR); 
    {          this.MENU_BAR = new JMenuBar(); 
      for (j=0;j<n;j++)          this.MENU_BAR.add(this.MENU_ARCHIVO); 
      {   
        if (i==j)          this.MENU_BAR = new JMenuBar(); 
        {          this.MENU_BAR.add(this.MENU_ARCHIVO); 
          mat[i][j]=1;          this.setJMenuBar(this.MENU_BAR); 
        }              ITEM_INGRESO.addActionListener(new ActionListener()  
        else 
        { 
        if (i>j) 
          public void actionPerformed(ActionEvent ev) 
        { 
          mat[i][j]=2;             { 
        }                   ar.setSize(600,400); 
        else               ar.setLayout(null); 
        {               ar.setVisible(true);  
        mat[i][j]=3;              } 
        }                } 
      }            ); 
    }           
     repaint();          ITEM_VER.addActionListener(new ActionListener()  
    }          { 
    }            public void actionPerformed(ActionEvent ev) 
           { String no,pr,res="";   } 
             float su;  int leer_num_entero () throws IOException 
             int hab;   {  
             LEER_GRABAR LG = new LEER_GRABAR();    hab=arc.readInt(); 
             try  {    return (hab);   
           LG.abrir();   }  
             int i,j;  void grabar(String no, String pr, float su, int hab) throws IOException 
             long tam;    { 
             tam=LG.arc.length()/58; //58 bytes es la longitud del registro.     arc.writeChars(no); 
            for (i=0;i<tam;i++)     arc.writeChars(pr); 
              {     arc.writeFloat(su); 
              LG.arc.seek(58*i); // Coloca el puntero en el     arc.writeInt(hab); 
registro en base al valor de i    } 
             no=LG.leer_cad("",20);  } 
             pr=LG.leer_cad("",5);   
             su=LG.leer_num_real();  //CLASE INGRESO_DATOS 
             hab=LG.leer_num_entero();  import java.awt.event.*; 
             if (hab==1)  import java.awt.*; 
             {  import java.awt.Graphics; 
              res=res+"\nNombre = "+no+"\nProfesion =  import java.io.*; 
"+pr+"\nSueldo = "+su+"\n‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐";   import java.io.IOException; 
             }          import javax.swing.*; 
              }   
              JOptionPane.showMessageDialog(null,"\nLISTADO DE  class INGRESO_DATOS extends JFrame     
EMPLEADOS\n"+res);   { JLabel L1,L2,L3,L4; 
              LG.arc.close();    JTextField T_NO,T_PR,T_SU; 
             }    
             catch(IOException ex)    JButton GRABAR,VER,BORRAR; 
             {    String no,pr; 
              JOptionPane.showMessageDialog(null," ERROR ");      float su; 
             }      int sw=0,hab=1; 
          }    LEER_GRABAR LG = new LEER_GRABAR(); 
        }    public INGRESO_DATOS() throws IOException  
        );    {   super (" DATOS DE EMPLEADOS "); 
        //LEER_GRABAR LG = new LEER_GRABAR(); 
      L1=new JLabel("DATOS DEL EMPLEADOS"); 
    }       L2=new JLabel("Ingrese Nombre "); 
     public static void main(String[] ARGS) throws IOException      L3=new JLabel("Ingrese Profesion "); 
    {  //‐‐ HACEMOS QUE SE INICIALIZE NUESTRA VENTANA JFRAME      L4=new JLabel("Ingrese Sueldo "); 
         ARCHIVOS_AWT ARCH = new ARCHIVOS_AWT();      T_NO=new JTextField(); 
         //‐‐ HACEMOS QUE NUESTRA VENTANA SE VISIBLE      T_PR=new JTextField(); 
         ARCH.setVisible(true);      T_SU=new JTextField(); 
    }         
}      GRABAR=new JButton("GRABAR"); 
      VER=new JButton("VER"); 
//CLASE LLER_GRABAR      BORRAR=new JButton("BORRAR"); 
import java.io.*;       
class LEER_GRABAR {      add(L1);L1.setBounds(200,30,150,30); 
  RandomAccessFile  arc;      add(L2);L2.setBounds(80,80,150,30); 
  String no,pr,cad="                                                    ",op;        add(T_NO);T_NO.setBounds(250,80,150,30); 
  float  su;         
  int  hab=1;        add(L3);L3.setBounds(80,140,150,30); 
void abrir () throws IOException      add(T_PR);T_PR.setBounds(250,150,100,30); 
{       
  arc= new RandomAccessFile ("e:/ORURO.txt","rw");      add(L4);L4.setBounds(80,220,150,30); 
}          add(T_SU);T_SU.setBounds(250,220,100,30); 
String leer_cad (String no, int longitud ) throws IOException       
 { int i;      add(GRABAR);GRABAR.setBounds(80,300,100,30); 
   for (i=0;i<longitud;i++)      add(VER);VER.setBounds(190,300,100,30); 
   {      add(BORRAR);BORRAR.setBounds(310,300,100,30);   
     no=no+arc.readChar();     
   }      GRABAR.addActionListener(new ActionListener() 
   return (no);      { 
 }      public void actionPerformed( ActionEvent e)  
float leer_num_real () throws IOException      { 
 {         try{ 
  su=arc.readFloat();         LG.abrir(); 
  return (su);         no=(T_NO.getText()+"                    ").substring(0,20); 
       pr=(T_PR.getText()+"     ").substring(0,5);      public PROBLEM(){ 
       su=Float.parseFloat(T_SU.getText());          super("Facebook/Inicio"); 
                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
       LG.arc.seek(LG.arc.length());          setSize(400,300); 
               TT=new JLabel("M E N U"); 
       LG.grabar(no,pr,su,1);           T1 = new JLabel("Correo"); 
                T_NO.setText("");          T2=new JLabel("Password"); 
       T_PR.setText("");          N = new JTextField(10); 
       T_SU.setText("");          P = new JPasswordField(10); 
       T_NO.setFocusable(true);          OK= new JButton("INGRESAR"); 
       LG.arc.close();          EXIT=new JButton("SALIR"); 
      }       add(TT);TT.setBounds(180,30,130,10); 
      catch (IOException ex)          add(T1);T1.setBounds(80,80,150,30); 
      {          add(T2);T2.setBounds(80,150,100,30); 
        JOptionPane.showMessageDialog(null,"ERROR");          add(N);N.setBounds(150,80,100,30); 
      }             add(P);P.setBounds(150,150,100,30); 
    }              add(OK);OK.setBounds(80,200,100,30); 
  }            add(EXIT);EXIT.setBounds(205,200,100,30); 
  );      OK.addActionListener( new ActionListener(){ 
        public void  actionPerformed(ActionEvent EVENTO) { 
  VER.addActionListener(new ActionListener()     String Email,Pa; 
  {    Pattern Plantilla=null; 
    public void actionPerformed( ActionEvent e) //throws    Matcher Resultado=null; 
IOException    Plantilla=Pattern.compile("^([0‐9a‐zA‐Z]([_.w]*[0‐9a‐zA‐Z])*@([0‐
    {   9a‐zA‐Z][‐w]*[0‐9a‐zA‐Z].)+([a‐zA‐Z]{2,9}.)+[com]{2,3})$"); 
     try  {    Email=N.getText(); 
      LG.abrir();    Resultado=Plantilla.matcher(Email); 
        String res="";    if(Resultado.find()==false){ 
        int i,j;   
        long tam;    JOptionPane.showMessageDialog(null,"ERROR!\n"+"PROBLEM No 
        tam=LG.arc.length()/58; //58 bytes es la longitud del registro.  Valido"); 
       for (i=0;i<tam;i++)      }else{ 
        {        int pos=Email.indexOf("@"); 
        LG.arc.seek(58*i); // Coloca el puntero en el registro        String newEmail=Email.substring(0,pos); 
en base al valor de i     
       no=LG.leer_cad("",20);    JOptionPane.showMessageDialog(null,"Bienvenido"+"\nSu Correo 
       pr=LG.leer_cad("",5);  es: "+newEmail+" cuenta perteneciente a: gmail"); 
       su=LG.leer_num_real();        } 
       hab=LG.leer_num_entero();          } 
       if (hab==1)      } 
       {      ); 
         res=res+"\nNombre = "+no+"\nProfesion =      EXIT.addActionListener(new ActionListener(){ 
"+pr+"\nSueldo = "+su+"\n‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐";         public void actionPerformed(ActionEvent EVENTO){ 
       }                  System.exit(0); 
        }          } 
        JOptionPane.showMessageDialog(null,"\nLISTADO DE        } 
EMPLEADOS\n"+res);       ); 
        LG.arc.close();    } 
        }    public static void main(String[] ARGUMENTOS) 
        catch(IOException ex)    { 
        {          PROBLEM MI_INTERFAZ = new PROBLEM(); 
          JOptionPane.showMessageDialog(null," ERROR ");            MI_INTERFAZ.setLayout(null); 
        }          MI_INTERFAZ.setVisible(true); 
     }        } 
  }    } 
  ); 
  }    

4)import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 
import java.util.regex.Matcher; 
import java.util.regex.Pattern; 
public class PROBLEM extends JFrame { 
    public JLabel T1,TT,T2; 
    public JTextField N; 
    public JPasswordField P; 
    public JButton OK,EXIT;  

You might also like