• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Programming Help (conversions)

 
James Wmurphy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently writing a program which will perform binary to decimal, decimal to binary, hexadecimal to decimal, decimal to hexadecimal conversions, 1's compliment, 2's compliment, and show the list of boolean algebra rules.

I have created the GUI however, I cannot figure out how to make the Jbuttons generate the coding needed for a binary to decimal conversion of the input in a JTextField. The code is below:



 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch It seems appropriate to have a Wmurphy signed on on 17th March

What is the logic for converting, eg binary to denary (decimal) without using a button? I presume you are doing the conversion yourself and not using % tags in the format or printf methods?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't want to have lots of frames inside your actionPerformed methods. You have one frame with lots of buttons attached; each button has its own Listener. That Listener calls a method to read the number, one to convert it and one to display it.
 
James Wmurphy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know my formatting isn't the best , but it also shows my level of expertise with dealing with Java on a GUI level. If you could help me format my existing code as well as show me how to convert user input from binary to decimal, it would greatly be appreciated.
 
Henry Wong
author
Marshal
Pie
Posts: 21185
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Wmurphy wrote:I know my formatting isn't the best , but it also shows my level of expertise with dealing with Java on a GUI level. If you could help me format my existing code as well as show me how to convert user input from binary to decimal, it would greatly be appreciated.


Maybe it would be a good idea to not use GUI first -- say just work out a very simple method that will convert a number from one base to another. Once you get that working, then you can attach it to a GUI.

Henry

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic