JComboBox 1 « JComboBox « Java Swing Q&A





1. why this code about combobox doesn't work?    stackoverflow.com

I have a combobox which stores "Computer ,Code:21","History ,Code:31" and also the number of items can be changed.but when I write this code for getting its items:

List<String> bIHELessons = new ArrayList<String>();
for ...

2. Where can I find features in a jComboBox that are found in the .NET ComboBox?    stackoverflow.com

i am .net c# programmer that wanna learn Java these days.I can connect DB , getting and writing data with JDBC.But How can i fill JComboBox and set its DisplayMember ...

3. Swing combo boxes    stackoverflow.com

Alright, so I'm simply defining a combo box like so...

JComboBox yearSelect = new JComboBox(); 
Now, I have not even added this to a panel or anything, I've just defined it. When ...

4. Invisible JComboBox    stackoverflow.com

I have a little problem. I had some JComboBox to a JDialog but they won't show up ... Moreover I can select them (see the pic). alt text And here's my code ...

5. custom JComboBox top label    stackoverflow.com

Hopefully an easy question. From the example on http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/combobox.html on "Providing a Custom Renderer" section, I can make a JComboBox like

Picture 3 - Text 3
-------------------
Picture 1 - Text 1
Picture 2 ...

6. JComboBox causes a runtime error    stackoverflow.com

I'm trying some GUI development in Java and when I added the following code, I got a runtime error during initialization of the class:

public class Search_Album_Main_Tab extends JPanel{
    ...

7. Cycle through jComboBox    stackoverflow.com

I have a bunch of jComboBox in a panel. What is the best way to cycle through the panel and set setSelectedIndex(0) for each of the controls?

8. JComboBox not showing results    stackoverflow.com

i am trying to set the values in a JCombobox based on a for and if loop, on an arraylist.

     //salesman=the name of the combobox
   ...

9. How to create JcomboBoxes with different reaction?    stackoverflow.com

My Problem is that every JComboBox in the SyntaxPanel is the same! I thought i could iterate over the name of the comboBox but this dont change anything. Maybe i should add it ...





10. Clojure proxy of JComboBox and IDeref gives a java.lang.VerifyError    stackoverflow.com

Somewhere in my code, I do this:

(proxy [JComboBox IDeref] []
  (deref [] (.getSelectedItem this)))
While on my machine this works fine, some users reported the following problem:
java.lang.VerifyError: class ggo.igs.gui.widgets.proxy$javax.swing.JComboBox$IDeref$db53459f 
  ...

11. How can I create several related JComboboxes?    stackoverflow.com

I want to create three JComboboxes and link them together. For example, in this picture: university, college and department JComboboxes when a selection is made for "university," the college combobox should ...

12. my jComboBox does not react properly     stackoverflow.com

I am having an editable jCombobox , and it will search for selected users if you enter something inside and click enter, this is my code

jComboBoxReceiver.getEditor().getEditorComponent().addKeyListener(new java.awt.event.KeyAdapter() {
    ...

13. Swing: detect Enter in JComboBox?    stackoverflow.com

I've tried using getInputMap() + getActionMap() on a JComboBox and it seems to have no effect. I've tried addActionListener() / addItemListener() on a JComboBox and I can't seem to distinguish a change ...

14. Java - How to prevent JComboBox from closing?    stackoverflow.com

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 ...

15. Can I implement word prediction with JComboBox    stackoverflow.com

I need advice, is there any way to implement with JComboBox word prediction, when I start type I want to open dropdown with all words which start with part what I ...

16. .txt in combo box    stackoverflow.com

I am new in the world of programming and am completing a Java programming assignment. In my assignment I am having a problem trying to display a list of .txt ...





17. NetworkInterface's getNetworkInterfaces() to JComboBox    stackoverflow.com

First Question

NetworkInterface.getNetworkInterfaces();
returns a Enumeration type. each element of the Enumeration has a getDisplayName() method which returns a string such as en0, en1, vnic1 etc. Now I would like to make these strings into ...

18. java swing combobox    stackoverflow.com

I have a combo box and a string array that holds all the values of the combo box in it. I erase the items from the combo box and then want ...

19. Typecast combobox in java    stackoverflow.com

How do I typecast my defaultListModel? I want it to hold my objects of type "Account" Do i need to create a new listmodel that extends listmodel or is there an easier way? ...

20. Type safety with JCombobox on Java 7    stackoverflow.com

I cant get rid of one new typesafety warning in java7. I have the following JCombobox object defined

private JComboBox<Integer> combobox_current_year;
And the the constructor
combobox_current_year = new JComboBox(options.getList_years().toArray());
Java 7 gives me now the following ...

21. How to synchronize popups visibility of two JComboBoxes (comboBox and mirrorComboBox)    stackoverflow.com

I am trying to synchronize popups of two combo boxes - call them comboBox and mirrorComboBox. I want to set popup of mirrorComboBox visible when popup of comboBox becomes visible. I tried to ...

22. How to set umlaut ( german character ü ) as mnemonic for JComboBox    stackoverflow.com

I have used the following code:

JComboBox cb=new JComboBox();
JLabel label = new JLabel("für");
label.setDisplayedMnemonic('ü');
label.setLabelFor(cb);
This code does not work. However if I set the mnemonic to 'f' instead of 'ü' it works fine. There is ...

23. GUI ComboBox Opens Other GUIs    bytes.com

24. Auto completing with jcombobox    bytes.com

i load the combobox with the values from database.whenever a text is enter all data starting with this text is loaded from database.i want the combobox list to drop down so ...

25. Master/Detail form + JComboBox + Converter???    forums.netbeans.org

cv2 Joined: 02 Aug 2009 Posts: 1 Posted: Sun Aug 02, 2009 8:46 am Post subject: Master/Detail form + JComboBox + Converter??? Unfortunately I am stuck on something ...

26. Re: Validate jComboBox to check if it is null in Java.    forums.netbeans.org

I am newbie, trying to learn java. I want to know how can i validate to check whether the Editable jCombox is null or not. I am making an Apps where i want that the jcomboxBox should not be blank & if it blank then the focus should be back to jcombobox. Pl. also let know me know how can i ...

27. Can't relate two entity classes for showing related field in JComboBox    forums.netbeans.org

Insufficient information. How are you binding the value? What do you mean when you say I changed the entity classes so they can show a relationship when I bind the 'selectedItem' in the JComboBox What exactly is the exception? Tony From: Cesar Santamaria [mailto:address-removed] Sent: 14 February 2011 19:27 To: address-removed Subject: [nbusers] Can't relate two entity classes for showing related ...

28. helpp jcombobox    forums.netbeans.org

hii everybody I have a probleme with jcombobox in my work of telecom .. see the code of them who I used initComponents(); Session a=NewHibernateUtil.getSessionFactory().openSession(); Criteria cre= a.createCriteria(Mt.class); int i=0; List e= cre.list(); for(Mt f:e) { jComboBox1.addItem(f.getReference()); i++; } this code show me in my jcombobox the data from database when the data is repeat in the base, she show ...

29. How to put something in JComboBox    forums.netbeans.org

Hi, I have small problem with ComboBox. I created code which gives me actual date and dates for next few days. I use GUI editor in netbeans. I created all interface (including this JComboBox) but I don't know where i have to put my code to display dates in ComboBox. Could you help me?

30. NB 7 designer & JComboBox warnings    forums.netbeans.org

Hello, With NB 7.01 and JDK 1.7.0_01 I develop a standard Java Swing application for Java 1.6 and higher, i.e. the project's source format is set to "JDK 6" (but I think I get the same problems with selected "JDK 7"). With the NB GUI designer I drop a JComboBox in a JFrame and enter some lines of text via this ...

31. JComboBox    coderanch.com

32. JComboBox    coderanch.com

I am using a Jcombobox with 9 options to choose from. When a selection is made an event is fired, things happen, and I want to change the text that is displayed inside the combobox. Is there an easy way to do this? The closest I could come was to totally replace the comboboxmodel that the combobox was using. This in ...

33. JComboBox Editor    coderanch.com

I have a combo box which i am populating through the keys of a Hashtable.If I keep the combo box editable , the newly entered value must be entered in the Hashtable in place of the old one.But when i edit the old value,the combo view does not get modified.I also tried implementing a custom editor by extending the javax.swing.plaf.basic.BasicComboBoxEditor class.But ...

34. two jcomboBox then    coderanch.com

35. combobox    coderanch.com

36. ComboBOx    coderanch.com

Hi all I need to make a Combobox with select & time intervals of 30 min ie 12:30 1:00 etc where the display on textfield is --Select-- & when user presses the button on combobox the pointer should point to other item on the list. Please let me know how to do that thanks & happy new year

37. Urgent JComboBox!!!    coderanch.com

38. swing(JComboBox)urgent    coderanch.com

39. regarding the JComboBox    coderanch.com

40. Very Urgent---JComboBox    coderanch.com

41. JComboBox    coderanch.com

Hi, I want to take information from user and that information I want to add to JComboBox.For that I have created few textfields. Means user will fill information into that textfields and if he click 'Add' button it should go to JComboBox.for that I have created ActionPerformedEvent.What is happening is it's working correct.But When I again run the same application previously ...

42. JComboBox internals    coderanch.com

Well, here's an idea. Don't know if it will work. The function of the TAB key is defined by the FocusManager. That's why you don't see your tabs. The focus manager consumes them before they get to your component's input methods. So you could subclass DefaultFocusManager and set it as the focus manager for your frame. Override the focus manager's processKeyEvent ...

44. set JComboBox    coderanch.com

45. set JComboBox    coderanch.com

46. Reg ComboBoxes    coderanch.com

47. AWT Combo Box    coderanch.com

I am trying to implement an AWT combo box into an existing applet. I use the visual cafe ide and it contains a basic AWT combo box however the button arrow looks awful and I want to implement a mask to restrict user input to digits 0-9. I have tried to create my own combo box but with too many problems ...

48. JComboBox    coderanch.com

49. JComboBox    coderanch.com

50. SelectFontAction in a JComboBox    coderanch.com

51. Exceptions with JComboBox    coderanch.com

52. JComboBox    coderanch.com

I think this does what you want it to do... import java.awt.*; import java.awt.event.*; import javax.swing.*; public class FormatCombo extends JFrame { private JComboBox combo; public static void main( String[] arg ) { new FormatCombo(); } public FormatCombo() { JPanel p = new JPanel(); combo = new JComboBox(); combo.setFont( new Font( "Dialog", Font.BOLD, 16 ) ); JComponent c = (JComponent)combo.getRenderer(); c.setBorder( ...

53. JComboBox    coderanch.com

54. How to show this JComboBox?    coderanch.com

Hi, I was wondering why this JComboBox is not showingup, though if i try to use Choice it works with the same code. Can you help me? regards, arun public void logo(String p,String f1,String name,String bname,ActionListener ae) { removeAll(); try { JComboBox jcbx=null; jcbx = new JComboBox(); JLabel username = new JLabel("Welcome"); username.setBounds(10,5,70,20); username.setForeground(new Color(3,9,117)); username.setBackground(new Color(255,255,255)); JLabel username1 = new ...

55. JComboBox    coderanch.com

56. Bug or Feature of JComboBox    coderanch.com

57. JCombobox...!!!    coderanch.com

58. JComboBox and limitations    coderanch.com

59. JComboBox Mystery!    coderanch.com

First of all I don't think Master Tiger is your real name, but your moderator will get to you soon. 1. I cant really answer this with the exact problem, but it appears that the Action you are using for the first JComboBox is running twice. Which type of listener are you using. Are you using ListSelectionListener. I think this fires ...

60. Stepped JComboBox    coderanch.com

61. About JComboBox    coderanch.com

62. Checked JComboBox    coderanch.com

You should be making custom ListCellRenderers and ComboBoxEditors to make a check box appear in a Combo box... Here is some example code of how to do this... import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.plaf.basic.*; public class TestCheck extends JFrame { private JComboBox combo; private Vector v; public static void main( String[] arg ) { new TestCheck(); } ...

63. JComboBox setEditor()    coderanch.com

64. JComboBox    coderanch.com

65. JComboBox and focusGained    coderanch.com

hm, your code seems fine to me. I checked the bugparade and there is an entry concering focusGained, though it is quite a special case. http://developer.java.sun.com/developer/bugParade/bugs/4707457.html What you could do is: - run your program with different java versions. - write a little test program (just a little frame with two components where you can test the focusGained/focusLost method) - don't ...

66. JComboBox    coderanch.com

67. JComboBox    coderanch.com

Well tushar, heres the component I promised. import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.util.Vector; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.event.DocumentListener; import javax.swing.event.DocumentEvent; public class AutoComplete extends JComboBox implements DocumentListener, ActionListener{ private JTextField editor =(JTextField)getEditor().getEditorComponent(); public AutoComplete(SortedComboBoxModel items){ super(items); editor.getDocument().addDocumentListener(this); setEditable(true); } public AutoComplete(Object[] items){ this(new SortedComboBoxModel(items)); } public AutoComplete(Vector items){ this(new SortedComboBoxModel(items)); } public void insertUpdate(DocumentEvent e){ showPopup(); ...

68. Keeping JComboBox Visible    coderanch.com

69. subselection with jcombobox    coderanch.com

70. JComboBox    coderanch.com

71. JComboBox over Appletborder    coderanch.com

72. control one JComboBox from another    coderanch.com

i have two JComboBoxes.when i select an item from the first combobox i want to populate the second combobox with items depending on the selection made in the first combobox. example : i have 3 items in the first combobox : A, B and C A = 1,2,3 B = 4,5,6 C = 7,8,9 if i select B from first combobox ...

73. JComboBox not working properly on a GridBagLayout ??    coderanch.com

Hi guys, I've got a very simple class to enter data of a new Customer. The user needs to select a branch from a drop down list (a JComboBox), but, the list of names is covered up by the labels that are in a lower position. If you'd compile this short code, you'll see what I mean. I just don't understand ...

74. Making a JComboBox uneditable    coderanch.com

75. JComboBox Blues    coderanch.com

76. JComboBox    coderanch.com

hi joe, Thanx for ur reply. The actual problem was, the event was not fired when the jcombobox was selected through my code. [ jCombobox.setSelected(true); //although the combox gets selected the event was not being fired. ] Basically, I wanted to fire the event without using the mouse & keyboard manually. It should be performed through my code itself. Hope u ...

77. JCombobox    coderanch.com

78. getRowForLocation(...) in JComboBox?    coderanch.com

79. JCombobox    coderanch.com

80. ComboBox    coderanch.com

81. jComboBox    coderanch.com

An applet with 3 combo boxes. You make a selction in the first combobox, and based on that selection, the options are in the second combobox, then based on the second selection, the options for the third combobox appear. How do I get that started? Picture Ordering CDs'; the first box is the music type,(country, jazz, etc...), the second box is ...

82. JComboBox    coderanch.com

83. JComboBox    coderanch.com

84. weird thing happening with JComboBox    coderanch.com

I am using a JComboBox as an editor in a JTable, and am having a problem with the ItemListener. I have the combo set up so that the user has to double click on the cell before the combo will open (using setClickCountToStart method on DefaultCellEditor). According to the swing tutorial, a JComboBox will fire two itemStateChanged events when a new ...

85. jcombobox    coderanch.com

If I'm reading this right, setSelectedIndex() coupled with itemStateChange() would fire the event Something like this import javax.swing.*; import java.awt.*; import java.awt.event.*; class JComboBoxEX extends JFrame implements ItemListener,ActionListener { private String cities[] = {"London","New York","Rome","Sydney"}; JComboBox cboBox = new JComboBox(cities); JLabel selection = new JLabel("Select a city"); JButton btn = new JButton("Next"); public JComboBoxEX() { super("JComboBoxEX"); setSize(350,100); setLocation(400,300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container frame ...

86. Trouble using JComboBox    coderanch.com

yes, this is the default behavior (as per api docs). if you want to get unique index for duplicate list items, you need to setup a custom renderer. this would be not too hard for what you need to do (unless you have, say, an editable combo box). you can modify and use the sun ComboBoxRenderer class example at http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html, (just ...

88. JComboBox is deaf    coderanch.com

hi all i'm a newbie to java GUI programming, and i'm getting stumped on something that should be trivial. my JComboBox doesn't hear mouse events, even though i've added a mouselistener that works with other controls. here' the full test story. i've got a tabbed pane in a JPanel. the tabbed pane has 2 JComboBoxes. i have a listener class that ...

89. creating a calander inside a ComboBox    coderanch.com

Hi im trying to create a comboBox, which will look like a normal comboBox, but its editor will be a calander, so when i'll click on the comboBox, the calander panel will appear. I already created the calander and defined it as the comboBox's Editor. the problem is that the Calander appears all the time and not just when i open ...

90. JComboBox    coderanch.com

import java.awt.*; import javax.swing.*; class Testing extends JFrame { Person[] person = {new Person("Fred",23),new Person("Joe",30),new Person("Mary",21)}; JComboBox cbo = new JComboBox(); public Testing() { setLocation(400,300); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel main = new JPanel(); for(int x = 0; x < person.length; x++) cbo.addItem(""+((Person)person[x]).age); //<--------- main.add(cbo); getContentPane().add(main); pack(); } public static void main(String[] args){new Testing().setVisible(true);} } class Person { String name; int age; public Person(String ...

91. ComboBox component (not JComboBox)    coderanch.com

I am having difficulty with a combobox in Java. I have the combobox set up the items are loaded from a database. That all works. After the 100 or so items are loaded from the database and I click on the combobox arrow to display the combobox list, the combobox list extends the whole length of my frame and overlaps into ...

92. jComboBox    coderanch.com

93. JComboBox oddity    coderanch.com

I'm not sure I'm following you on this one. Here is a quick and dirty example of a combo class: package testing; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class comboTest extends JFrame { private Vector v; JComboBox cbMyCombo; public comboTest() { super("duper"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = createMenuBar(); getContentPane().add(menuBar, BorderLayout.NORTH); JPanel panel = myPanel(); getContentPane().add( panel ); setSize(400, 200); ...

94. combo box    coderanch.com

umm hi guys help me here pls. i need to make a pull down menu which has options Us Dollars, Malaysian Ringgit, Sterling Pounds. i need to make an applet that money changers can use. In my applet the user types in the exchange rates, then from 100 XX currency the user selects either Us Dollars, Malaysian Ringgit, Sterling Pounds from ...

95. How to set hotkey for jcombobox?    coderanch.com

96. restrict the length of a JComboBox    coderanch.com

97. how to make JComboBox    coderanch.com

98. Swing + JComboBox    coderanch.com

here's a simple demo (you could do this with just the one combo box if you wanted) import java.awt.*; import java.awt.event.*; import javax.swing.*; class Testing extends JFrame { String[] cbo1Text = {"Snacks","Drinks","Cigarettes"}; String[][] cbo2Text = {{"Chocolate Bar","Chips","Candy"},{"Soft","Beer","Wine","Spirits"}, {"Menthol","Camel","Marlboro","Lite"}}; String[][][] cbo3Text = {{{"Choc1","Choc2","Choc3"},{"Chips1","Chips2","Chips3"},{"Candy1","Candy2","Candy3"}}, {{"Coca Cola","Pepsi","Dr Pepper","Solo"},{"Bud","Coors","Heinekken"}, {"Champagne","Chardonnay","Shiraz"},{"Bourbon","Scotch","Vodka"}}, {{"Menthol15","Menthol20","Menthol40"},{"Camel15","Camel20","Camel40"}, {"Marlboro15","Marlboro20","Marlboro40"},{"Lite15","Lite20","Lite40"}}}; JComboBox cbo1 = new JComboBox(cbo1Text); JComboBox cbo2 = new JComboBox(cbo2Text[0]); JComboBox cbo3 = ...

100. JComboBox again    coderanch.com

I want my combo box field to display a code selected by a user. However if the user displays the drop down list I would like the list to contain a code and a description. This is mainly due to the fact that the description can be quite long and I don't want a huge field on the screen. Is this ...