jueves, 22 de diciembre de 2016

Procesamiento de imagenes en Java


Que tal amigos en esta ocasión les quiero compartir un programa que hice en java en el cual consisten el el procesamiento e imágenes en el cual la cual aplica varios filtros , rota la imagen a 90, permite abrir y guardar varios formatos de imágenes y los cambios que se apliquen a la imagen se puede guardar con esos cambios sin ningún problema. Les dejo algunas imágenes y el código fuente para que lo mejoren y dejen sus comentarios si nos es muchas molestia.








Clase transformar imagen que permite rotar la imagen a 90 grados

       
           package program;

/**
 * importando las librerias
 */
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;

/**
 *
 * @author Francisco Aguilar
 * @author maricarmen etc.
 */
public class TransformarImagen {

    /**
     * declaracion de variables globales
     */
    //se crea un objeto 
    AffineTransform trans;

    int alturaImagen;
    int anchoImagen;
    double grados;

    /**
     * metodo que devuelve la altura y la anchura de la imagen
     *
     * @param alturaImagen variable de tipo entero
     * @param anchuraImagen variable de tipo entero
     */
    public TransformarImagen(int alturaImagen, int anchuraImagen) {
        trans = new AffineTransform();
        this.alturaImagen = alturaImagen;
        this.anchoImagen = anchuraImagen;
    }

    /**
     * metodo que devuelve los grados
     *
     * @param grados variable de tipo double
     */
    public void rotar(double grados) {
        this.grados = grados;
        //calcula el angulo  y el punto de rotacion 
        trans.rotate(Math.toRadians(grados), anchoImagen / 2.0, alturaImagen / 2.0);
    }

    /**
     * metodo que devuelve el objeto AffineTransform llamado trans
     *
     * @return
     */
    public AffineTransform Trans() {
        return trans;
    }

    /**
     * metodo que calcula la translacion de la imagen
     */
    public void Traslacionfinal() {
        /*
         * variable de tipo point2D
         * Point2Dclase define un punto que representa una ubicación en el (x,y)espacio de coordenadas.
         */
        Point2D puntoA, puntoB;
        //calcula el ṕunto A
        puntoA = hallarPtoATraslacion();
        puntoB = trans.transform(puntoA, null);
        //variable de tipo double
        double ytrans = puntoB.getY();

        puntoA = hallarPtoBTraslacion();
        puntoB = trans.transform(puntoA, null);
        //        variable de tipo double
        double xtrans = puntoB.getX();
        //se crea un objeto nuego de tipo affine
        AffineTransform a = new AffineTransform();
        // el objeto obtiene las coordenadas de X y Y
        a.translate(-xtrans, -ytrans);
        trans.preConcatenate(a);
    }

    /**
     * metodo que obtiene el punto A
     *
     * @return devuelve un objeto de tipo point2D
     */
    private Point2D hallarPtoATraslacion() {
        Point2D puntoA;
        if (grados >= 0 && grados <= 90) {
            puntoA = new Point2D.Double(0.0, 0.0);
        } else if (grados > 90 && grados <= 180) {
            puntoA = new Point2D.Double(0.0, alturaImagen);
        } else if (grados > 180 && grados <= 270) {
            puntoA = new Point2D.Double(anchoImagen, alturaImagen);
        } else {
            puntoA = new Point2D.Double(anchoImagen, 0.0);
        }
        return puntoA;
    }

    /**
     * metodo que obtiene el punto B
     *
     * @return devuelve un Objeto de tipo point2D
     */
    private Point2D hallarPtoBTraslacion() {
        Point2D puntoB;
        if (grados >= 0 && grados <= 90) {
            puntoB = new Point2D.Double(0.0, alturaImagen);
        } else if (grados > 90 && grados <= 180) {
            puntoB = new Point2D.Double(anchoImagen, alturaImagen);
        } else if (grados > 180 && grados <= 270) {
            puntoB = new Point2D.Double(anchoImagen, 0.0);
        } else {
            puntoB = new Point2D.Double(0.0, 0.0);
        }
        return puntoB;
    }
}

       
 


Clase que permite guardar el recorte de la  imagen

       
        package program;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JLabel;
import static program.design.mos_msj;


public class RecortarImagen extends JLabel implements MouseMotionListener, MouseListener {

    /**
     *  variables generales usadas dentro de la clase
     */
    Image Original;
    BufferedImage Imagen, ImagenR;
    Graphics2D g2;
    Graphics2D g2D;
    boolean con_foto = false;

    /**
     * coordenadas y tamaño del recorte
     */
    float X = 30;
    float Y = 30;
    float clipAncho = 200;
    float clipAlto = 200;

    /**
     * define el tamaño del recorte
     * 
     */
    public void TamañoRecorte(float ancho) {
        this.clipAncho = ancho;
        clipAlto = ancho;
        repaint();
    }

    /**
     * variables para elmovimiento
     */
    private int Pos_Marca_new_X = 0;
    private int Pos_Marca_new_Y = 0;
    private int Pos_Marca_X = 0;
    private int Pos_Marca_Y = 0;
    private int Dist_X = 0;
    private int Dist_Y = 0;

    private Color color_linea = new Color(100, 0, 0);
    private float grosor_linea = 2f;

    public RecortarImagen(BufferedImage f) {
        this.Original = f;
        this.setSize(f.getWidth(), f.getHeight());
        this.setVisible(true);
        this.con_foto = true;
        //eventos del raton
        addMouseMotionListener(this);
        addMouseListener(this);
    }

    @Override
    protected void paintComponent(Graphics g) {

        g2 = (Graphics2D) g;
        if (this.con_foto) {
            //se crea un lienzo del tamaño de la foto
            Imagen = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB);
            g2D = Imagen.createGraphics();
            g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            //se añade la foto grande original
            g2D.drawImage(Original, 0, 0, Original.getWidth(this), Original.getHeight(this), this);
            //se crea un recuadro que sirve de referencia para el recorte
            g2D.setStroke(new BasicStroke(this.grosor_linea));
            g2D.setColor(color_linea);
            Rectangle2D r2 = new Rectangle2D.Float(X, Y, clipAncho, clipAlto);
            g2D.draw(r2);
            //se dibuja todo
            g2.drawImage(Imagen, 0, 0, this);

        }

    }

    //se extrae una subimagen de la imagen original del tamaño del recuadro rojo
    private void recortar() {
        ImagenR = ((BufferedImage) Original).getSubimage((int) X, (int) Y, (int) clipAncho, (int) clipAlto);
    }

    //metodo que guarda la imagen en disco en formato JPG
    public void guardar_imagen(File f, String formato) {
        recortar();
        try {
            //se escribe en disco            
            ImageIO.write(ImagenR, formato, f);
           /*Mensaje*/
           mos_msj("Se guardó correctamente");
        } catch (IOException e) {
            mos_msj("No se pudo guardar");
        }
    }

    /* metodos del mouse para el cuadro de recorte */
    public void mouseDragged(MouseEvent e) {
        //nuevas coordenadas
        Pos_Marca_new_X = (int) e.getPoint().getX();
        Pos_Marca_new_Y = (int) e.getPoint().getY();

        //se obtiene distancia del movimiento
        Dist_X = Pos_Marca_new_X - Pos_Marca_X;
        Dist_Y = Pos_Marca_new_Y - Pos_Marca_Y;

        //se coloca la nueva posicion
        X = X + Dist_X;
        Y = Y + Dist_Y;

        //evita que se revace los limites de la imagen
        if (X < 0) {
            X = 0;
        }
        if (Y < 0) {
            Y = 0;
        }
        if ((X + this.clipAncho) > this.getWidth()) {
            X = this.getWidth() - this.clipAncho;
        }
        if ((Y + this.clipAlto) > this.getHeight()) {
            Y = this.getHeight() - this.clipAlto;
        }

        Pos_Marca_X = Pos_Marca_X + Dist_X;
        Pos_Marca_Y = Pos_Marca_Y + Dist_Y;
        this.repaint();
    }

    public void mouseMoved(MouseEvent e) {

    }

    public void mouseClicked(MouseEvent e) {

    }

    public void mousePressed(MouseEvent e) {
        Pos_Marca_X = (int) e.getPoint().getX();
        Pos_Marca_Y = (int) e.getPoint().getY();
    }

    public void mouseReleased(MouseEvent e) {

    }

    public void mouseEntered(MouseEvent e) {

    }

    public void mouseExited(MouseEvent e) {

    }

}

       
 

Formulario principal en donde se abre las imagenes, aqui tambien estan algunos metodos

       
          package program;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.color.ColorSpace;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ByteLookupTable;
import java.awt.image.ColorConvertOp;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import java.awt.image.LookupOp;
import java.awt.image.LookupTable;
import java.awt.image.RescaleOp;
import java.awt.image.ShortLookupTable;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import static program.design.mos_msj;

public class imagen extends javax.swing.JFrame implements ActionListener {

    /**
     *  crea un un objeto de otra clase llada RecortarImagen
     */
    RecortarImagen recorte;

    /**
     * variables globales de tipó bufferedImagen y variables de tipo entero.
     *
     */
    private BufferedImage imagen, imagen_filtro, copia;
    int w, h, opcion, grados = 0;
    double x1, y1;

    /**
     * constructor de la clase
     */
    public imagen() {
        initComponents();
        setTitle("Area Imagen");
    }

    /**
     * metodo que devuelve un valor de tipo entero.
     *
     * @param efecto
     */
    public void r_efecto(int efecto) {
        opcion = efecto;
    }

    /**
     * metodo set que recibe dos valores de tipo double
     *
     * @param x
     * @param y
     */
    public void tam(double x, double y) {
        x1 = x;
        y1 = y;
    }

    /**
     * arreglo estatico de tipo flotante para filtro sharpening
     */
    public static final float[] SHARPEN3x3 = {
        0.f, -1.f, 0.f,
        -1.f, 5.f, -1.f,
        0.f, -1.f, 0.f
    };
    /**
     * arreglo estatico de tipo flotante para filtro detectar bordes
     */
    public static final float[] valores = {
        0.0f, -1.0f, 0.0f,
        -1.0f, 4.0f, -1.0f,
        0.0f, -1.0f, 0.0f
    };
    /**
     * arreglo estatico de tipo flotante para filtro low-pass
     */
    public static final float[] BLUR3x3 = {
        0.1f, 0.1f, 0.1f,
        0.1f, 0.2f, 0.1f,
        0.1f, 0.1f, 0.1f
    };
    //variable estatica tipo short
    public static final short col = 256;
    /**
     * arreglo estatico de tipo flotante para filtro negativo
     */
    public static final short[] coloresInvertidos = new short[col];

    static {
        for (int i = 0; i < col; i++) {
            coloresInvertidos[i] = (short) ((col - 1) - i);
        }
    }
    /**
     * Arreglo para el eliminar el color rojo
     */
    static final short[] coloresSinInvertir_r = new short[col];
    static final short[] cr_cero = new short[col];

    /*Guarda azul*/
    static short[][] elimina_rojo = {
        cr_cero, coloresSinInvertir_r, coloresSinInvertir_r};

    static {
        for (int i = 0; i < col; i++) {
            coloresSinInvertir_r[i] = (short) (i);
            coloresInvertidos[i] = (short) ((col - 1) - i);
            cr_cero[i] = 0;
        }
    }

    /*Guarda rojo*/
    static short[][] elimina_azul = {
        coloresSinInvertir_r, cr_cero, coloresSinInvertir_r};

    /*Guarda Amarillo*/
    static short[][] elimina_verde = {
        coloresSinInvertir_r, coloresSinInvertir_r, cr_cero};


    /*Para ajuste de brillo*/
    public static float p = (float) 2;
    static final float[] componentes = {p, p, p};
    static final float[] desplazamientos = {0.0f, 0.0f, 0.0f};

    /**
     * Metodo para abrir la imagen con JfileChooser
     *
     * @return exportPath variable de tipo cadena
     */
    public String agregar_imagen() {

        JFileChooser file = new JFileChooser();//Objeto de tipo File Chosser para seleccionar la ruta de la imagen
        File ruta = null;// como la ruta cambia de direccion, la inicializo a null como contador

        int estado = file.showOpenDialog(null);//guardo el estado en un entero
        if (estado == JFileChooser.APPROVE_OPTION) {//Si presiono en aceptar entonces se procesa a guardar la direccion

            ruta = file.getSelectedFile();
            String exportPath = file.getSelectedFile().getAbsolutePath();
            System.out.println(exportPath);
            return exportPath;
        }
        return null;
    }//fin deñ metodo cargar imagen

    /**
     * metodo que carga la imagen al bufferedImagen ajustando el tamaño de la
     * ventana
     *
     */
    public void cargaImag() {
        try {
            String url = agregar_imagen();
            imagen = ImageIO.read(new File(url));

            w = imagen.getWidth(); // ancho
            h = imagen.getHeight(); //alto
            if (imagen.getType() != BufferedImage.TYPE_INT_RGB) {
                BufferedImage bi2
                        = new BufferedImage(imagen.getWidth(), imagen.getHeight(), BufferedImage.TYPE_INT_RGB);
                Graphics big = bi2.getGraphics();
                big.drawImage(imagen, 0, 0, w, h, null);
                imagen_filtro = copia = imagen = bi2;
                mos_msj("Imagen cargada correctamente");
            }
            this.setSize(w, h);
        } catch (IOException e) {
            mos_msj("La imagen no se pudo leer");
            //System.exit(1);
        }
    } //fin del metodo cargarimagen

    /**
     * metodo que aplica filtros sobre la imagen original
     */
    public void agrega_filtro() {
        //declaracion de un buffered image
        BufferedImageOp destino = null;
        //estructura de seleccion switch
        switch (opcion) {
            case 9:
                /* Negativo */
                LookupTable lt = new ShortLookupTable(0, coloresInvertidos);
                destino = new LookupOp(lt, null);
                break;
            case 10:
                /*Detecta bordes*/
                float[] data1 = valores;
                destino = new ConvolveOp(new Kernel(3, 3, data1), ConvolveOp.EDGE_NO_OP, null);
                break;
            case 11:
                /* aumenta escala usando transform Op e interpolacion BICUBIC */
                AffineTransform at = AffineTransform.getScaleInstance(x1, y1);
                destino = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
                break;
            case 12:
            /* low pass filter */
            case 13:
                /* sharpen */
                float[] data = (opcion == 12) ? BLUR3x3 : SHARPEN3x3;
                destino = new ConvolveOp(new Kernel(3, 3, data), ConvolveOp.EDGE_NO_OP, null);
                break;
            case 14:
                /* lookup */
                byte lut[] = new byte[256];
                for (int j = 0; j < 256; j++) {
                    lut[j] = (byte) (256 - j);
                }
                ByteLookupTable blut = new ByteLookupTable(0, lut);
                destino = new LookupOp(blut, null);
                break;
            default:
        }
        try {
            imagen_filtro = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            destino.filter(imagen, imagen_filtro);
        } catch (Exception e) {
            System.out.print("");
        }

    } // fin metodo agrega filtro

    /**
     * metetodo que pinta sobre el panel
     *
     * @param g variable de tipo graphics
     */
    @Override
    public void paint(Graphics g) {
        //limpia contenido de contexto grafico
        g.clearRect(0, 0, this.getWidth(), this.getHeight());
        switch (opcion) {
            case 0:
                /*Imagen Original*/
                imagen_filtro = imagen;
                g.drawImage(imagen, 0, 0, null);
                break;
            case 1:
                /*Azul*/
                LookupTable azul = new ShortLookupTable(0, elimina_rojo);
                LookupOp az = new LookupOp(azul, null);
                imagen_filtro = az.filter(imagen, null);
                g.drawImage(imagen_filtro, 0, 0, null);
                break;
            case 2:
                /*Brillo*/
                RescaleOp rop2 = new RescaleOp(componentes, desplazamientos, null);
                imagen_filtro = rop2.filter(imagen, null);
                g.drawImage(imagen_filtro, 0, 0, null);
                break;
            case 3:
                /*Gris*/
                ColorConvertOp ccop = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
                imagen_filtro = ccop.filter(imagen, null);
                g.drawImage(imagen_filtro, 0, 0, null);
                break;
            case 4:
                /*Girar*/
                double r = Math.toRadians(grados); //se convierte a radianes lo grados
                AffineTransform a = new AffineTransform();
                a.rotate(r, this.getWidth() / 2, this.getHeight() / 2); //se asigna el angulo y centro de rotacion
                ((Graphics2D) g).setTransform(a);
                g.drawImage(imagen_filtro, 0, 0, this);
                break;
            case 5:
                /*Amarillo*/
                LookupTable amarillo = new ShortLookupTable(0, elimina_verde);
                LookupOp ye = new LookupOp(amarillo, null);
                imagen_filtro = ye.filter(imagen, null);
                g.drawImage(imagen_filtro, 0, 0, null);
                break;
            case 6:
                /*Filtro Rojo*/
                LookupTable rojo = new ShortLookupTable(0, elimina_azul);
                LookupOp ro = new LookupOp(rojo, null);
                imagen_filtro = ro.filter(imagen, null);
                g.drawImage(imagen_filtro, 0, 0, null);
                break;
            case 7:
                /*Efecto Espejo*/
                AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);
                tx.translate(-copia.getWidth(null), 0);
                AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
                imagen_filtro = op.filter(imagen_filtro, null);
                g.drawImage(imagen_filtro, 0, 0, null);
                break;
            default:
                //apĺica los filtros  que estan dentro del metodo agrega_filtro
                agrega_filtro();
                g.drawImage(imagen_filtro, 0, 0, null);
                break;
        }
    }// fin de paint

    /**
     * este metodo rota la imagen recibibiendo los grados de tipo double
     * llamando los metodos rotar y translacion final de la clase transformar
     * imagen
     *
     * @param grados variable de tipo double
     * @return devuelve un objeto de tipo buffered imagen
     */
    public BufferedImage rotacionImagen(double grados) {
        //crea un objeto  transformar de la clase transformar imagen
        TransformarImagen Transformar = new TransformarImagen(imagen.getHeight(), imagen.getWidth());
        //llama al metodo rotar
        Transformar.rotar(grados);
        //llama al metodo tranlacion final
        Transformar.Traslacionfinal();
        //se crea un objeto de la clase AffineTransformOp
        AffineTransformOp nuevo = new AffineTransformOp(Transformar.Trans(), AffineTransformOp.TYPE_BILINEAR);
        /*
         createCompatibleDestImage(BufferedImage src, ColorModel destCM)
                Crea una imagen de destino puesto a cero con el tamaño y número de bandas correcta.
         */
        imagen_filtro = nuevo.createCompatibleDestImage(imagen, imagen.getColorModel());
        /*
            filter(BufferedImage src, BufferedImage dest)
            Realiza una operación con una sola entrada / salida única en una BufferedImage.
         */
        imagen = nuevo.filter(imagen, imagen_filtro);
        //retorna imagen
        return imagen;
    }

    /**
     * metodo set que actualiza el frame
     */
    public void actualiza_frame() {
        this.setSize(imagen.getWidth(), imagen.getHeight());
    }

    /**
     * metodo que modifica los grados a girar
     *
     * @param grados variable de tipo entero
     */
    public void Grados(int grados) {
        this.grados = grados;
        repaint();
    }

    /**
     * metodo que devuelve el objeto imagen filtro
     *
     * @return imagen_filtro variable de tipo bufferedImage
     */
    public BufferedImage getBi() {
        return imagen_filtro;
    }
/**
 * metodo que recorta una parte de la imagen
 */
    public void RecortarImagen() {
        recorte = new RecortarImagen(imagen_filtro);
        this.label.removeAll();
        this.label.add(recorte);

        recorte.TamañoRecorte(design.TAncho.getValue());
        design.TAncho.setMaximum(imagen_filtro.getHeight());

        this.label.repaint();

    }
/**
 * metodo que guarda el recorte 
 */
    public void GuardarRecorte() {
        String formato = (String) design.Formatos.getSelectedItem();
        File saveFile = new File("Recorte." + formato);
        JFileChooser chooser = new JFileChooser();
        chooser.setSelectedFile(saveFile);
        int rFormato = chooser.showSaveDialog(design.Formatos);
        if (rFormato == JFileChooser.APPROVE_OPTION) {
            saveFile = chooser.getSelectedFile();
            recorte.guardar_imagen(saveFile, formato);
        }
    }

    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        label = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        label.setText("jLabel1");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
        );

        pack();
    }// //GEN-END:initComponents

    @Override
    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel label;
    // End of variables declaration//GEN-END:variables
}

       
 

Formulario  de controles en donde  hacemos cualquier proceso een la imagen
       
           package program;

/**
 * importando las librerias necesarias
 */
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;

/**
 *
 * @author yuriani
 * @author Francisco Aguilar
 * @author Maricarmen Santos
 * @author Ivan luis Jimenez
 */
public class design extends javax.swing.JFrame {

    /*
   se crea un objeto para llamar al frame llamado imagen
     */
    imagen obj = new imagen();

    /**
     * constructor de la clase
     */
    public design() {
        setTitle("Menu principal");
        initComponents();
        filtro_manual.setEnabled(false);

    }

    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        filtro = new javax.swing.JComboBox<>();
        jPanel2 = new javax.swing.JPanel();
        girar = new javax.swing.JButton();
        ac_filtro_manual = new javax.swing.JCheckBox();
        filtro_manual = new javax.swing.JSlider();
        jPanel3 = new javax.swing.JPanel();
        RGB = new javax.swing.JComboBox<>();
        jPanel4 = new javax.swing.JPanel();
        Formatos = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        Guardar_B = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        Guardar = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenuItem13 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Filtros", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(255, 0, 51))); // NOI18N

        filtro.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Ninguno", "LookupOp", "Sharpen", "LowPass", "Detectar Bordes", "Negativo", "Espejo" }));
        filtro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filtroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(filtro, 0, 288, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(filtro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Girar", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(255, 0, 51))); // NOI18N
        jPanel2.setForeground(new java.awt.Color(255, 255, 255));

        girar.setText("90 Grados");
        girar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                girarActionPerformed(evt);
            }
        });

        ac_filtro_manual.setText("Girar Manualmente");
        ac_filtro_manual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ac_filtro_manualActionPerformed(evt);
            }
        });

        filtro_manual.setMajorTickSpacing(50);
        filtro_manual.setMaximum(360);
        filtro_manual.setPaintLabels(true);
        filtro_manual.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                filtro_manualStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(filtro_manual, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(94, 94, 94)
                                .addComponent(girar))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(67, 67, 67)
                                .addComponent(ac_filtro_manual)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(girar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ac_filtro_manual)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(filtro_manual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "RGB", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(255, 0, 51))); // NOI18N

        RGB.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Ninguno", "Escala de Grises", "Rojo", "Azul", "Amarillo", "Brillo" }));
        RGB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RGBActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(RGB, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(RGB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 15, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Guardar", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(255, 0, 51))); // NOI18N

        Formatos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "bmp", "gif", "jpeg", "jpg", "png" }));
        Formatos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FormatosActionPerformed(evt);
            }
        });

        jLabel1.setText("Formato:");

        Guardar_B.setText("Guardar");
        Guardar_B.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Guardar_BActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Formatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(Guardar_B)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Formatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(Guardar_B))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Recortar Imagen", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(255, 0, 51))); // NOI18N

        TAncho.setMaximum(0);
        TAncho.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                TAnchoStateChanged(evt);
            }
        });

        jButton2.setText("Guardar Recorte");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(TAncho, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(71, 71, 71)
                        .addComponent(jButton2)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jButton2)
                .addGap(12, 12, 12)
                .addComponent(TAncho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        mensaje.setBackground(new java.awt.Color(0, 0, 0));
        mensaje.setForeground(new java.awt.Color(204, 0, 51));

        jMenu1.setText("Archivo");

        jMenuItem1.setText("Abrir");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        Guardar.setText("Guardar");
        Guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GuardarActionPerformed(evt);
            }
        });
        jMenu1.add(Guardar);

        jMenuBar1.add(jMenu1);

        jMenu3.setText("Zoom");

        jMenu4.setText("Zoom (-)");

        jMenuItem6.setText("25%");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem6);

        jMenuItem7.setText("50%");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem7);

        jMenuItem8.setText("75%");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem8);

        jMenuItem9.setText("99%");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem9);

        jMenu3.add(jMenu4);

        jMenu5.setText("Zoom (+)");

        jMenuItem10.setText("25%");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem10);

        jMenuItem11.setText("50%");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem11);

        jMenuItem12.setText("75%");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem12);

        jMenuItem13.setText("99%");
        jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem13ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem13);

        jMenu3.add(jMenu5);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        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()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mensaje, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// //GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        try {
            //llamada del metodo cargar imagen
            obj.cargaImag();
            obj.setVisible(true);
        } catch (Exception e) {
            System.out.println("");
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void filtroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtroActionPerformed
        if (obj.isVisible()) {
            //seleccion de los filtros del combobox
            if (filtro.getSelectedItem() == "Ninguno") {
                obj.r_efecto(0);
                obj.repaint();
                mos_msj("Imagen Original");
            }
            if (filtro.getSelectedItem() == "LookupOp") {
                obj.r_efecto(14);
                obj.repaint();
                mos_msj("Se aplicó filtro LookupOp");
            }
            if (filtro.getSelectedItem() == "Sharpen") {
                obj.r_efecto(13);
                obj.repaint();
                mos_msj("Se aplicó filtro Sharpen");
            }
            if (filtro.getSelectedItem() == "LowPass") {
                obj.r_efecto(12);
                obj.repaint();
                mos_msj("Se aplicó filtro LowPass");
            }
            if (filtro.getSelectedItem() == "Detectar Bordes") {
                obj.r_efecto(10);
                obj.repaint();
                mos_msj("Filtro de marcado de bordes");
            }
            if (filtro.getSelectedItem() == "Negativo") {
                obj.r_efecto(9);
                obj.repaint();
                mos_msj("Se aplicó filtro Negativo");
            }
            if (filtro.getSelectedItem() == "Espejo") {
                obj.r_efecto(7);
                obj.repaint();
                mos_msj("Se tranformo a espejo");
            }
        }
    }//GEN-LAST:event_filtroActionPerformed

    private void girarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_girarActionPerformed
        try {
            //llamamada del metodo rotar imagen
            obj.rotacionImagen(90);
            obj.actualiza_frame();
            obj.repaint();
            mos_msj("Se giró la imagen");
        } catch (Exception e) {
            System.out.println("");
        }
    }//GEN-LAST:event_girarActionPerformed

    private void ac_filtro_manualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ac_filtro_manualActionPerformed

        if (ac_filtro_manual.isSelected()) {
            filtro_manual.setEnabled(true);
            mos_msj("Giro manual ACTIVADO");
        } else {
            filtro_manual.setEnabled(false);
            mos_msj("Giro manual DESACTIVADO");
        }
    }//GEN-LAST:event_ac_filtro_manualActionPerformed

    private void filtro_manualStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_filtro_manualStateChanged
        //llamada del metodo grados para girar la imagen
        obj.Grados(filtro_manual.getValue());
        obj.r_efecto(4);
    }//GEN-LAST:event_filtro_manualStateChanged

    private void RGBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RGBActionPerformed
        //seleccion de los filtros del comboboxRGB
        if (RGB.getSelectedItem() == "Ninguno") {
            obj.r_efecto(0);
            obj.repaint();
            mos_msj("Imagen Original");
        }
        if (RGB.getSelectedItem() == "Escala de Grises") {
            obj.r_efecto(3);
            obj.repaint();
            mos_msj("Se aplicó escala de grises");
        }
        if (RGB.getSelectedItem() == "Azul") {
            obj.r_efecto(1);
            obj.repaint();
            mos_msj("Se aplicó filtro azul");
        }
        if (RGB.getSelectedItem() == "Rojo") {
            obj.r_efecto(6);
            obj.repaint();
            mos_msj("Se aplico filtro rojo");
        }
        if (RGB.getSelectedItem() == "Amarillo") {
            obj.r_efecto(5);
            obj.repaint();
            mos_msj("Se aplicó filtro amarillo");
        }
        if (RGB.getSelectedItem() == "Brillo") {
            obj.r_efecto(2);
            obj.repaint();
            mos_msj("Se aplicó brillo");
        }
    }//GEN-LAST:event_RGBActionPerformed

    private void FormatosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FormatosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_FormatosActionPerformed

    private void GuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GuardarActionPerformed
        try {
            // llamada del metodo guardar
            guardar();
        } catch (IOException ex) {
            System.out.println("");
        }
    }//GEN-LAST:event_GuardarActionPerformed

    private void Guardar_BActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Guardar_BActionPerformed
        try {
            //llamada del metodo guardar
            guardar();
        } catch (IOException ex) {
            System.out.println("");
        }
    }//GEN-LAST:event_Guardar_BActionPerformed

    private void TAnchoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TAnchoStateChanged
        //llamada del metodo recortar imagen
        try {

            obj.RecortarImagen();
        } catch (Exception e) {
        }
    }//GEN-LAST:event_TAnchoStateChanged

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        //llamada del metodo guardar recorte
        obj.GuardarRecorte();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al -%99
        obj.tam(0.75, 0.75);
        obj.r_efecto(11);

        obj.repaint();

    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al  -%50
        obj.tam(0.5, 0.5);
        obj.r_efecto(11);
        obj.repaint();
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al -%25
        obj.tam(0.25, 0.25);
        obj.r_efecto(11);
        obj.repaint();
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al -%10:
        obj.tam(0.1, 0.1);
        obj.r_efecto(11);
        obj.repaint();
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al %25
        obj.tam(1.25, 1.25);
        obj.r_efecto(11);
        obj.repaint();
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al %50
        obj.tam(1.5, 1.5);
        obj.r_efecto(11);
        obj.repaint();
    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al %75
        obj.tam(1.75, 1.75);
        obj.r_efecto(11);
        obj.repaint();
    }//GEN-LAST:event_jMenuItem12ActionPerformed

    private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed
        //metodo que llama al metodo tam para aplicar zoom al %99
        obj.tam(1.9, 1.9);
        obj.r_efecto(11);

        obj.repaint();
    }//GEN-LAST:event_jMenuItem13ActionPerformed

    /**
     * metodo que guarda la imagen
     *
     * @throws IOException variable IOException
     */
    public void guardar() throws IOException {
        try {

            String formato = (String) Formatos.getSelectedItem();
            File saveFile = new File("Imagen." + formato);
            JFileChooser chooser = new JFileChooser();
            chooser.setSelectedFile(saveFile);
            int rFormato = chooser.showSaveDialog(Formatos);
            if (rFormato == JFileChooser.APPROVE_OPTION) {
                saveFile = chooser.getSelectedFile();
                ImageIO.write(obj.getBi(), formato, saveFile);
                mos_msj("Se guardó correctamente");
            }
        } catch (Exception e) {
        }
    }

    public static void mos_msj(String Mensaje) {
        mensaje.setText(Mensaje);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //
        /* 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(design.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(design.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(design.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(design.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //
      
/* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new design().setVisible(true);

            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public static javax.swing.JComboBox Formatos;
    private javax.swing.JMenuItem Guardar;
    private javax.swing.JButton Guardar_B;
    private javax.swing.JComboBox RGB;
    public static final javax.swing.JSlider TAncho = new javax.swing.JSlider();
    private javax.swing.JCheckBox ac_filtro_manual;
    private javax.swing.JComboBox filtro;
    private javax.swing.JSlider filtro_manual;
    private javax.swing.JButton girar;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    public static final javax.swing.JLabel mensaje = new javax.swing.JLabel();
    // End of variables declaration//GEN-END:variables
}

  //
       
 

link del proyecto hecho en netbeans: procesamiento de imagenes


domingo, 23 de octubre de 2016

Anclas con texto e imagenes en html5

















que tal amigos les traigo un video tutorial  sobre anclas  con imagenes en html 5

espero y les sea de utilidad




Insertar codigo java en blogger

que tal amigos en esta ocasion vengo a mostrarles como inserta codigo java en nuestro blogger para que no se vea muy feo. sin mas rodeos les dejo una captura y el codigo..



--------------------------------------------------------------------------------------------------------------------------
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: &quot;andale mono&quot; , &quot;lucida console&quot; , &quot;monaco&quot; , &quot;fixed&quot; , monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;">       <code style="color: black; word-wrap: normal;">
           YOUR CODE HERE
           aqui es donde debes pegar todo tu codigo
       </code>
 </pre>
-------------------------------------------------------------------------------------------------------------------------


 y el resultado queda asi....

       

           YOUR CODE HERE

           aqui es donde debes pegar todo tu codigo

       



 


Odenamiento mecla directa en archivos externos

que tal amigos hoy les traigo este proyecto con el que me tope, en donde  como sabrán para algunos la materia de estructura de datos es un dolor de cabeza, en esta ocasion les traigo lo que es el ordenamiento de datos en este caso son números  en el cual ordena de manera externa mediante  archivos, que son 2 auxiliares y uno de origen , este código  es de mi auditoría basan dome en el libro de estructura de datos de cairo. bueno sin mas rodeos , les dejo algunas capturas y el código. son libres de modificarlo y mejorarlo, espero y les sirva







       


import java.io.*;
import java.util.Scanner;

public class OrdenExtMzclaDirecta {

   

    static void mezclaDirecta(File f) throws IOException {
        int longSec;
        int numReg;
        File f1 = new File("ArchivoAux1.dat");
        File f2 = new File("ArchivoAux2.dat");
        /* número de registros se obtiene dividiendo el tamaño
         del archivo por el tamaño del registro: 4.
         */
        numReg = (int) f.length() / 4;
        longSec = 1;
        while (longSec < numReg) {
            distribuir(f, f1, f2, longSec, numReg);
            mezclar(f1, f2, f, longSec, numReg);
            longSec *= 2;
        }
    }

    static void distribuir(File f, File f1, File f2,
            int longSec, int numReg) throws IOException {
        int numSec, resto, i;
        DataInputStream flujo = new DataInputStream(
                new BufferedInputStream(new FileInputStream(f)));
        DataOutputStream flujo1 = new DataOutputStream(
                new BufferedOutputStream(new FileOutputStream(f1)));
        DataOutputStream flujo2 = new DataOutputStream(
                new BufferedOutputStream(new FileOutputStream(f2)));
        numSec = numReg / (2 * longSec);
        resto = numReg % (2 * longSec);
//distribuye secuencias de longitud longSec
        for (i = 1; i <= numSec; i++) {
            subSecuencia(flujo, flujo1, longSec);
            subSecuencia(flujo, flujo2, longSec);
        }
        /*
         Se procesa el resto de registros del archivo
         */
        if (resto > longSec) {
            resto -= longSec;
        } else {
            longSec = resto;
            resto = 0;
        }
        subSecuencia(flujo, flujo1, longSec);
        subSecuencia(flujo, flujo2, resto);
        flujo.close();
        flujo1.close();
        flujo2.close();
    }

    private static void subSecuencia(DataInput f, DataOutput t,
            int longSec) throws IOException {
        int clave;
//escribe en el flujo t el dato entero leído de f
        for (int j = 1; j <= longSec; j++) {
            clave = f.readInt();
            t.writeInt(clave);
        }
    }

    static void mezclar(File f1, File f2, File f,
            int lonSec, int numReg) throws IOException {
        int numSec, resto, i, j, k;
        int clave1 = 0, clave2 = 0;
        numSec = numReg / (2 * lonSec); // número de subsecuencias
        resto = numReg % (2 * lonSec);
        DataOutputStream flujo = new DataOutputStream(
                new BufferedOutputStream(new FileOutputStream(f)));
        DataInputStream flujo1 = new DataInputStream(
                new BufferedInputStream(new FileInputStream(f1)));
        DataInputStream flujo2 = new DataInputStream(
                new BufferedInputStream(new FileInputStream(f2)));
//claves iniciales
        clave1 = flujo1.readInt();
        clave2 = flujo2.readInt();
//bucle para controlar todo el proceso de mezcla
        for (int s = 1; s <= numSec + 1; s++) {
            int n1, n2;
            n1 = n2 = lonSec;
            if (s == numSec + 1) { // proceso de subsecuencia incompleta
                if (resto > lonSec) {
                    n2 = resto - lonSec;
                } else {
                    n1 = resto;
                    n2 = 0;
                }
            }
            i = j = 1;
            while (i <= n1 && j <= n2) {
                int clave;
                if (clave1 < clave2) {
                    clave = clave1;
                    try {
                        clave1 = flujo1.readInt();
                    } catch (EOFException e) {;
                    }
                    i++;
                } else {
                    clave = clave2;
                    try {
                        clave2 = flujo2.readInt();
                    } catch (EOFException e) {;
                    }
                    j++;
                }
                flujo.writeInt(clave);
            }
            /*
             Los registros no procesados se escriben directamente
             */
            for (k = i; k <= n1; k++) {
                flujo.writeInt(clave1);
                try {
                    clave1 = flujo1.readInt();
                } catch (EOFException e) {;
                }
            }
            for (k = j; k <= n2; k++) {
                flujo.writeInt(clave2);
                try {
                    clave2 = flujo2.readInt();
                } catch (EOFException e) {;
                }
            }
        }
        flujo.close();
        flujo1.close();
        flujo2.close();
    }

    static void leer(File f) throws FileNotFoundException, IOException {
        int clave, k;
        boolean mas = true;
        DataInputStream flujo = null;
        try {
            flujo = new DataInputStream(
                    new BufferedInputStream(new FileInputStream(f)));
            k = 0;
            System.out.println("ARCHIVO DE CLAVES TIPO INT");
            while (mas) {
                k++;
                System.out.print(flujo.readInt() + " ");
                if (k % 11 == 0) {
                    System.out.println();
                }
            }

        } catch (EOFException eof) {
            System.out.println("\n *** Fin del archivo ***\n");
            try {
                flujo.close();
            } catch (IOException er) {
                er.printStackTrace();
            }
        }
    }

   public static void crearAtchivo(File Ffichero) {

        // crear un objeto de tipo archivo
        DataOutputStream archivo = null;
        // creando e inicializando los campos del registro
        // observar que se debe usar clases numericas apropiadas
        int clave = 0;
        String nombre = new String("");
        int edad = 0;
        // creando objeto teclado
        BufferedReader teclado = new BufferedReader(new InputStreamReader(System.in));
        // abriendo archivo, capturando y grabando datos
        try {
            //* Creando y grabando a un archivo, esta larga la instrucción*/
            archivo = new DataOutputStream(new FileOutputStream(Ffichero, true));
            System.out.println("dame clave: ");
            clave = Integer.parseInt(teclado.readLine());

            //grabando al archivo
            archivo.writeInt(clave);

            archivo.close();
        } catch (FileNotFoundException fnfe) { /* Archivo no encontrado */

        } catch (IOException ioe) { /* Error al escribir */

        }
    }

    public static void main(String[] a) throws FileNotFoundException, IOException {
        Scanner s = new Scanner(System.in);
        File f = new File("ArchivoOrigen.dat");

        int opcion = 0;
        while (opcion != 4) {
            System.out.println("menu\n"
                    + "1.-agregar\n"
                    + "2.-leer\n"
                    + "3.-ordenar\n"
                    + "4.-salir");
            System.out.println("que opcion desea realizar");
            opcion=s.nextInt();
            switch (opcion) {
                case 1:
                    crearAtchivo(f);
                    System.out.println("dato agregado");
                    break;
                case 2:
                    leer(f);
                    System.out.println("datos mostrados con exito");
                    break;
                case 3:
                    mezclaDirecta(f);
                    System.out.println("Datos ordenados exitosamente");
                case 4:
                    System.out.println("programa finalizado");
                    break;
                default:
                    System.out.println("opcion invalida");
                    break;
            }
            
        }
    }
}

          

       
 

Ecuaciones diferenciales no homogéneas que se convierten en homogéneas



Que tal amigos hoy les traigo algunas captura de las ecuaciones diferenciales, claro ya deben de tener un poco de conocimientos de estas, ya que un macho todo lo puede pues les dejo cual es el procedimiento y 2 ejemplos de cómo resolverlos. Saludos espero y les sirva.









espero y les halla servidor.. muchas gracias x su visita.

Calculador de resistencias en Java

Que tal amigos hoy les vengo trayendo  el programa del  color de resistencias electrónicos en su ya en su versión final como le había comentado semanas antes esta versión final del proyecto  fue desarrollado junto a mi compañero Ivan Luis.


Si más rodeos este programa lo que hace es  calcular el valor  de la resistencia a partir de una selección de colores de  3, 4  5 bandas  junto con la tolerancia. Si no se especifica la tolerancia por defecto son 20 %. Además tambien hace su inverso es decir poner el valor  y automáticamente te dará  el valor de las bandas automáticamente. Bueno aquí les dejo algunas imágenes y su respectivo código. espero sus comentarios si no es mucha molestia.





       

            
import com.sun.awt.AWTUtilities;
import java.awt.Color;
import javax.swing.JOptionPane;

/**
 *
 * @author Francisco Aguilar Jacobo
 */
public class Resistencia extends javax.swing.JFrame {

    /**
     * Creates new form Resistencia
     */
    public Resistencia() {
        initComponents();
        setSize(700, 500);
        AWTUtilities.setWindowOpaque(this, false);
        setLocationRelativeTo(this);
        List1.setVisible(false);
        List2.setVisible(false);
        List3.setVisible(false);

        multiplicativo.setVisible(false);
        tolerancia.setVisible(false);

        color1.setVisible(false);
        color2.setVisible(false);
        color3.setVisible(false);
        tolerancia1.setBackground(oro());
        Calcular.setBackground(oro());
        unidad.setBackground(oro());

        multiplicadorb.setVisible(false);
        toleranciab.setVisible(false);
        total_resis(Integer.parseInt(bandas.getSelectedItem().toString()));

        List1.setBackground(oro());
        List2.setBackground(oro());
        List3.setBackground(oro());
        multiplicativo.setBackground(oro());
        tolerancia.setBackground(oro());

        p1.setBackground(Color.CYAN);
        p2.setBackground(Color.CYAN);
        p3.setBackground(Color.cyan);
        Cerrar.setBackground(Color.RED);
        bandas.setBackground(Color.green);
        Reset.setBackground(oro());

    }

    public Color cafe() {
        Color cafe = new Color(102, 51, 0);
        return cafe;
    }

    public Color violeta() {
        Color violeta = new Color(204, 0, 204);

        return violeta;
    }

    public Color oro() {
        Color oro = new Color(172, 150, 0);
        return oro;
    }

    public Color plata() {
        Color plata = new Color(153, 153, 153);
        return plata;
    }

    public Color reset_color() {
        Color reset = new Color(187, 187, 187);
        return reset;
    }

    public int Select1() {
        int opcion = List1.getSelectedIndex();
        switch (opcion) {
            case 0:
                color1.setBackground(reset_color());
                break;
            case 1:
                opcion = 0;
                color1.setBackground(Color.BLACK);
                break;
            case 2:
                opcion = 1;
                color1.setBackground(cafe());
                break;
            case 3:
                opcion = 2;
                color1.setBackground(Color.RED);
                break;
            case 4:
                opcion = 3;
                color1.setBackground(Color.ORANGE);
                break;
            case 5:
                opcion = 4;
                color1.setBackground(Color.YELLOW);
                break;
            case 6:
                opcion = 5;
                color1.setBackground(Color.GREEN);
                break;
            case 7:
                opcion = 6;
                color1.setBackground(Color.BLUE);
                break;
            case 8:
                opcion = 7;
                color2.setBackground(violeta());
                break;
            case 9:
                opcion = 8;
                color1.setBackground(Color.GRAY);
                break;
            case 10:
                opcion = 9;
                color1.setBackground(Color.WHITE);
                break;
            default:

                break;
        }

        return opcion;
    }

    public int Select2() {
        int opcion = List2.getSelectedIndex();
        switch (opcion) {
            case 0:
                color2.setBackground(reset_color());
                break;
            case 1:
                opcion = 0;
                color2.setBackground(Color.BLACK);
                break;
            case 2:
                opcion = 1;
                color2.setBackground(cafe());
                break;
            case 3:
                opcion = 2;
                color2.setBackground(Color.RED);
                break;
            case 4:
                opcion = 3;
                color2.setBackground(Color.ORANGE);
                break;
            case 5:
                opcion = 4;
                color2.setBackground(Color.YELLOW);
                break;
            case 6:
                opcion = 5;
                color2.setBackground(Color.GREEN);
                break;
            case 7:
                opcion = 6;
                color2.setBackground(Color.BLUE);
                break;
            case 8:
                opcion = 7;
                color2.setBackground(violeta());
                break;
            case 9:
                opcion = 8;
                color2.setBackground(Color.GRAY);
                break;
            case 10:
                opcion = 9;
                color2.setBackground(Color.WHITE);
                break;
            default:

                break;
        }

        return opcion;
    }

    public float calc() {
        
        
        float banda1 = 0;
        if ((Integer.parseInt(bandas.getSelectedItem().toString())) == 4) {
            banda1 = ((Select1() * 10) + Select2()) * Select4();
        } else {
            banda1 = ((Select1() * 100) + (Select2() * 10) + Select3()) * Select4();
        }

        if (tolerancia.getSelectedItem().toString() =="Ninguno") {
            tole.setText("+/- 20%");
            toleranciab.setVisible(false);
        }
        
        return banda1;
    }

    public int Select3() {
        int opcion = List3.getSelectedIndex();
        switch (opcion) {
            case 0:
                color3.setBackground(reset_color());
                break;
            case 1:
                opcion = 0;
                color3.setBackground(Color.BLACK);
                break;
            case 2:
                opcion = 1;
                color3.setBackground(cafe());
                break;
            case 3:
                opcion = 2;
                color3.setBackground(Color.RED);
                break;
            case 4:
                opcion = 3;
                color3.setBackground(Color.ORANGE);
                break;
            case 5:
                opcion = 4;
                color3.setBackground(Color.YELLOW);
                break;
            case 6:
                opcion = 5;
                color3.setBackground(Color.GREEN);
                break;
            case 7:
                opcion = 6;
                color3.setBackground(Color.BLUE);
                break;
            case 8:
                opcion = 7;
                color3.setBackground(violeta());
                break;
            case 9:
                opcion = 8;
                color3.setBackground(Color.GRAY);
                break;
            case 10:
                opcion = 9;
                color3.setBackground(Color.WHITE);
                break;
            default:

                break;
        }

        return opcion;
    }

    public float Select4() {
        int o = multiplicativo.getSelectedIndex();
        float opcion = 0;

        switch (o) {
            case 0:
                multiplicadorb.setBackground(reset_color());
                break;
            case 1:
                opcion = 1;
                multiplicadorb.setBackground(Color.BLACK);
                break;
            case 2:
                opcion = 10;
                multiplicadorb.setBackground(cafe());
                break;
            case 3:
                opcion = 100;
                multiplicadorb.setBackground(Color.RED);
                break;
            case 4:
                opcion = 1000;
                multiplicadorb.setBackground(Color.ORANGE);
                break;
            case 5:
                opcion = 10000;
                multiplicadorb.setBackground(Color.YELLOW);
                break;
            case 6:
                opcion = 100000;
                multiplicadorb.setBackground(Color.GREEN);
                break;
            case 7:
                opcion = 1000000;
                multiplicadorb.setBackground(Color.BLUE);
                break;
            case 8:
                opcion = (float) 0.01;
                multiplicadorb.setBackground(plata());
                break;
            case 9:
                opcion = (float) 0.1;
                multiplicadorb.setBackground(oro());
                break;

            default:

                break;
        }

        return opcion;
    }

    public void Select5() {
        int opcion = tolerancia.getSelectedIndex();
        switch (opcion) {
            case 0:
                toleranciab.setBackground(reset_color());
                toleranciab.setVisible(false);
                tole.setText("+/- 20%");
                break;
            case 1:

                toleranciab.setBackground(cafe());
                toleranciab.setVisible(true);
                tole.setText("+/- 1%");
                break;
            case 2:

                toleranciab.setBackground(Color.RED);
                toleranciab.setVisible(true);
                tole.setText("+/- 2%");
                break;
            case 3:

                toleranciab.setBackground(Color.GREEN);
                toleranciab.setVisible(true);
                tole.setText("+/- 0.5%");
                break;
            case 4:

                toleranciab.setBackground(Color.BLUE);
                toleranciab.setVisible(true);
                tole.setText("+/- 0.25%");
                break;
            case 5:

                toleranciab.setBackground(violeta());
                toleranciab.setVisible(true);
                tole.setText("+/- 0.10%");
                break;
            case 6:

                toleranciab.setBackground(Color.GRAY);
                toleranciab.setVisible(true);
                tole.setText("+/- 0.05%");
                break;
            case 7:

                toleranciab.setBackground(oro());
                toleranciab.setVisible(true);
                tole.setText("+/- 5%");
                break;
            case 8:

                toleranciab.setBackground(plata());
                toleranciab.setVisible(true);
                tole.setText("+/- 10%");
                break;

            default:

                break;
        }

    }
    public void Select6() {
        int opcion = tolerancia1.getSelectedIndex();
        toleranciab.setVisible(true);
        switch (opcion) {
            case 0:
                toleranciab.setBackground(reset_color());
                tole1.setText("+/- 20%");
                tolerancia.setSelectedItem("Ninguno");
                break;
            case 1:

                toleranciab.setBackground(cafe());
                tole1.setText("+/- 1%");
                tolerancia.setSelectedItem("Cafe");
                break;
            case 2:

                toleranciab.setBackground(Color.RED);
                tole1.setText("+/- 2%");
                tolerancia.setSelectedItem("Rojo");
                break;
            case 3:

                toleranciab.setBackground(Color.GREEN);
               tole1.setText("+/- 0.5%");
               tolerancia.setSelectedItem("Verde");
                break;
            case 4:

                toleranciab.setBackground(Color.BLUE);
               tole1.setText("+/- 0.25%");
               tolerancia.setSelectedItem("Azul");
                break;
            case 5:

                toleranciab.setBackground(violeta());
               tole1.setText("+/- 0.10%");
               tolerancia.setSelectedItem("Violeta");
                break;
            case 6:

                toleranciab.setBackground(Color.GRAY);
              tole1.setText("+/- 0.05%");
              tolerancia.setSelectedItem("Gris");
                break;
            case 7:

                toleranciab.setBackground(oro());
            tole1.setText("+/- 5%");
            tolerancia.setSelectedItem("Oro");
                break;
            case 8:

                toleranciab.setBackground(plata());
           tole1.setText("+/- 10%");
           tolerancia.setSelectedItem("Plata");
                break;

            default:

                break;
        }

    }

    @SuppressWarnings("unchecked")
    //                           
    private void initComponents() {

        Reset = new javax.swing.JButton();
        color2 = new javax.swing.JButton();
        p3 = new javax.swing.JPanel();
        Resultado = new javax.swing.JLabel();
        unidad = new javax.swing.JComboBox();
        tole = new javax.swing.JLabel();
        p2 = new javax.swing.JPanel();
        valor = new javax.swing.JTextField();
        Calcular = new javax.swing.JToggleButton();
        tolerancia1 = new javax.swing.JComboBox();
        unidad1 = new javax.swing.JLabel();
        tole1 = new javax.swing.JLabel();
        p1 = new javax.swing.JPanel();
        List1 = new javax.swing.JComboBox();
        List2 = new javax.swing.JComboBox();
        List3 = new javax.swing.JComboBox();
        multiplicativo = new javax.swing.JComboBox();
        tolerancia = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        bandas = new javax.swing.JComboBox();
        toleranciab = new javax.swing.JButton();
        multiplicadorb = new javax.swing.JButton();
        color3 = new javax.swing.JButton();
        color1 = new javax.swing.JButton();
        Cerrar = new javax.swing.JButton();
        casco = new javax.swing.JLabel();
        resistencia = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setUndecorated(true);
        getContentPane().setLayout(null);

        Reset.setText("Reset");
        Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetActionPerformed(evt);
            }
        });
        getContentPane().add(Reset);
        Reset.setBounds(530, 340, 77, 32);
        getContentPane().add(color2);
        color2.setBounds(240, 290, 40, 130);

        p3.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados"));
        p3.setLayout(null);
        p3.add(Resultado);
        Resultado.setBounds(10, 20, 110, 20);

        unidad.setModel(new javax.swing.DefaultComboBoxModel(new String[] 
{ "Ohm Ω", "KΩ", "MΩ", "GΩ", "MiliΩ", "MicroΩ", "NanoΩ" }));
        unidad.setToolTipText("");
        unidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                unidadActionPerformed(evt);
            }
        });
        p3.add(unidad);
        unidad.setBounds(180, 20, 80, 26);
        p3.add(tole);
        tole.setBounds(110, 20, 60, 16);

        getContentPane().add(p3);
        p3.setBounds(200, 210, 270, 50);

        p2.setBorder(javax.swing.BorderFactory.createTitledBorder("De valores a colores"));
        p2.setLayout(null);

        valor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                valorActionPerformed(evt);
            }
        });
        valor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                valorKeyTyped(evt);
            }
        });
        p2.add(valor);
        valor.setBounds(20, 20, 120, 30);

        Calcular.setText("Calcular");
        Calcular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CalcularActionPerformed(evt);
            }
        });
        p2.add(Calcular);
        Calcular.setBounds(500, 20, 77, 32);

        tolerancia1.setModel(new javax.swing.DefaultComboBoxModel(new String[]
 { "Ninguno", "Cafe", "Rojo", "Verde", "Azul", "Violeta", "Gris", "Oro", "Plata" }));
        tolerancia1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tolerancia1ActionPerformed(evt);
            }
        });
        p2.add(tolerancia1);
        tolerancia1.setBounds(230, 20, 100, 26);

        unidad1.setText("Ohm Ω");
        p2.add(unidad1);
        unidad1.setBounds(350, 30, 70, 16);
        p2.add(tole1);
        tole1.setBounds(150, 30, 60, 16);

        getContentPane().add(p2);
        p2.setBounds(20, 140, 640, 60);

        p1.setBorder(javax.swing.BorderFactory.createTitledBorder("De colores a valores"));
        p1.setLayout(null);

        List1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguno", "Negro", "Cafe", "Rojo", "Naranja", "Amarillo", "Verde", "Azul", "Violeta", "Gris", "Blanco" }));
        List1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                List1ActionPerformed(evt);
            }
        });
        p1.add(List1);
        List1.setBounds(30, 20, 100, 26);

        List2.setModel(new javax.swing.DefaultComboBoxModel(new String[]
 { "Ninguno", "Negro", "Cafe", "Rojo", "Naranja", "Amarillo", "Verde", "Azul", "Violeta", "Gris", "Blanco" }));
        List2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                List2ActionPerformed(evt);
            }
        });
        p1.add(List2);
        List2.setBounds(150, 20, 100, 26);

        List3.setModel(new javax.swing.DefaultComboBoxModel(new String[] 
{ "Ninguno", "Negro", "Cafe", "Rojo", "Naranja", "Amarillo", "Verde", "Azul", "Violeta", "Gris", "Blanco" }));
        List3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                List3ActionPerformed(evt);
            }
        });
        p1.add(List3);
        List3.setBounds(270, 20, 100, 26);

        multiplicativo.setModel(new javax.swing.DefaultComboBoxModel(new String[] 
{ "Ninguno", "Negro", "Cafe", "Rojo", "Naranja", "Amarillo", "Verde", "Azul", "Plata", "Oro" }));
        multiplicativo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                multiplicativoActionPerformed(evt);
            }
        });
        p1.add(multiplicativo);
        multiplicativo.setBounds(390, 20, 100, 26);

        tolerancia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguno", "Cafe", "Rojo", "Verde", "Azul", "Violeta", "Gris", "Oro", "Plata" }));
        tolerancia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toleranciaActionPerformed(evt);
            }
        });
        p1.add(tolerancia);
        tolerancia.setBounds(510, 20, 100, 26);

        getContentPane().add(p1);
        p1.setBounds(20, 70, 640, 60);

        jLabel1.setBackground(new java.awt.Color(0, 0, 0));
        jLabel1.setForeground(new java.awt.Color(0, 0, 0));
        jLabel1.setText("Indique total de bandas:");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(230, 40, 140, 16);

        bandas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "4", "5" }));
        bandas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bandasActionPerformed(evt);
            }
        });
        getContentPane().add(bandas);
        bandas.setBounds(380, 40, 50, 26);
        getContentPane().add(toleranciab);
        toleranciab.setBounds(440, 290, 40, 130);
        getContentPane().add(multiplicadorb);
        multiplicadorb.setBounds(390, 290, 40, 130);
        getContentPane().add(color3);
        color3.setBounds(290, 290, 40, 130);
        getContentPane().add(color1);
        color1.setBounds(190, 290, 40, 130);

        Cerrar.setFont(new java.awt.Font("Cooper Black", 1, 18)); // NOI18N
        Cerrar.setText("X");
        Cerrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CerrarMouseClicked(evt);
            }
        });
        getContentPane().add(Cerrar);
        Cerrar.setBounds(630, 30, 45, 38);

        casco.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/casco.png"))); // NOI18N
        getContentPane().add(casco);
        casco.setBounds(0, 10, 690, 320);

        resistencia.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/bajo.png"))); // NOI18N
        getContentPane().add(resistencia);
        resistencia.setBounds(0, 250, 690, 210);

        pack();
    }//                         

    private void CerrarMouseClicked(java.awt.event.MouseEvent evt) {                                    
        System.exit(0);
    }                                   

    private void List1ActionPerformed(java.awt.event.ActionEvent evt) {                                      

        Resultado.setText("" + calc());

    }                                     

    private void List2ActionPerformed(java.awt.event.ActionEvent evt) {                                      

        Resultado.setText("" + calc());
    }                                     

    private void List3ActionPerformed(java.awt.event.ActionEvent evt) {                                      

        Resultado.setText("" + calc());
    }                                     

    private void multiplicativoActionPerformed(java.awt.event.ActionEvent evt) {                                               

        Resultado.setText("" + calc());
    }                                              

    private void toleranciaActionPerformed(java.awt.event.ActionEvent evt) {                                           

        Select5();

    }                                          

    private void bandasActionPerformed(java.awt.event.ActionEvent evt) {                                       
        int total = Integer.parseInt(bandas.getSelectedItem().toString());
        total_resis(total);
        if (total == 5) {
            p2.setEnabled(false);
            valor.setEnabled(false);
            Calcular.setEnabled(false);
            tolerancia1.setEnabled(false);
            unidad1.setEnabled(false);
            tole1.setEnabled(false);
        } else {
            p2.setEnabled(true);
            valor.setEnabled(true);
            Calcular.setEnabled(true);
            tolerancia1.setEnabled(true);
            unidad1.setEnabled(true);
            tole1.setEnabled(true);
        }
    }                                      

    private void unidadActionPerformed(java.awt.event.ActionEvent evt) {                                       
        Resultado.setText(convertidor() + "");
    }                                      

    private void ResetActionPerformed(java.awt.event.ActionEvent evt) {                                      
        List1.setSelectedItem("Ninguno");
        List2.setSelectedItem("Ninguno");
        List3.setSelectedItem("Ninguno");
        multiplicativo.setSelectedItem("Ninguno");
        tolerancia.setSelectedItem("Ninguno");
        unidad.setSelectedItem("Ohm Ω");
        tole1.setText("");
        valor.setText("");

        tole.setText("");
        Resultado.setText("");
        color1.setBackground(reset_color());
        color2.setBackground(reset_color());
        color3.setBackground(reset_color());
        multiplicadorb.setBackground(reset_color());
        toleranciab.setBackground(reset_color());
    }                                     

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

    private void CalcularActionPerformed(java.awt.event.ActionEvent evt) {                                         
//        System.out.println(valor.getText().isEmpty());

        if ((valor.getText().isEmpty())) {
            JOptionPane.showMessageDialog(null, "Debe ingresar un valor en Ohm", "Atención", 2);
        } else {
            float r = Float.parseFloat(valor.getText());
           
            if (r < 1) {
                JOptionPane.showMessageDialog(null, "solo numeros >=1");
             
            } else {
                List1.setSelectedItem("Negro");
                List2.setSelectedItem("Negro");
                multiplicativo.setSelectedItem("Negro");
                
                color1.setBackground(Color.black);
                color2.setBackground(Color.black);
                multiplicadorb.setBackground(Color.black);
                divide_ca(valor.getText());
            }
        }
        
        if(tolerancia1.getSelectedItem().toString().equals("Ninguno")){
            tole1.setText("+/- 20%");
        }


    }                                        

    private void valorKeyTyped(java.awt.event.KeyEvent evt) {                               
        char c = evt.getKeyChar();
        if ((Character.isLetter(c))) {
            getToolkit().beep();

            evt.consume();

            JOptionPane.showMessageDialog(null, "Ingrse sólo números", "Atención", 2);

        }


    }                              

    private void tolerancia1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        Select6();
    }                                           


    public void total_resis(int total) {
        if (total == 4) {
            List1.setVisible(true);
            multiplicativo.setVisible(true);
            tolerancia.setVisible(true);
            List3.setVisible(false);
            color3.setVisible(false);

            List2.setVisible(true);
            color1.setVisible(true);
            color2.setVisible(true);
            multiplicadorb.setVisible(true);
            toleranciab.setVisible(true);

            // tolerancia(total);
        }
        if (total == 5) {
            List1.setVisible(true);
            multiplicativo.setVisible(true);
            tolerancia.setVisible(true);
            List2.setVisible(true);
            List3.setVisible(true);
            color3.setVisible(true);

        }

    }

    public float convertidor() {
        int or = unidad.getSelectedIndex();
        float val = 0;
        switch (or) {
            case 0:
                val = calc();
                break;
            case 1:
                val = (float) (calc() * 0.001);
                break;
            case 2:
                val = (float) (calc() * 0.000001);
                break;
            case 3:
                val = (float) (calc() * 0.000000001);
                break;
            case 4:
                val = (float) (calc() * 1000);
                break;
            case 5:
                val = (float) (calc() * 1000000);
                break;
            case 6:
                val = (float) (calc() * 1000000000);
                break;
        }
        return val;
    }

    public void divide_ca(String cadena) {
        int r = (int) (Double.parseDouble(cadena)); //convierte a entero la cadena
        String copia = String.valueOf(r); //convierte String del entero convertido

        int resultado = 0;
        //String color3 = "negro";
        if (copia.length() == 1) {
            resultado = r;
            //here
            multiplicativo.setSelectedItem("Negro");
            multiplicadorb.setBackground(Color.BLACK);
          
        } else {
            if (copia.length() == 2) {
                resultado = r;
                multiplicadorb.setBackground(Color.BLACK);
                //here
                multiplicativo.setSelectedItem("Negro");
            } else if (copia.length() == 3) {
                resultado = r / 10;
                multiplicadorb.setBackground(cafe());
                multiplicativo.setSelectedItem("Cafe");

            } else if (copia.length() == 4) {
                resultado = r / 100;
                multiplicadorb.setBackground(Color.RED);
                multiplicativo.setSelectedItem("Rojo");
            } else if (copia.length() == 5) {
                resultado = r / 1000;
                multiplicadorb.setBackground(Color.ORANGE);
                multiplicativo.setSelectedItem("Naranja");
            } else if (copia.length() == 6) {
                resultado = r / 10000;
                multiplicadorb.setBackground(Color.YELLOW);
                multiplicativo.setSelectedItem("Amarillo");
            } else if (copia.length() == 7) {
                resultado = r / 100000;
                multiplicadorb.setBackground(Color.GREEN);
                multiplicativo.setSelectedItem("Verde");
            } else if (copia.length() == 8) {
                resultado = r / 100000;
                multiplicadorb.setBackground(Color.BLUE);
                multiplicativo.setSelectedItem("Azul");
            } else if (copia.length() == 9) {
                resultado = r / 10000000;
                multiplicadorb.setBackground(violeta());
                multiplicativo.setSelectedItem("Violeta");
            }
        }

        //System.out.println("resul: " + resultado);
        String copi = String.valueOf(resultado);
        int[] enteros = new int[copi.length()];

        String cad = "";

        for (int j = 0; j < copi.length(); j++) {
            cad = String.valueOf(copi.charAt(j));

            enteros[j] = Integer.parseInt(cad);

        }

        if (enteros.length < 2) {
            if (enteros[0] == 0) {
                color2.setBackground(Color.BLACK);
                //here
                List2.setSelectedItem("Negro");
            } else if (enteros[0] == 1) {
                color2.setBackground(cafe());
                List2.setSelectedItem("Cafe");
            } else if (enteros[0] == 2) {
                color2.setBackground(Color.RED);
                List2.setSelectedItem("Rojo");
            } else if (enteros[0] == 3) {
                color2.setBackground(Color.ORANGE);
                List2.setSelectedItem("Naranja");
            } else if (enteros[0] == 4) {
                color2.setBackground(Color.YELLOW);
                List2.setSelectedItem("Amarillo");
            } else if (enteros[0] == 5) {
                color2.setBackground(Color.GREEN);
                List2.setSelectedItem("Verde");
            } else if (enteros[0] == 6) {
                color2.setBackground(Color.BLUE);
                List2.setSelectedItem("Azul");
            } else if (enteros[0] == 7) {
                color2.setBackground(violeta());
                List2.setSelectedItem("Violeta");
            } else if (enteros[0] == 8) {
                color2.setBackground(Color.GRAY);
                List2.setSelectedItem("Gris");
            } else if (enteros[0] == 9) {
                color2.setBackground(Color.WHITE);
                List2.setSelectedItem("Blanco");
            }
            //System.out.println(color2 + "  " + color + "  " + color3);
        } else {

            if (enteros[0] == 0) {
                color1.setBackground(Color.BLACK);
                //here
                List1.setSelectedItem("Negro");
            } else if (enteros[0] == 1) {
                List1.setSelectedItem("Cafe");
                color1.setBackground(cafe());
            } else if (enteros[0] == 2) {
                color1.setBackground(Color.RED);
                List1.setSelectedItem("Rojo");
            } else if (enteros[0] == 3) {
                color1.setBackground(Color.ORANGE);
                List1.setSelectedItem("Naranja");
            } else if (enteros[0] == 4) {
                color1.setBackground(Color.YELLOW);
                List1.setSelectedItem("Amarillo");
            } else if (enteros[0] == 5) {
                color1.setBackground(Color.GREEN);
                List1.setSelectedItem("Verde");
            } else if (enteros[0] == 6) {
                color1.setBackground(Color.BLUE);
                List1.setSelectedItem("Azul");
            } else if (enteros[0] == 7) {
                color1.setBackground(violeta());
                List1.setSelectedItem("Violeta");
            } else if (enteros[0] == 8) {
                color1.setBackground(Color.GRAY);
                List1.setSelectedItem("Gris");
            } else if (enteros[0] == 9) {
                color1.setBackground(Color.WHITE);
                List1.setSelectedItem("Blanco");
            }

            if (enteros[1] == 0) {
                color2.setBackground(Color.BLACK);
                //here
                List2.setSelectedItem("Negro");
            } else if (enteros[1] == 1) {
                color2.setBackground(cafe());
                List2.setSelectedItem("Cafe");
            } else if (enteros[1] == 2) {
                color2.setBackground(Color.RED);
                List2.setSelectedItem("Rojo");
            } else if (enteros[1] == 3) {
                color2.setBackground(Color.ORANGE);
                List2.setSelectedItem("Naranja");
            } else if (enteros[1] == 4) {
                color2.setBackground(Color.YELLOW);
                List2.setSelectedItem("Amarillo");
            } else if (enteros[1] == 5) {
                color2.setBackground(Color.GREEN);
                List2.setSelectedItem("Verde");
            } else if (enteros[1] == 6) {
                color2.setBackground(Color.BLUE);
                List2.setSelectedItem("Azul");
            } else if (enteros[1] == 7) {
                color2.setBackground(violeta());
                List2.setSelectedItem("Violeta");
            } else if (enteros[1] == 8) {
                color2.setBackground(Color.GRAY);
                List2.setSelectedItem("Gris");
            } else if (enteros[1] == 9) {
                color2.setBackground(Color.WHITE);
                List2.setSelectedItem("Blanco");
            }
            //System.out.println(color + "  " + color2 + "  " + color3);
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //
        /* 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(Resistencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Resistencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Resistencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Resistencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //

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

                new Resistencia().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JToggleButton Calcular;
    private javax.swing.JButton Cerrar;
    private javax.swing.JComboBox List1;
    private javax.swing.JComboBox List2;
    private javax.swing.JComboBox List3;
    private javax.swing.JButton Reset;
    private javax.swing.JLabel Resultado;
    private javax.swing.JComboBox bandas;
    private javax.swing.JLabel casco;
    private javax.swing.JButton color1;
    private javax.swing.JButton color2;
    private javax.swing.JButton color3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton multiplicadorb;
    private javax.swing.JComboBox multiplicativo;
    private javax.swing.JPanel p1;
    private javax.swing.JPanel p2;
    private javax.swing.JPanel p3;
    private javax.swing.JLabel resistencia;
    private javax.swing.JLabel tole;
    private javax.swing.JLabel tole1;
    private javax.swing.JComboBox tolerancia;
    private javax.swing.JComboBox tolerancia1;
    private javax.swing.JButton toleranciab;
    private javax.swing.JComboBox unidad;
    private javax.swing.JLabel unidad1;
    private javax.swing.JTextField valor;
    // End of variables declaration                   
}


       
 


lin del  proyecto completo... conversor  de resistencias