jcombobox

Populating Swing JComboBox from Enum

I would like to populate a java.swing JComboBox with values from an Enum. e.g. public enum Mood { HAPPY, SAD, AWESOME; } and have these three values populate a readonly JComboBox. Thanks! ...

Netbeans - Entering items in a jComboBox

I have generated a GUI from netbeans in which I have placed a combobox too. By default, the items in combobox are item1, item2, item3, item4. But I want my own items. Netbeans doesn't allow editing generated code so how can i edit the comnbobox according to me. Note: I know one method by editing the "model" property of that jComboBox ...

JCombobox editable enabled

What is the difference between the setEditable() and the setEnabled() in a jCombobox? Can a combobox be editable but not enabled and other way around? In which situation would you use which method? Can you imagine a situation in which you would do setEnabled(false) together with setEditable(true)? ...

Java ComboBox What controls where list will display?

Possibly an odd question but how can I change how my Java Swing combo box displays its list of items? The default behavior is for the list to be displayed below the combo box. There are times, when the combo box is low on the screen, that the list is displayed above the combo box. Is there a way to force it to always display above? W...

How do I populate a jcombobox with information from a mySQL database?

Title says it all.. Basically the program takes customer information and dumps it in a database. In order to change information I want the user to be able to pick a customer name from a combobox, so the system can then call all the info out of the database on that customer. Accessing the database is fine, putting info in and changing it...

populating a jcombobox with database information

I know I am missing something simple, I think in getting the combobox to access the array. package my.freelancebillingapp; import java.sql.; import java.sql.Connection; import java.sql.DriverManager; import java.util.ArrayList; import javax.swing.; public class billingInfoUI extends javax.swing.JFrame { public billingInfoUI() { ...

jcombobox not loading values from an array

jComboBox1.setModel(customers); public class CustomerData { private static final String JDBC_CONNECTION_URL = "jdbc:mysql://localhost/test"; private static final String DATABASE_USER = "root"; private static final String DATABASE_PASSWORD = "root"; // query to select customer data private static final String SQL_FETCH_CUSTOMERS = "...

Java Dropdown Checklist

I understand how to make a multiple-select list box using JLists but I want to add JCheckBoxes to the list and make it dropdown like. The best visual representation I have found online is dropdown-check-list. What would be the best way to accomplish the above? I was thinking of a TableList. Any suggestions? ...

Editable JComboBox

if the user select the item which its index is 1,and change it from"123" to "abcd".how can I set "abcd" instead of "123" (in NetBeans)????Also how can I delete the item for ever???? ...

How do I customize a JComboBox so that the pop-up is a JTree (instead of a list)?

I am trying to create a combo box so that I can put whatever control I prefer within the pop-up, in my specific case a JTree. Having a look at how the JComboBox is implement, the pop-up is really created by the UI delegate. The problem in changing that is that it would need to be re-implemented for each look and feel, which is something ...

why this code about combobox doesn't work?

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 (int i=0;i<jComboBox1.getItemCount();i++) { String lessons = (String) jComboBox1.getItemAt(i); if (lessons != nu...

JComboBox "no text" text

I'm trying to reproduce the behavior of the search field of Firefox or Safari, or the search field of stackoverflow.com on the top right of this page. I mean, when there is no text on the editable JComboBox, an instruction text is displayed, like "Type here" or whatever. When the JComboBox is focused the text is removed. If the focus is...

JComboBox not loading data

@SuppressWarnings("unchecked") private void loadToCombo(){ List toList = GateDAO.findAll(Company.class); ListComboBoxModel toComboModel = new ListComboBoxModel(toList); toComboModel.setFirstObject("New Organization"); recieverToCombo.setModel(toComboModel); } I have the above code loading my JComboBox with the results from ...

JComboBox adds items for one ArrayList of strings, but disappears from GUI for another

I have 2 JComboBox components added to my GUI productComboBox and categoryComboBox, with the following item listeners defined for each: categoryComboBox.addItemListener(new GoItemListener()); productComboBox.addItemListener(new ProductItemListener()); The user first selects a product, and then the listener should populate the ...

JCombobox, Editor and Renderer related

As a JCombobox ListCellRenderer, I have a class like this one: class ZComboBoxRenderer extends JPanel implements ListCellRenderer{ private ZGrid grid; public ZComboBoxRenderer(ZGrid grid) { setLayout(new BorderLayout()); this.grid = grid; add(new JScrollPane(grid), BorderLayout.CENTER); } public ZGrid getGrid(){ return g...

Need flexible Java key/value collection class for JComboBox

I have a model class that stores keys and values: public class KeyValue { private Object key; private String value; KeyValue () { } KeyValue (Object key, String value) { this.key=key; this.value=value; } public Object getKey() { return this.key; } public void setKey(Object ...

How to load already instantiated JComboBox with data in Java?

I have a Swings GUI which contains a JComboBox and I want to load data into it from the database. I have retrieved the data from the database in a String Array. Now how can I populate this String array into the JComboBox EDITED==================================================================== In actual, the JComboBox is already inst...

How to map the JComboBox item to its corresponding ID?

I have a table in a database that contains two fields id name I have populated a JComboBox "combo1" with all the names stored in the DB. Now I want that whenever a user selects an item of the "combo1", I can recognize the "id" of the selected item. But the problem is that names can be duplicates in a table. So let assume if a table ...

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

Hi, 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 "PersonelName" and ValueMember "PersonelID". In .NET there is related properties like DisplayMember,DataSource,ValueMember , i can show personel's name with displaymem...

JTable with JComboBox editor : Is it possible to edit the cell value from keyboard with one key press

Hi, I'm having a JTable containing JComboBox editors initialized somewhat like JComboBox comboBox = ...; TableColumn tc = table.getColumnModel().getColumn(i); tc.setCellEditor(new DefaultCellEditor(comboBox)); This is working otherwise fine but I'd like to be able to navigate in the table and update the values with keyboard only. Now...