Hey guys,
Here's my problem:
I developed some code that converts binary to characters and characters to binary. At first all went well (by first I mean on the good ol' console), but when i tried implementing a GUI, some weird stuff came up.
When I try converting characters (strings to be more exact), the output for the binary goes swell, but when I try doing the opposite, it either catches an Exception or it erases the text from the Binary JTextArea and leaves nothing on the Text JTextArea (Text is the TextArea ASCII characters are supposed to be written on).
Since the code is pretty long and (probably) very buggy, I'm uploading the entire code as an attachment.
I have a vague idea of where the problem is:
if(!focusBool) {
inputBinary = binArea.getText();
binArea.setText(inputBinary);
try {
outputBinary = Bin2String(inputBinary);
}
catch(Exception exc) {
JOptionPane.showMessageDialog(null,
errorMessage, "Invalid Data",
JOptionPane.ERROR_MESSAGE);
}
textArea.setText(outputBinary);
}
else {
inputString = textArea.getText();
textArea.setText(inputString);
try {
outputString = String2Bin(inputString);
}
catch(Exception exc) {
JOptionPane.showMessageDialog(null,
errorMessage, "Invalid Data",
JOptionPane.ERROR_MESSAGE);
}
binArea.setText(outputString);
}
}
Not sure though. Could be a problem in the actual conversion.
Another interesting thing I thought would be worth mentioning. When I debug the Binary JTextArea with small binary numbers, such as "01010100", it actually returns "T", but the same doesn't apply when trying "01010100"(x11). Overflow, maybe?
I would recommend actually compiling my code, since there are plenty of bugs that I could have a hand with.
All help is very welcome.
Thank you in advance,
~Renato
P.S.: Using NetBeans 7.0 and on Vista.