This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HOw to make Jcombobox mandatory?  RSS feed

 
Raji Raj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using JCOmboBox.I just want to indicate to the user that he should select anyone value.so i need to make Jcombobox as madatory field.is there anyway to do it?please give me suggesstions.

Thanks,
Raji
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you can use the Combo Box Prompt.

This won't force the user to select anything but will give them a visual clue to select something.

Then when the user clicks on the "Save" button, you get the selected index of the combo box. If the value is 0, then you display a JOptionPane requesting the user to make a selection.

This approach can be used for any component. That is you can also check text fields to make sure text has been entered in required text fields.
 
Raji Raj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply...but my requirement is to display * in combobox to indicate user that its a Mandatory field.

I will do all those validations while clicking save button.


is there any way to do display * in combobox?

Thanks.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can display the * in the label field, why have it in the combobox itself?
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check your private messages.
 
Raji Raj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in combox whether we will be able to do it or not?
Thanks i changed last name.
 
Rob Spoor
Sheriff
Posts: 21089
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raji Raj, please follow Amit's instructions:
Amit Ghorpade wrote:Please check your private messages.
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For functionality like this you would generally add a JLabel beside the JComboBox with "*" as the text.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!