Author Topic: MagiConverter  (Read 3118 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
MagiConverter
« 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.

Quote from: What you are thinking right now
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 :)



Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: MagiConverter
« Reply #1 on: December 20, 2010, 07:13:16 pm »
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?
« Last Edit: December 20, 2010, 07:14:42 pm by nemo »


Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: MagiConverter
« Reply #2 on: December 20, 2010, 07:16:45 pm »
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 :(

Code: [Select]
//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:

Code: [Select]
//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);;
        }
    }
« Last Edit: December 20, 2010, 07:19:04 pm by ScoutDavid »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: MagiConverter
« Reply #3 on: December 21, 2010, 02:56:08 pm »
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.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: MagiConverter
« Reply #4 on: December 21, 2010, 03:00:32 pm »
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 :)