Omnimaga
General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: Munchor on December 20, 2010, 07:09:01 pm
-
Hey everyone, Ashbad challenged me to finish something by yesterday (10 minutes) ago but I failed. However, here I am uploading a Java program (two actually) that convert Binary to Decimal or Decimal to Binary.
What's so special about it?
1. I made it;
2. It was made in Java;
3. It's a .jar file super fast;
4. It has got a Graphical User Interface;
5. It is easy and simple to convert.
I have a request for you: download it and run it. It takes you 3 seconds to open this program just so that you see what it is :)
-
What was ashbad's challenge? and downloaded, they look nice
edit: though i'd suggest looking through the input strings to make sure you didn't put in ABCDEF and tried to convert it from binary to decimal.
edit2: what was the source, by the way?
-
What was ashbad's challenge? and downloaded, they look nice
edit: though i'd suggest looking through the input strings to make sure you didn't put in ABCDEF and tried to convert it from binary to decimal.
edit2: what was the source, by the way?
When you enter letters, it won't compile. Too large numbers won't compile too:
Also, Ashbad's challenge was to release another program in that day (yesterday), but it's past Midnight now :(
//Imports
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main {
public static void main(String[] args) {
JFrame frame= new JFrame("MagiConverter");
JPanel panel=new JPanel();
final JLabel title = new JLabel("MagiConverter - Binary to Decimal");
JLabel empty = new JLabel(" ");
final JTextField inputDecimal = new JTextField(25);
final JTextField outputBinary = new JTextField(25);
JButton convertButton = new JButton("Convert");
convertButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
String inputDecimalString = inputDecimal.getText();
int inputDecimalNumber;
inputDecimalNumber = Integer.parseInt(inputDecimalString);
int outputBinaryNumber = Integer.parseInt(inputDecimalString,2);
outputBinary.setText(Integer.toString(outputBinaryNumber));
}
});
frame.add(panel);
panel.add(title);
panel.add(empty);
panel.add(empty);
panel.add(inputDecimal);
panel.add(convertButton);
panel.add(outputBinary);
frame.setSize(300,220);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);;
}
}
I'll post the other one in a second.
EDIT: Here it it is:
//Imports
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main {
public static void main(String[] args) {
JFrame frame= new JFrame("MagiConverter");
JPanel panel=new JPanel();
final JLabel title = new JLabel("MagiConverter - Decimal to Binary");
JLabel empty = new JLabel(" ");
final JTextField inputDecimal = new JTextField(25);
final JTextField outputBinary = new JTextField(25);
JButton convertButton = new JButton("Convert");
convertButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
String inputDecimalString = inputDecimal.getText();
int inputDecimalNumber;
inputDecimalNumber = Integer.parseInt(inputDecimalString);
String outputBinaryNumber = Integer.toBinaryString(inputDecimalNumber);
outputBinary.setText(outputBinaryNumber);
}
});
frame.add(panel);
panel.add(title);
panel.add(empty);
panel.add(empty);
panel.add(inputDecimal);
panel.add(convertButton);
panel.add(outputBinary);
frame.setSize(300,220);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);;
}
}
-
Nice I guess that can be kinda useful sometimes when you don't want to search for a converter site everytime you want to convert a huge string of data to hex to paste in an Axe program.
-
Nice I guess that can be kinda useful sometimes when you don't want to search for a converter site everytime you want to convert a huge string of data to hex to paste in an Axe program.
Yes, it's more for personal use :)