This week's book giveaway is in the Cloud/Virtualizaton forum.We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!

Johnny Gambles
Greenhorn
Posts: 2
Hi guys, sorry if this is too much of a beginners question to be in here, but I'm trying to add a binary and hexidecimal method to a string. But the string has a comment which has writing in it. So I was just wondering how to change this for use in a calculator

For example here is my multiply button

{
public void actionPerformed(ActionEvent b)
{
int z;
x = Integer.parseInt(aTextField1.getText());
y = Integer.parseInt(aTextField2.getText());
z = x * y;
String c = new String(x + " x " + y + " = " + z);
aTextField3.setText(c);
aButton3.setPreferredSize(new Dimension(x, y));
}
});

This is just one of my 7 buttons used, I wont quote them all for space, but I needed a button which will use the .toHexString and .toBinaryString to the 'atextField3'

THe user will enter data in text field a, then in text field b and then recieve an answer along the lines of "12 + 12 = 24" in text field c. In the field d I want to get the answer from text field c and change that into binary. Also the text field c MUST have "12 + 12 = 24" in it without fail

If any help can be issued, I'll be majorly greatful, thanks!
[ March 17, 2006: Message edited by: Johnny Gambles ]

Charles Lyons
Author
Ranch Hand
Posts: 836
So you know the values of the two original numbers (x and y), so why don't you just convert those, then place the result in field D - just as you did with field C? For example, suppose 'x' and 'y' represent the values of the fields A and B, then (adjust my variable names as appropriate):

Does that help?