aspose file tools*
The moose likes Java in General and the fly likes Java Programming Help (conversions) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Programming Help (conversions)" Watch "Java Programming Help (conversions)" New topic
Author

Java Programming Help (conversions)

James Wmurphy
Greenhorn

Joined: Mar 17, 2010
Posts: 2
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

Joined: Oct 13, 2005
Posts: 38793
    
  23
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

Joined: Oct 13, 2005
Posts: 38793
    
  23
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

Joined: Mar 17, 2010
Posts: 2
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
Sheriff

Joined: Sep 28, 2004
Posts: 18829
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Programming Help (conversions)