After selecting an item from a JComboBox, i want to keep the JComboBox still opened to allow the user to choose another item from it. Is that possible ?
I hope you can provide me an example.
Perhaps what you are after is a JList instead.
As a different approach, maybe you can display in the JComboBox only the "allowed to choose" items in first place?
Related
I am using multiple JComboBox in a single JPanel. I was wondering what is the go to initial JComboBox selection text?
For example I can put "None" but that will seem as if some value is already selected in the JComboBox. I am using labels for which type of data they are so writing their type is unnecessary.
I can either put "" but something like "----" seems better. Is there a standard text when you want the user to select some value from JComboBox?
If you want to set an initial value to JComboBox that should be non-selectable (as soon as user selects another option, it will not be possible to select the initial one again), than it has been already answered here.
One way is to use a custom renderer. The renderer will simply display a default prompt when no item of the combo box has been selected.
Check out Combo Box Prompt for an example of this approach.
how can I create (with JAVA) Combobox that contains Checkboxes for multiple selection and display the selected items in the Combobox like this picture:
click to see the pic
and thnx for advance.
EDIT:
I found this API (JAPURA API) and it's great but when I select multiple things I want to display the selected items instead of "* multiple items *".
Here's the link to achieve your goal:
JComboBox Providing a Custom Renderer
I would suggest you create a JButton and style it in the form of a Combobox if you want that.
Then, at the onclick function (actionperformed), you create a JPanel and make it visible under the button. In the panel, you can put whatever you want, so you just put checkboxes there.
I know this is kind of a workaround of your problem, but it should be easy for you to do so, and the actual user does not see a difference at all.
Hope I could help you.
Cheers,
Lucky
On Netbeans, I have a jDialog with a jComboBox populated from values coming from a Java Enumeration. I need the default value of the Combo Box to be blank at start (or null or whatever), this way forcing the user to choose for a valid option. I have "selectedIndex" set to -1 but still the default value is my first enumeration value. So how can I have my Combo Box load with no value selected?
Thank you very much for your help.
Cheers.
You need to remove and re-add the ItemListener as suggested in this answer to a similar question.
is their any way to set text for a combo box, which is not an element of the combobox.
cboSubjects=new JComboBox();
cbo.addItem("Maths"); // and few more subjects are added
cbo.setSelectedItem("subjects"); // this does not set the default text of combobox
Is their any way to solve this problem ? I need something which works like combobox.text
property of combobox in visual basic
I am working on school management system. I need help.
I'd like to show you a possible alternative :)
Note, you need to call label.setDisplayedMnemonic('s'); and label.setLabelFor(combo) to complete the effect!
You can make jComboBox editable, cbo.setEditable(true);, and after that set the text you want: cbo.setSelectedItem("subjects");
I want to make my JList editable, what should I do?
Use a 1-column JTable instead.
List Editor
You can find the source code for an editable list here:
http://www.java2s.com/Code/Java/Swing-Components/EditableListExample.htm
Depending on your use case an JComboBox, which is editable, might be a better solution than a JList.