1) I have several jtextfields in a Jwindow , my major problem I cannot get the cursor to appear in the first jtextfield , the user would need to click on it this doesnt look too professional. I can I solve this? 2) Under the above jtextfields there are 3 jradiobuttons which are included in a buttongroup. The user has the option of picking one of the 3, but this is optional. My problem if someone happens to pick one and then decides he no longer wishes to he is unable to remove his choice. How can i bring the radiobuttons to their original state? I have tried ButtonGroup.setSellected(ButtonModel button1, false); repaint(); but with no success can someone please help thank u all and a great new year ------------------
Ans 1) You can explicitly set focus to the textfield using textfield.requestFocus(); when your app loads. Note: this works only in application & not in applet, which is a bug in JDK. Ans2) I don't understand how the user is not able to select another choice, could u pls post ur code, because in normal cases in a buttongroup u can select only "1 at a time", so after selecting one, if you want to select another u can do so but the previous selection goes.
For your second you could always add a radio button option for none. I have noticed it as well and copped out with adding a none option. So I haven't actually spent alot of time trying. I tried what you did and it didn't work. But since the option had to be something the user did I just added another radio button.
For the question#2. I paste sth. from sun tutorial
You should generally initialize a group of radio buttons so that one is selected. However, the API doesn't enforce this rule -- a group of radio buttons can have no initial selection. Once the user has made a selection, exactly one button is selected from then on. There's no supported API for unselecting all the buttons. However, if you really want to unselect all the buttons (not that we recommend it), invoking setSelected(null, true) on the ButtonGroup should do the trick.
I tryed myButtongroup.setSelected(null, true); It works but not very well... Good luck!
HI, Why not associate a listener with each radio button and if a button is clicked when it is already selected call that null method on the group. That way the user can alter the selection or undo the selection they just made. I suggest you include a tooltip to explain that functionality as it's not what all users may think of. Hope that helps, Terry