change icon « JComboBox « Java Swing Q&A





1. JComboBox Selection Change Listener?    stackoverflow.com

I'm trying to get an event to fire whenever a choice is made from a JComboBox. The problem I'm having is that there is no obvious addSelectionListener method. I've tried to ...

2. Changing the Contents of the JComboBox    stackoverflow.com

I would like to change the contents of the list of a JComboBox (like adding another list in place of and older one). Is there any way I might be able ...

3. How can I change the width of a JComboBox dropdown list?    stackoverflow.com

I have an editable JComboBox which contains a list of single letter values. Because of that the combobox is very small. Every letter has a special meaning which sometimes isn't clear ...

4. JComboBox getSelectedItem() not changing    stackoverflow.com

I'm binding a JComboBox to an observable List. I clear and add Objects form the observable list. This works fine and reflects the changes in the JComboBox correctly. The problem is ...

5. How do i change the UI of a JComboBox    stackoverflow.com

I like to change the UI of a JComboBox from the default metal look to some custom UI, see attached image. Sample I have tried changing all the UIDefaults ...

6. How to listen to JComboBox's width changes?    stackoverflow.com

I tried PropertyChangeListener with property set to "width", "Width", "size" and "Size".

PropertyChangeListener widthChangeListener = new PropertyChangeListener() {
            @Override
  ...

7. How can I change the arrow style in a JComboBox    stackoverflow.com

Let's say I want to use a custom image for the arrow in JComboBox, how can I do this? I understand it's possible using the synth xml files, or maybe even ...

8. Change the size of a scrollbar in JComboBox    stackoverflow.com

Does anybody know how to change the scrollbar size in jComboBox manually? I've tried a whole bunch of stuff and nothing works.

9. Change JComboBox Arrow's background color    stackoverflow.com

I found the following solution for changing a JComboBox arrow's color:

For JComboBox and Metal L&F
-- iterate recursively over the components of the JComboBox and grab a reference 
  ...





10. Changing the ControlShadow color of JComboBoxes only    stackoverflow.com

I've been asked to change the colors of a JComboBox in an application to a very particular, non-default color scheme. I've found that if I change the value of the

System.UserInterface.Colors.SwingDefaults.ControlShadow
of the ...

11. Dynamically change JComboBox    stackoverflow.com

I am fetching the data values from the database success fully. I have also stored them into a String array. I need to load the String array as the items of ...

12. Changing elements of a JComboBox according to the selection from another JComboBox    stackoverflow.com

I have a small app that generates statistic charts from a MySQL DB via JPA. To select which DB components to include in the statistic I have installed 2 JComboBoxes. First ...

13. Make a state change in one jcombobox enable a different jcombobox    stackoverflow.com

I have 7 jcomboboxes, say: customerInfo1 customerInfo2 customerInfo3 customerInfo4 customerInfo5 customerInfo6 customerInfo7 All but the first one are set to setEnabled(false) and have setSelectedItem("Please Select a Customer from the dropdown menu"). I am having the hardest time figuring out ...

14. Changing a JComboBox model unsing a ListModel. Does it have hiden consecuences?    stackoverflow.com

I use both JList and JComboBox in diferent places. The content of both change dinamicaly. Once a comboBox is created you cant just say comboBox.setModel(String[]), you have to create a new model ...

15. JCombobox change another JCombobox    stackoverflow.com

vHi all, trying to combine 2 jcomboboxes. 1 combobox is for showing category of expences. and second combobox is reading file from text file to show types of products. If i change ...

16. How to change that array of items in JComboBox at runtime    stackoverflow.com

I add a JComboBox to a JPanel (in the JComboBox constructor I load array of strings). How can I change that array at runtime, to load new items?





17. how to change UI depending on combo box selection    stackoverflow.com

In dialog I need to display one group of controls if some combo is checked and another group of controls otherwise. I.e. I need 2 layers and I need to switch ...

18. JComboBox Item Change    stackoverflow.com

My JComboBox model contains item like item1, item2, item1. My problem is when I select third item (item1) in JComboBox and check getSelectedIndex() it always returns 0. If ...

19. Change the first letter of a word to uppercase in java    stackoverflow.com

I am saving items to JComboBox from a textfield(input) when a button is clicked. The user may give the input starting with lowercase but I want to change the first letter ...

20. Changing JScrollPane on JComboboxBox    stackoverflow.com

I'm new here so please forgive me if I do something wrong... I am using Seaglass Look-and-Feel and it uses JScrollPane in case of large number of items. I would like to ...

21. JComboBox gets stuck after changing a JTextField    stackoverflow.com

I've made a GUI with JFrame which includes a JComboBox with several JTextFields. When I choose an item in the JComboBox the text fields changes their values and I am suppose ...

22. Change JTextArea color based on selected JComboBox item    stackoverflow.com

Along with a basic main thread, this will display a window with a sentence, and change the font to bold as soon as something from a drop down menu is selected. ...

23. Change JComboBox colours WITHOUT renderer    stackoverflow.com

I can change the ComboBox background color using:

UIManager.put("ComboBox.background", Color.RED);
and it works. But to change the [selected].background, having a look at Nimbus Defaults the property is called ComboBox:"ComboBox.listRenderer"[Selected].background, so I tried ...

24. How to make JRadioButtons change properties (JFrame)?    stackoverflow.com

How can I make my JRadioButton enable/disable a JComboBox in JFrame?

25. Change existing items in editable JComboBox    stackoverflow.com

I want to implement editing of the combo items, e.g. when I select 3-th item "Item 3" and it appears in the input field, I alter the string to "Item 3 ...

26. How to change displayed list in jComboBox?    forums.netbeans.org

Hello, I'm trying to change the displayed item list in a non-editable jComboBox that was generated by the netbeans palette with a default list. The name of the jComboBox is jMainComboBox. ...

28. Reverting change of jComboBox Master/Detail form    forums.netbeans.org

Hello, I've two problems with reverting changes of jComboBox in standard Master/Detail form. 1. I have method: private void jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) { if (!) { this.jComboBox2.setSelectedItem(z.getIdMj()); } } which sets (if testings failed) value of jComboBox2 back to previous value from database. Unfortunately both values (in master table and in combobox) remains with new value. How can I change value ...

32. Change color of JComboBox content    coderanch.com

Hi there, does anyone know how to change the background of a JComboBox.I tried using, the setBackground() method, works fine for a windows platform, but if I put it on a Mac, the outline of the JComboBox is set to the color that i want. But the combobox is still grey. I would like the combobox to be filled with the ...

33. Prevent user from changing display item in JComboBox ?    coderanch.com

Hi. If some conditions are fulfilled, I would like to prevent the user from selecting other items in the JCombobox list i.e. if the user clicks on another item other than the default one in setSelectedIndex, the display will not change and stay the same e.g. String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" }; //Create the combo box, select ...

35. changing contents of a combo box    coderanch.com

maybe this will help. Here is a quick and dirty example of my problem. package testing; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class comboTest extends JFrame { private Vector v; JComboBox cb; public comboTest() { super("duper"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = myComboPanel(); getContentPane().add(p); setSize(400, 200); } public void changeBox() { v = new Vector(); v.add("1"); v.add("2"); v.add("3"); v.add("4"); cb ...

36. Change the background of combobox in disabled mode    coderanch.com

Hi all, How do i change the background color of the combobox to white in disabled mode. I have used UIManager.put ( "ComboBox.disabledBackground", Color.WHITE ); This is actually making the background color of the combo box to white. But the problem is when i apply this, the background color of the combo box is changed to white throughout the application. I ...

37. Changing Combo box Model    coderanch.com

38. How to persuade a JComboBox to change its selected item    coderanch.com

final Vector

addresses = new Vector
(); rs.beforeFirst(); // type ResultSet while (rs.next()) { addresses.add(new Address(rs.get . . .)); } myAddress = addresses.get(0); // type Address . . . addressBox = new JComboBox(addresses); addressBox.setMaximumRowCount(10); // addressBox.setEditable(true); // addressBox.setEnabled(true); . . . addressBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { myAddress = (Address) addressBox.getSelectedItem(); System.out.printf("Item state changed: %d %s %s%n", addressBox.getSelectedIndex(), ...

42. Problem in Changing size of JComboBox    coderanch.com

Hi, I'm new to java Applets.I'm trying to implement an expert system with the help of jess and java Applets. My applet have 2 "JComboBox" objects. I have used the grid layout as a layout manager. I want to set size of the "combobox" , because it appears too large and very ugly. (Actually i want to arrange the things in ...

43. Using a JComboBox to change the contents of another JComboBox    coderanch.com

Hello, I'm new by the way. I would like to make a JComboBox change the contents of another JComboBox when one of it's values has been selected with the mouse. Not really sure how to go about this (I'm the grandfather of the original newb) So far, my code is this; import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Main extends ...

44. JComboBox display issue when changing models    coderanch.com

I am having a display issue when changing list elements within a model that is attached to a JComboBox. Using the attached code, perform the following: launch code. click on button "list2" select any element in the Combobox. click on button "list1". try to select an element in the combobox. the popup display is of the correct length, but the list ...

45. changing the border of a JComboBox    java-forums.org

I'm not talking about the normal border of the combo box but about the border of the selection menu. When I click at the JComboBox, a JList pops up like a drop down selection menu. But it is always surrounded by a thin black line border. Is it possible to change the color of the border? Or even remove it? Changing ...

46. How to change font/ font color etc in a graphic object using JCombobox?    java-forums.org

Hello My program im writing recently is a small tiny application which can change fonts, font sizes, font colors and background color of the graphics object containing some strings. Im planning to use Jcomboboxes for all those 4 ideas in implementing those functions. Somehow it doesnt work! Any help would be grateful. So currently what ive done so far is that: ...

47. JComboBox problem, when I choose an Item .. items wont change!    forums.oracle.com

In your itemStateChanged() override, you are only testing to see if the source is meals, which you have as a string array and that can't generate an item event, at least not to my knowledge. I think you probably meant to test it for av, your JComboBox. Replace if (s == meals) with if (s == av)

49. Please help > JComboBox how to change the string [ ]    forums.oracle.com

Hi, I have declared a combo box without an string [ ] 'cos I need other methods to formula the string 1st. Then I add it into a JPanel. itemsCombo = new JComboBox(); displayPanel.add(arms2Combo, f); After I finally got the string, how can I now add the string [ ] into the JComboBox? I have tried String [] stuff= {"N1", "N2", ...

50. help with detecting changes in jcomboboxes    forums.oracle.com

51. How to Change all Items of JComboBox    forums.oracle.com

thanks, i have read it, but there is a problem with my code. i wrote this: XerxesMain.langlist.setModel(new DefaultComboBoxModel(insertItemAt(ShockCfg.txt.getString("MainDeuLang"), 0), insertItemAt(ShockCfg.txt.getString("MainEngLang", 1)))); and now I get the following errors: ./SetRes.java:63: cannot find symbol symbol : method insertItemAt(java.lang.String,int) location: class SetRes XerxesMain.langlist.setModel(new DefaultComboBoxModel(insertItemAt(ShockCfg.txt.getString("MainDeuLang"), 0), insertItemAt(ShockCfg.txt.getString("MainEngLang", 1)))); ^ ./SetRes.java:63: getString(java.lang.String) in java.util.ResourceBundle cannot be applied to (java.lang.String,int) XerxesMain.langlist.setModel(new DefaultComboBoxModel(insertItemAt(ShockCfg.txt.getString("MainDeuLang"), 0), insertItemAt(ShockCfg.txt.getString("MainEngLang", 1)))); ^ ./SetRes.java:63: ...

52. Change the size of Scrollbar in JComboBox    forums.oracle.com