This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Adding .binary and hexidecimal to an answer from a calculation  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

aButton3.addActionListener(new ActionListener()
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);
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 ]
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!