Convertion of Decimal to Binary, Octal, and Hexadecimal in Applet
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SampleGui extends JApplet{
JLabel lblDec, lblBin, lblOct, lblHex;
JTextField txtDec, txtBin, txtOct, txtHex;
JButton btnConvert, btnContinue, btnExit;
Container con;
JFrame f;
public void init()
{
int i;
String Number;
Number=JOptionPane.showInputDialog(null,"Enter the decimal value!: ");
i=Integer.parseInt(Number);
con = getContentPane();
con.setLayout(new GridLayout(5,2));
con.setSize(20,20);
lblBin = new JLabel( "Binary:");
con.add( lblBin );
txtBin = new JTextField( Integer.toBinaryString(i) );
txtBin.setEditable( true );
con.add( txtBin );
lblOct = new JLabel( "Octal:" );
con.add( lblOct );
txtOct = new JTextField( Integer.toOctalString(i) );
txtOct.setEditable( true );
con.add( txtOct );
lblHex = new JLabel( "Hexadecimal:" );
con.add( lblHex );
txtHex = new JTextField( Integer.toHexString(i).toUpperCase() );
txtHex.setEditable( true );
con.add( txtHex );
btnConvert = new JButton("Convert");
btnConvert.setSize(5,5);
con.add(btnConvert);
btnExit = new JButton("Exit");
con.add(btnExit);
}
}

