• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

two really important questions

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
------------------
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You can use requestFocus method of JTextField
for cursor display during startup of the
JWindow.You can do this part in
WindowListener's windowOpened method.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic