/** IMAGEN DE PROGRAMA EN EJECUCION **/
/** PROGRAMA JAR EJECUTABLE SI TIENES JAVA **/
http://www.4shared.com/file/YhUm3tF1/Convertidor.html
/** PROYECTO PARA LEVANTAR EN NETBEANS **/
http://www.4shared.com/file/1nRX6IiM/Convertidor.html
/** Espero le sea de utilidad el código que posteare a continuación **/
********************************************************************
* CODIGO DE LA INTERFAZ GRÁFICA DE USUARIO *
********************************************************************
/*
* Codigo creado y modificado por ZoidHack
* Elvis Leonardo Pérez Alcántara
* elvis_1245@hotmail.com
* Ultima fecha de modificacion : 19 - 04 - 2011
*/
package convertidor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Ventana extends JFrame
{
private JLabel etiqueta[] = new JLabel[3];
private JTextField campo[] = new JTextField[3];
private GridBagLayout gbl = new GridBagLayout();
private GridBagConstraints cons = new GridBagConstraints();
public Ventana()
{
super("Producciones TIBITO");
Preparar();
Eventos();
GUI();
setSize(300,400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void GUI()
{
Container contenedor = getContentPane();
contenedor.setLayout(gbl);
cons.fill = GridBagConstraints.HORIZONTAL;
cons.weightx = 0.1;
cons.weighty = 1.0;
cons.gridx = 0;
cons.gridy = 0;
contenedor.add(etiqueta[0],cons);
cons.gridx = 0;
cons.gridy = 1;
contenedor.add(etiqueta[1],cons);
cons.gridx = 0;
cons.gridy = 2;
contenedor.add(etiqueta[2],cons);
cons.weightx = 1.0;
cons.gridx = 1;
cons.gridy = 0;
contenedor.add(campo[0],cons);
cons.gridx = 1;
cons.gridy = 1;
contenedor.add(campo[1],cons);
cons.gridx = 1;
cons.gridy = 2;
contenedor.add(campo[2],cons);
}
private void Eventos()
{
campo[0].addKeyListener(
new KeyListener() {
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
try
{
String a = campo[0].getText();
if( a.equals("") )
{
campo[1].setText("");
campo[2].setText("");
}
int n = Integer.parseInt( a );
campo[1].setText( Funciones.DectoHexadecimal( n ) );
campo[2].setText( Funciones.DectoBinario( n ) ) ;
}
catch(NumberFormatException N)
{
JOptionPane.showMessageDialog(null, "Cadena ingresada no representa un numero.");
campo[0].setText("");
}
}
});
campo[1].addKeyListener(
new KeyListener() {
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
try
{
String n = campo[1].getText();
if( n.equals("") )
{
campo[0].setText("");
campo[2].setText("");
}
campo[0].setText( Funciones.HextoDecimal( n ) );
campo[2].setText( Funciones.HextoBinario( n ) ) ;
}
catch(NumberFormatException N)
{
JOptionPane.showMessageDialog(null, "Cadena ingresada no representa un numero.");
campo[0].setText("");
}
}
});
campo[2].addKeyListener(
new KeyListener() {
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
try
{
String n = campo[2].getText();
if( n.equals("") )
{
campo[0].setText("");
campo[1].setText("");
}
campo[0].setText( Funciones.BintoDecimal( n ) );
campo[1].setText( Funciones.BintoHexadecimal( n ) ) ;
}
catch(NumberFormatException N)
{
JOptionPane.showMessageDialog(null, "Cadena ingresada no representa un numero.");
campo[0].setText("");
}
}
});
}
private void Preparar()
{
etiqueta[0] = new JLabel("Decimal : ");
etiqueta[1] = new JLabel("Hexadecimal : ");
etiqueta[2] = new JLabel("Binario : ");
for(int i = 0; i< campo.length; ++i)
campo[i] = new JTextField();
}
private String DectoBinario(int n)
{
String dev = "";
while(n > 0)
{
dev += (n&1);
n >>= 1;
}
StringBuffer dev1 = new StringBuffer(dev);
dev = dev1.reverse().toString();
return dev;
}
}
*****************************************************************************
* CODIGO DE LA CLASE QUE CONTIENE LAS FUNCIONES *
* DE CONVERSION ENTRE SISTEMAS *
*****************************************************************************
package convertidor;
/*
* Codigo creado y modificado por ZoidHack
* Elvis Leonardo Pérez Alcántara
* elvis_1245@hotmail.com
* Ultima fecha de modificacion : 19 - 04 - 2011
*/
public class Funciones
{
public static String DectoBinario(int n)
{
return Integer.toBinaryString(n);
}
public static String DectoHexadecimal(int n)
{
return Integer.toHexString(n).toUpperCase();
}
public static String HextoDecimal(String n)
{
Integer dev = Integer.parseInt( n , 16 );
return dev.toString();
}
public static String BintoDecimal(String n)
{
Integer dev = Integer.parseInt( n , 2 );
return dev.toString();
}
public static String BintoHexadecimal(String n)
{
Integer dev = Integer.parseInt( n , 2 );
String dev1 = DectoHexadecimal(dev);
return dev1;
}
public static String HextoBinario(String n)
{
Integer dev = Integer.parseInt( n , 16 );
String dev1 = DectoBinario(dev);
return dev1.toString();
}
}
/*** Posteen sus dudas, y si necesitan aplicaciones ya saben ps, me comunican y alli arreglamos xD... **/
http://www.4shared.com/file/YhUm3tF1/Convertidor.html
/** PROYECTO PARA LEVANTAR EN NETBEANS **/
http://www.4shared.com/file/1nRX6IiM/Convertidor.html
/** Espero le sea de utilidad el código que posteare a continuación **/
********************************************************************
* CODIGO DE LA INTERFAZ GRÁFICA DE USUARIO *
********************************************************************
/*
* Codigo creado y modificado por ZoidHack
* Elvis Leonardo Pérez Alcántara
* elvis_1245@hotmail.com
* Ultima fecha de modificacion : 19 - 04 - 2011
*/
package convertidor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Ventana extends JFrame
{
private JLabel etiqueta[] = new JLabel[3];
private JTextField campo[] = new JTextField[3];
private GridBagLayout gbl = new GridBagLayout();
private GridBagConstraints cons = new GridBagConstraints();
public Ventana()
{
super("Producciones TIBITO");
Preparar();
Eventos();
GUI();
setSize(300,400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void GUI()
{
Container contenedor = getContentPane();
contenedor.setLayout(gbl);
cons.fill = GridBagConstraints.HORIZONTAL;
cons.weightx = 0.1;
cons.weighty = 1.0;
cons.gridx = 0;
cons.gridy = 0;
contenedor.add(etiqueta[0],cons);
cons.gridx = 0;
cons.gridy = 1;
contenedor.add(etiqueta[1],cons);
cons.gridx = 0;
cons.gridy = 2;
contenedor.add(etiqueta[2],cons);
cons.weightx = 1.0;
cons.gridx = 1;
cons.gridy = 0;
contenedor.add(campo[0],cons);
cons.gridx = 1;
cons.gridy = 1;
contenedor.add(campo[1],cons);
cons.gridx = 1;
cons.gridy = 2;
contenedor.add(campo[2],cons);
}
private void Eventos()
{
campo[0].addKeyListener(
new KeyListener() {
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
try
{
String a = campo[0].getText();
if( a.equals("") )
{
campo[1].setText("");
campo[2].setText("");
}
int n = Integer.parseInt( a );
campo[1].setText( Funciones.DectoHexadecimal( n ) );
campo[2].setText( Funciones.DectoBinario( n ) ) ;
}
catch(NumberFormatException N)
{
JOptionPane.showMessageDialog(null, "Cadena ingresada no representa un numero.");
campo[0].setText("");
}
}
});
campo[1].addKeyListener(
new KeyListener() {
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
try
{
String n = campo[1].getText();
if( n.equals("") )
{
campo[0].setText("");
campo[2].setText("");
}
campo[0].setText( Funciones.HextoDecimal( n ) );
campo[2].setText( Funciones.HextoBinario( n ) ) ;
}
catch(NumberFormatException N)
{
JOptionPane.showMessageDialog(null, "Cadena ingresada no representa un numero.");
campo[0].setText("");
}
}
});
campo[2].addKeyListener(
new KeyListener() {
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
try
{
String n = campo[2].getText();
if( n.equals("") )
{
campo[0].setText("");
campo[1].setText("");
}
campo[0].setText( Funciones.BintoDecimal( n ) );
campo[1].setText( Funciones.BintoHexadecimal( n ) ) ;
}
catch(NumberFormatException N)
{
JOptionPane.showMessageDialog(null, "Cadena ingresada no representa un numero.");
campo[0].setText("");
}
}
});
}
private void Preparar()
{
etiqueta[0] = new JLabel("Decimal : ");
etiqueta[1] = new JLabel("Hexadecimal : ");
etiqueta[2] = new JLabel("Binario : ");
for(int i = 0; i< campo.length; ++i)
campo[i] = new JTextField();
}
private String DectoBinario(int n)
{
String dev = "";
while(n > 0)
{
dev += (n&1);
n >>= 1;
}
StringBuffer dev1 = new StringBuffer(dev);
dev = dev1.reverse().toString();
return dev;
}
}
*****************************************************************************
* CODIGO DE LA CLASE QUE CONTIENE LAS FUNCIONES *
* DE CONVERSION ENTRE SISTEMAS *
*****************************************************************************
package convertidor;
/*
* Codigo creado y modificado por ZoidHack
* Elvis Leonardo Pérez Alcántara
* elvis_1245@hotmail.com
* Ultima fecha de modificacion : 19 - 04 - 2011
*/
public class Funciones
{
public static String DectoBinario(int n)
{
return Integer.toBinaryString(n);
}
public static String DectoHexadecimal(int n)
{
return Integer.toHexString(n).toUpperCase();
}
public static String HextoDecimal(String n)
{
Integer dev = Integer.parseInt( n , 16 );
return dev.toString();
}
public static String BintoDecimal(String n)
{
Integer dev = Integer.parseInt( n , 2 );
return dev.toString();
}
public static String BintoHexadecimal(String n)
{
Integer dev = Integer.parseInt( n , 2 );
String dev1 = DectoHexadecimal(dev);
return dev1;
}
public static String HextoBinario(String n)
{
Integer dev = Integer.parseInt( n , 16 );
String dev1 = DectoBinario(dev);
return dev1.toString();
}
}
/*** Posteen sus dudas, y si necesitan aplicaciones ya saben ps, me comunican y alli arreglamos xD... **/

