• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Java Programming Help (conversions)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:



 
Marshal
Posts: 80775
489
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 80775
489
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic