• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I add RadioButton to my Account class?

 
Aneeqa Rustam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my assignment and I really need help. Add two radio buttons so that the user can select the gender (male or female). Also extend your Account class so that it contains the gender information as well. When the user presses “Submit”, your program should read the entered data and create an Account object that captures all the data in your interface.
This is my code, what would I need to add in order to make a RadioButton?

 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the JRadioButton, did you consult the java tutorials here?

For the Account class, what attributes do you have in it?

Does "Account" represent the bank's checking or savings account or something more?
 
Aneeqa Rustam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what is within the Account

 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that's a class where you store your Account data. If you're looking for a place to add a radio button, you wouldn't add it to that class. Haven't you written some GUI code already? (The assignment description suggests to me that you have.) Then you should add the radio button to that GUI code.
 
Campbell Ritchie
Marshal
Posts: 52587
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aneeqa Rustam wrote:. . .
That sort of comment is unnecessary; it says nothing more than the code does and such comments should be avoided completely
That is total nonsense. You are not initialising anything there, but in the constructor.
You do not have a private class at all and private classes do not constitute data hiding.

What you are doing is declaring the field as private for data hiding. Long comments like that should be in /* form */

. . .
That is a serious mistake making that field public.
. . .
Another inane comment which should be removed. And inaccurate: you are initialising the Scanner field local variable.

You do not want to add a radio button to the account class, as Paul C has already told you. You add it to the GUI. Or more precisely you probably don't add it to the GUI because you probably want an ordinary button not a radio button.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!