sábado, 26 de noviembre de 2022

ESTADISTICO

 Programa que da promedio, valor máximo,valor mínimo, varianza y desviación estandar en java codigo.


El programas siguiente utilizan esta clase Leer para que funcione, esta clase debe estar en la misma carpeta donde este cada programa. El programas a continuación deben tener esta clase.

Crear este archivo java con el siguiente código

import java.io.*;


public class Leer{

public static String dato() {

String sdato = "";

try

{

// Definir un flujo de caracteres de entrada: flujoE

InputStreamReader isr = new InputStreamReader(System.in);

BufferedReader flujoE = new BufferedReader(isr);

// Leer. La entrada finaliza al pulsar la tecla Entrar

sdato = flujoE.readLine();

}

catch(IOException e) {

System.err.println("Error: " + e.getMessage());

}

return sdato; // devolver el dato tecleado

}

public static short datoShort() {

try

{

return Short.parseShort(dato());

}

catch(NumberFormatException e) {

return Short.MIN_VALUE; // valor más pequeño

}

}

public static int datoInt() {

try {

return Integer.parseInt(dato());

}

catch(NumberFormatException e) {

return Integer.MIN_VALUE; // valor más pequeño

}

}

public static long datoLong() {

try

{

return Long.parseLong(dato());

}

catch(NumberFormatException e) {

return Long.MIN_VALUE; // valor más pequeño

}

}

public static float datoFloat()

{

try

{

return Float.parseFloat(dato());

}

catch(NumberFormatException e)

{

return Float.NaN; // No es un Número; valor float.

}

}

public static double datoDouble() {

try {

return Double.parseDouble(dato());

}

catch(NumberFormatException e) {

return Double.NaN; // No es un Número; valor double.

}

}

}

_______Crear archivo principal llamado Estadistica con el siguiente codigo

import java.lang.Math.*;

public class Estadistica {

public static void main(String[] args) {

int nElementos, b, guarda, suma,dos=2;

double prom, sumaV, vza, v; //, dos=2.0;

System.out.println("Programacion Orientada a Objetos ");

System.out.println("Programa de Calculos Estadisticos: ");

System.out.println("Nombre: jose ");

System.out.println();

System.out.print("¿Cuantos elementos son?: ");

nElementos = Leer.datoInt();

int[] m = new int[nElementos];

int i = 0;

suma=0;

System.out.println("Introduce los datos a calcular.");

for (i = 0; i < nElementos; i++) {

System.out.print("Elemento[" + i + "] = ");

m[i] = Leer.datoInt();

suma=suma+m[i]; }

do {

b=0;

for(i=0;i<nElementos-1;i++) {

if (m[i] > m[i+1]) {

guarda=m[i];

m[i]=m[i+1];

m[i+1]=guarda;

b=1; } }

}while (b==1);

System.out.println();

System.out.print("Dado los datos: ");

for (i = 0; i < nElementos; i++)

System.out.print(m[i] + " ");

System.out.println();

prom=suma/nElementos;

System.out.println("Su promedio es: " + prom);

System.out.println("El valor minimo es: " + m[0]);

System.out.println("El valor maximo es: " + m[nElementos-1]);

sumaV=0;

for (i = 0; i < nElementos; i++) {

v=(Math.pow((m[i] -prom), dos));

sumaV=sumaV+ v; }

vza=sumaV / nElementos - 1;

System.out.println("Su Varianza es: " + vza);

System.out.println("Su DesvStd es: " + Math.sqrt(vza));

System.out.println("\n\nFin del proceso."); }

} --------------------Configuration: <Default>----------------

Programacion Orientada a Objetos

Programa de Calculos Estadisticos:

Nombre: jose

¿Cuantos elementos son?: 5

Introduce los datos a calcular.

Dado los datos: 3 4 4 5 6

Elemento[0] = 3

Elemento[1] = 4

Elemento[2] = 6

Su promedio es: 4.0

Elemento[3] = 5

El valor minimo es: 3

Elemento[4] = 4

El valor maximo es: 6

Su Varianza es: 0.19999999999999996

Su DesvStd es: 0.44721359549995787

Fin del proceso.

Process completed.




:




martes, 22 de noviembre de 2022

Factorizar en java

 El programas siguiente utilizan esta clase Leer para que funcione, esta clase debe estar en la misma carpeta donde este cada programa. El programas a continuación deben tener esta clase.

Crear este archivo java con el siguiente código:


import java.io.*;


public class Leer{

public static String dato() {

String sdato = "";

try

{

// Definir un flujo de caracteres de entrada: flujoE

InputStreamReader isr = new InputStreamReader(System.in);

BufferedReader flujoE = new BufferedReader(isr);

// Leer. La entrada finaliza al pulsar la tecla Entrar

sdato = flujoE.readLine();

}

catch(IOException e) {

System.err.println("Error: " + e.getMessage());

}

return sdato; // devolver el dato tecleado

}

public static short datoShort() {

try

{

return Short.parseShort(dato());

}

catch(NumberFormatException e) {

return Short.MIN_VALUE; // valor más pequeño

}

}

public static int datoInt() {

try {

return Integer.parseInt(dato());

}

catch(NumberFormatException e) {

return Integer.MIN_VALUE; // valor más pequeño

}

}

public static long datoLong() {

try

{

return Long.parseLong(dato());

}

catch(NumberFormatException e) {

return Long.MIN_VALUE; // valor más pequeño

}

}

public static float datoFloat()

{

try

{

return Float.parseFloat(dato());

}

catch(NumberFormatException e)

{

return Float.NaN; // No es un Número; valor float.

}

}

public static double datoDouble() {

try {

return Double.parseDouble(dato());

}

catch(NumberFormatException e) {

return Double.NaN; // No es un Número; valor double.

}

}

}

________,Creat nuevo archivo Factoresprimos___


public class Factoresprimos {   

    public static void main(String[] args) {

                long numero,r,d,prueba;

      System.out.println("Numero a factorizar "); numero = Leer.datoLong();

    d = 2;

    do    {

                r = numero / d;

                if ((numero%d)==0)             {

                               System.out.print(d +" x ");

                               numero= r;         } 

                else         {

                               d=d +1;                  }

    }          while (r>1);           

                System.out.print(" 1 ");

    }

                }


--------------------Configuration: <Default>--------------------


Programa corrido

Numero a factorizar

150

2 x 3 x 5 x 5 x  1

Process completed.


jueves, 17 de noviembre de 2022

PREGUNTAS AL AZAR DE TABLAS DE MULTIPLICAR

 El programas siguiente utilizan esta clase Leer para que funcione, esta clase debe estar en la misma carpeta donde este cada programa. El programas a continuación deben tener esta clase.

Crear este archivo java con el siguiente código:

import java.io.*;


public class Leer{

  public static String dato() {

    String sdato = "";

    try

    {

      // Definir un flujo de caracteres de entrada: flujoE

      InputStreamReader isr = new InputStreamReader(System.in);

      BufferedReader flujoE = new BufferedReader(isr);

      // Leer. La entrada finaliza al pulsar la tecla Entrar

      sdato = flujoE.readLine();

    }

    catch(IOException e) {

      System.err.println("Error: " + e.getMessage());

    }

    return sdato; // devolver el dato tecleado

  }

  

  public static short datoShort() {

    try

    {

      return Short.parseShort(dato());

    }

    catch(NumberFormatException e) {

      return Short.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static int datoInt() {

    try {

      return Integer.parseInt(dato());

    }

    catch(NumberFormatException e) {

      return Integer.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static long datoLong() {

    try

    {

      return Long.parseLong(dato());

    }

    catch(NumberFormatException e) {

      return Long.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static float datoFloat()

  {

    try

    {

      return Float.parseFloat(dato());

    }

    catch(NumberFormatException e)

    {

      return Float.NaN; // No es un Número; valor float.

    }

  }

  

  public static double datoDouble() {

    try {

      return Double.parseDouble(dato());

    }

    catch(NumberFormatException e) {

      return Double.NaN; // No es un Número; valor double.

    }

  }

}

___________Crear nuevo archivo java con nombre preguntasalazardetablasdemultiplicar____________


import java.io.PrintStream;


public class preguntasalazardetablasdemultiplicar {


  public static void main(String[] args)

  {

                int r=0, resp=0, n1=0, n2=0, b=0, m=0;

   double cal;

    do

    { 

                n1=(int)(Math.random()*10)+1;

               

                n2=(int)(Math.random()*10)+1;

               

                System.out.printf("\n\n\t¿Cuanto es %2d por %2d?<0>Salir ",n1,n2);

                resp=Leer.datoInt();           

                 if (resp > 0 );

                 {

                                r=n1*n2;

                                if(r==resp)

                                {

                                               b=b+1;

        System.out.printf("\n\n\t CORRECTO!!Llevas %2d BUENAS Y %2d MALAS",b,m);

                                              

      }     

   else

                {

                               m=m+1;

                System.out.printf("\n\n\t INCORRECTO!!Llevas %2d BUENAS Y %2d MALAS",b,m);

                }                                                            

                }

    }while(resp!=0);

   

    cal=b*100/(b+m);

   

                System.out.printf("\n\n\t CALIFICACION = %.2f",cal);

  }

}


--------------------Configuration: <Default>--------------------

    ¿Cuanto es 10 por 9?<0>Salir 90



     CORRECTO!!Llevas 1 BUENAS Y 0 MALAS


    ¿Cuanto es 1 por 8?<0>Salir 0







viernes, 11 de noviembre de 2022

Sacar areas de triangulo, cuadrado y círculo en java con ciclos

 El programas siguiente utilizan esta clase Leer para que funcione, esta clase debe estar en la misma carpeta donde este cada programa. El programas a continuación deben tener esta clase.

Crear este archivo java con el siguiente código:

import java.io.*;


public class Leer{

  public static String dato() {

    String sdato = "";

    try

    {

      // Definir un flujo de caracteres de entrada: flujoE

      InputStreamReader isr = new InputStreamReader(System.in);

      BufferedReader flujoE = new BufferedReader(isr);

      // Leer. La entrada finaliza al pulsar la tecla Entrar

      sdato = flujoE.readLine();

    }

    catch(IOException e) {

      System.err.println("Error: " + e.getMessage());

    }

    return sdato; // devolver el dato tecleado

  }

  

  public static short datoShort() {

    try

    {

      return Short.parseShort(dato());

    }

    catch(NumberFormatException e) {

      return Short.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static int datoInt() {

    try {

      return Integer.parseInt(dato());

    }

    catch(NumberFormatException e) {

      return Integer.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static long datoLong() {

    try

    {

      return Long.parseLong(dato());

    }

    catch(NumberFormatException e) {

      return Long.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static float datoFloat()

  {

    try

    {

      return Float.parseFloat(dato());

    }

    catch(NumberFormatException e)

    {

      return Float.NaN; // No es un Número; valor float.

    }

  }

  

  public static double datoDouble() {

    try {

      return Double.parseDouble(dato());

    }

    catch(NumberFormatException e) {

      return Double.NaN; // No es un Número; valor double.

    }

  }

}

_________Creamos el segundo archivo java llamado Areas_______

import java.io.PrintStream;

public class Areas {

    public static void main(String[] args)

  {

    int opcion;

    double base, altura, radio, area;

    do

    {         

     System.out.printf("Calculo de areas de figuras geometricas");

     System.out.printf("\n\t 1)AREA DEL CIRCULO");

     System.out.printf("\n\t 2)AREA DEL RECTANGULO");  

     System.out.printf("\n\t 3)AREA DEL TRIANGULO"); 

     System.out.printf("\n\n\t ¿ESCOGE EL AREA A CALCULAR? <0>Salir ");         

     opcion = Leer.datoInt();               

     if (opcion > 0 && opcion<4) {

                if (opcion==1)

        {

            System.out.printf("\n\n\t ¿VALOR DEL RADIO? ");         

            radio = Leer.datoFloat();       

                area=radio*3.1416;

                System.out.printf("\n El Area es = %.2f ",area);

                System.out.printf("\n\n"); }

                if (opcion==2) {

            System.out.printf("\n\n\t ¿VALOR DE LA BASE? ");       

            base = Leer.datoFloat();        

                System.out.printf("\n\n\t ¿VALOR DE LA ALTURA? ");              

            altura = Leer.datoFloat();

                area=base * altura;

                System.out.printf("\n El Area es = %.2f ",area);

                System.out.printf("\n\n"); }

        if (opcion==3) {

            System.out.printf("\n\n\t ¿VALOR DE LA BASE? ");       

            base = Leer.datoFloat();        

                System.out.printf("\n\n\t ¿VALOR DE LA ALTURA? ");              

            altura = Leer.datoFloat();

                area=(base * altura)/2;

                System.out.printf("\n El Area es = %.2f ",area);

        System.out.printf("\nHecho por jose ");

                                               System.out.printf("\n\n"); }                        

      }     

    }while(opcion!=0); }      

      }

--------------------Configuration: <Default>--------------------

Calculo de areas de figuras geometricas

     1)AREA DEL CIRCULO

     2)AREA DEL RECTANGULO

     3)AREA DEL TRIANGULO

     ¿ESCOGE EL AREA A CALCULAR? <0>Salir 2

     ¿VALOR DE LA BASE? 1

¿VALOR DE LA ALTURA? 1

 El Area es = 1.00






miércoles, 9 de noviembre de 2022

Factorial en java

 Los programas siguientes utilizan esta clase Leer para que funcione, esta clase debe estar en la misma carpeta donde este cada programa. Todos los programas a continuación deben tener esta clase.

Crear este archivo java con el siguiente código:


import java.io.*;


public class Leer{

  public static String dato() {

    String sdato = "";

    try

    {

      // Definir un flujo de caracteres de entrada: flujoE

      InputStreamReader isr = new InputStreamReader(System.in);

      BufferedReader flujoE = new BufferedReader(isr);

      // Leer. La entrada finaliza al pulsar la tecla Entrar

      sdato = flujoE.readLine();

    }

    catch(IOException e) {

      System.err.println("Error: " + e.getMessage());

    }

    return sdato; // devolver el dato tecleado

  }

  

  public static short datoShort() {

    try

    {

      return Short.parseShort(dato());

    }

    catch(NumberFormatException e) {

      return Short.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static int datoInt() {

    try {

      return Integer.parseInt(dato());

    }

    catch(NumberFormatException e) {

      return Integer.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static long datoLong() {

    try

    {

      return Long.parseLong(dato());

    }

    catch(NumberFormatException e) {

      return Long.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static float datoFloat()

  {

    try

    {

      return Float.parseFloat(dato());

    }

    catch(NumberFormatException e)

    {

      return Float.NaN; // No es un Número; valor float.

    }

  }

  

  public static double datoDouble() {

    try {

      return Double.parseDouble(dato());

    }

    catch(NumberFormatException e) {

      return Double.NaN; // No es un Número; valor double.

    }

  }

}

_________________se crea otro archivo con la clase principal____

public class Factorial

{

  // Cálculo del factorial de un número

  long fact;

  public static long factorial(int n)

  {

    long fac;

    if (n == 0)

      return 1;

    else

      fac=1;

      do {

       fac=fac*n;

       n=n-1;

      }while (n>1);

      return fac;   

  }


  public static void main(String[] args)

  {

    int numero=0;

    long fact;

    do

    {

      System.out.print("¿Numero a calcular su factorial? ");

      numero = Leer.datoInt();

    }

    while (numero < 0 || numero > 25);

    fact = factorial(numero);

    System.out.println("\nPractica ");

    System.out.println("Calculo del factorial de un numero ");

    System.out.println("Realizado por: jose");

    System.out.println("\nEl factorial de " + numero + " es: " + fact);

  }

}


--------------------Configuration: <Default>--------------------

¿Numero a calcular su factorial? 8


Practica 

Calculo del factorial de un numero

Realizado por: jose


El factorial de 8 es: 40320

Process completed.





domingo, 6 de noviembre de 2022

CONVERTIR A DOLARES EN JAVA

 

Los programas siguientes utilizan esta clase Leer para que funcione, esta clase debe estar en la misma carpeta donde este cada programa. Todos los programas a continuación deben tener esta clase.

Crear este archivo java con el siguiente código:


import java.io.*;


public class Leer{

public static String dato() {

String sdato = "";

try

{

// Definir un flujo de caracteres de entrada: flujoE

InputStreamReader isr = new InputStreamReader(System.in);

BufferedReader flujoE = new BufferedReader(isr);

// Leer. La entrada finaliza al pulsar la tecla Entrar

sdato = flujoE.readLine();

}

catch(IOException e) {

System.err.println("Error: " + e.getMessage());

}

return sdato; // devolver el dato tecleado

}

public static short datoShort() {

try

{

return Short.parseShort(dato());

}

catch(NumberFormatException e) {

return Short.MIN_VALUE; // valor más pequeño

}

}

public static int datoInt() {

try {

return Integer.parseInt(dato());

}

catch(NumberFormatException e) {

return Integer.MIN_VALUE; // valor más pequeño

}

}

public static long datoLong() {

try

{

return Long.parseLong(dato());

}

catch(NumberFormatException e) {

return Long.MIN_VALUE; // valor más pequeño

}

}

public static float datoFloat()

{

try

{

return Float.parseFloat(dato());

}

catch(NumberFormatException e)

{

return Float.NaN; // No es un Número; valor float.

}

}

public static double datoDouble() {

try {

return Double.parseDouble(dato());

}

catch(NumberFormatException e) {

return Double.NaN; // No es un Número; valor double.

}

}

}

________El siguiente archivo es la clase principal __________

public class Cambiodemoneda{

                public static void main (String[]args){

                               int resp;

                               float cant;

                               double resultado;

                               System.out.println("CANTIDAD A CONVERTIR?");cant=Leer.datoFloat();

                               System.out.println("\n  1)CONVERTIR A PESOS");

                               System.out.println("  2)CONVERTIR A DOLARES");

                               System.out.println("  Escoje la opcion ");resp=Leer.datoInt();

                               if(resp==1)

                               {

                                               resultado=cant*20.00;

                               }

                               else

                               {

                                               resultado=cant/20.00;

                               }

                               System.out.println(".\n\nEL RESULTADO ES "+resultado);

                }

    }



--------------------Configuration: <Default>--------------------

CANTIDAD A CONVERTIR?

2


  1)CONVERTIR A PESOS

  2)CONVERTIR A DOLARES

  Escoje la opcion

1

.

EL RESULTADO ES 40.0

Process completed.

miércoles, 2 de noviembre de 2022

PRODUCTOS DE DOS NÚMEROS

 Los programas siguientes utilizan esta clase Leer para que funcione, esta clase debe estar en la misma carpeta donde este cada programa. Todos los programas a continuación deben tener esta clase.

Crear este archivo java con el siguiente código

import java.io.*;


public class Leer{

  public static String dato() {

    String sdato = "";

    try

    {

      // Definir un flujo de caracteres de entrada: flujoE

      InputStreamReader isr = new InputStreamReader(System.in);

      BufferedReader flujoE = new BufferedReader(isr);

      // Leer. La entrada finaliza al pulsar la tecla Entrar

      sdato = flujoE.readLine();

    }

    catch(IOException e) {

      System.err.println("Error: " + e.getMessage());

    }

    return sdato; // devolver el dato tecleado

  }

  

  public static short datoShort() {

    try

    {

      return Short.parseShort(dato());

    }

    catch(NumberFormatException e) {

      return Short.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static int datoInt() {

    try {

      return Integer.parseInt(dato());

    }

    catch(NumberFormatException e) {

      return Integer.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static long datoLong() {

    try

    {

      return Long.parseLong(dato());

    }

    catch(NumberFormatException e) {

      return Long.MIN_VALUE; // valor más pequeño

    }

  }

  

  public static float datoFloat()

  {

    try

    {

      return Float.parseFloat(dato());

    }

    catch(NumberFormatException e)

    {

      return Float.NaN; // No es un Número; valor float.

    }

  }

  

  public static double datoDouble() {

    try {

      return Double.parseDouble(dato());

    }

    catch(NumberFormatException e) {

      return Double.NaN; // No es un Número; valor double.

    }

  }

}

__________________

public class Producto {


    public static void main(String[] args) {

                int valor1=0;

                int valor2=0;

                int resultado=0;



                System.out.println("Dame el primer numero =>"); valor1 = Leer.datoInt();

                               System.out.println("Dame el segundo numero =>"); valor2 = Leer.datoInt();

                               resultado= valor1 * valor2;

                               System.out.println();

                               System.out.println("El resultado es =" + resultado);

    }

}


_____________________

Dame el primer numero =>

5

Dame el segundo numero =>

8


El resultado es =40

Process completed.




:


jueves, 13 de octubre de 2022

domingo, 10 de diciembre de 2017

Crear una Linea en JAVA Netbens "Plano cartesiano"


Crear una Linea en JAVA Netbens "Plano cartesiano"













CODIGO DEL PROGRAMA









-

import java.awt.Graphics;
import javax.swing.JPanel;


public class Linea extends javax.swing.JFrame {
public class Dibujo2D extends JPanel{
public Dibujo2D(){

}
@Override
protected void paintComponent(Graphics g){
int x1,x2, y1, y2;
x1=(int)Double.parseDouble(X1.getText());
y1=(int)Double.parseDouble(Y1.getText());
x2=(int)Double.parseDouble(X2.getText());
y2=(int)Double.parseDouble(Y2.getText());
g.drawLine(x1, y1, x2, y2);
}
}
 

    public Linea() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                       
    private void initComponents() {

        panel11 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        X1 = new javax.swing.JTextField();
        X2 = new javax.swing.JTextField();
        Y1 = new javax.swing.JTextField();
        Y2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        panel11.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0)));

        javax.swing.GroupLayout panel11Layout = new javax.swing.GroupLayout(panel11);
        panel11.setLayout(panel11Layout);
        panel11Layout.setHorizontalGroup(
            panel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 198, Short.MAX_VALUE)
        );
        panel11Layout.setVerticalGroup(
            panel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 188, Short.MAX_VALUE)
        );

        jLabel1.setText("x1");

        jLabel2.setText("x2");

        jLabel3.setText("y1");

        jLabel4.setText("y2");

        jButton1.setText("Dibuja");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        X2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                X2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(X1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Y1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(Y2))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(X2))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 41, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(X1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(X2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(45, 45, 45)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(Y1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Y2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(41, 41, 41)
                        .addComponent(jButton1)))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                     

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                       
        dibujar();// TODO add your handling code here:
    }                                     

    private void X2ActionPerformed(java.awt.event.ActionEvent evt) {                                 
        // TODO add your handling code here:
    }                               

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Linea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Linea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Linea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Linea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Linea().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                   
    private javax.swing.JTextField X1;
    private javax.swing.JTextField X2;
    private javax.swing.JTextField Y1;
    private javax.swing.JTextField Y2;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel panel11;
    // End of variables declaration                 
private void dibujar(){
Linea.Dibujo2D dibuj=new Linea.Dibujo2D() ;
dibuj.setBounds(50,100,1000,1000);
dibuj.setOpaque(false);
panel11.add(dibuj);
panel11.repaint();
}
}