-1

I've been searching for all codes in the internet, but all I see is for Buffered Reader. Is it possible to have it in a JFrame format? I am new to Java and I wanted to create this program which will convert a decimal number to binary and vice versa. Can you help me how to do it?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Ms. B
  • 1,073
  • 6
  • 15
  • 26
  • What have you tried? Have you got a Frame? Input/Outputs? [this previous question might be of some help](http://stackoverflow.com/questions/5203974/converting-decimal-to-binary-in-java) – AerusDar Feb 05 '13 at 00:21
  • Ye I have tried something like that but what I wanted to do is to use a GUI. I mean is it still the same process? And I was adding up some JOptionPane too. – Ms. B Feb 05 '13 at 01:20
  • There is no such thing as 'convert decimal to binary numbers in Java using JFrame'. Your question makes zero sense. – user207421 Feb 05 '13 at 07:02
  • JFrame is the GUI and what I want is to create a conversion program with a GUI. If you misunderstood my question well I am sorry. But this question is already answered. Others don't mind how the question is imposed, as long as they can answered the question properly, it STILL make sense. – Ms. B Feb 06 '13 at 01:23
  • There is nothing to understand. A contradiction in terms cannot be understood. You need to clarify your question, not shoot the messenger. – user207421 Apr 06 '17 at 23:49

1 Answers1

2

Converting and rendering (displaying) are completely unrelated issues.

To convert, use Integer.parseInt() and Integer.toBinaryString():

String input = "10"; // some number as your input
int i = Integer.parseInt(input);
String binary = Integer.toBinaryString(i);

To display, put that String into the display area (too trivial to bother with here)

Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • Can i put "String input;" rather than placing a specific number? What I want is that, when a user enter a number in a JTextField, it will convert to a binary and vice versa. I tried copying what I see in some sites using BufferedReader but I keep getting errors – Ms. B Feb 05 '13 at 01:22
  • 1
    My code is just an example that compiles. You would get your input from the text field, something like `String input = textField.getText();` – Bohemian Feb 05 '13 at 03:29