Item « JComboBox « Java Swing Q&A





1. Swing: Floating panel next to the selected item in a JComboBox    stackoverflow.com

I've created an app with a small window (the size of a combo box). I need to create a floating panel that sits outside the window, next to the selected ...

2. Netbeans - Entering items in a jComboBox    stackoverflow.com

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

3. How to map the JComboBox item to its corresponding ID?    stackoverflow.com

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

4. How can I make some items in a JComboBox unselectable?    stackoverflow.com

How can I make some of my JComboBox Items unselectable? I tried this:

@Override
public Component getListCellRendererComponent(JList list, Object value,
    int index. boolean isSelected, boolean cellHasFocus) {

    ...

5. How to select item in jComboBox    stackoverflow.com

I have a jComboBox that I am populating with some objects. The objects are of a type which I have made myself, and include a String and an int. The object's ...

6. jComboBox set selected item not working properly    stackoverflow.com

I'm trying to populate my jComboBox with the following items:

public class DropDownItem {

private String text;
private int id;

public void setText(String text) {
    this.text = text;
}

public void setId(int id) {
 ...

7. JComboBox - no ItemEvents for null-items    stackoverflow.com

It seems no selected or deselected ItemEvents are generated for the null-item in the JComboBox. How can I change this? Making the item "" is not an option.

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JComboBox;
import ...

8. ComboBox - printing out the selected item    stackoverflow.com

I am a little stuck. I can't figure out a much bigger problem than this, so I am going to the roots to eventually build my way up! I can't print the ...

9. How do I make a listener that fires when the USER selects an item in a JComboBox    stackoverflow.com

I'm looking for a listener that fires ONLY when the user, the one who's using the program, selects an item in the JComboBox. I don't want to use ActionListener or ItemListener ...





10. Preferred way of getting the selected item of a JComboBox    stackoverflow.com

HI, Which is the correct way to get the value from a JComboBox as a String and why is it the correct way. Thanks.

String x = JComboBox.getSelectedItem().toString();
or
String x = (String)JComboBox.getSelectedItem();

11. How do you access items in an uneditable JComboBox so a method can be run upon selection?    stackoverflow.com

I know a little Python but unfortunately no Java. I'm trying to get a minimal Jython example to work, where a method is executed each time an item in my ...

12. Calling JComboBox#addItem() in a while(resultSet.next()) loop ends up with only 1 item    stackoverflow.com

this is the code thats giving me problems.

try{
ResultSet rs = Main.dbase.search("select * from myTable");
//rs.next()
while(rs.next())
{
 cmb.addItem(rs.getString(1).trim());
}
rs.close();
} catch (Exception ex) {System.out.println(ex);}
here dbase is an object executing Statement.executeQuery, and cmb is JComboBox. the problem is ...

13. ComboBox items are overlapped    stackoverflow.com

Please have a view of the attached image. I use VLCJ to build this application. However, it is unexpected that the item in combobox is hidden by the Canvas (which is used ...

14. Set the height of an item inside a JCombobox    stackoverflow.com

I have a JCombobox with many items and first of all them is a NULL value When opening the combobox, all the items have a normal height but not the first one ...

15. setting items to a jComboBox    stackoverflow.com

i know how to get data from Database to the java applications but my problem is adding the data to a JComboBox,i did this: main.java:

`Interface itself = new Interface();
  itself.setComboBoxItems();`
//calling the ...

16. How to set the JComboBox back to its default item    stackoverflow.com

I have 24 JComboBox consisting of numbers, 2 JButton for "COMPUTE" and "CLEAR ALL". my COMPUTE BUTTON works just fine. But for the CLEAR ALL button I cant get my desired ...





17. JComboBox automaticaly selects first item in list    stackoverflow.com

I have a JComboBox with a few selectable items in it. My problem is when the user click on the JComboBox, the list shows up as expected, but when he decide ...

18. selected item from a JComboBox    coderanch.com

Thank for replying.. This is what i have so far... there are some error here & there which i'm not sure how to solve them.. can u kindly point out to me.. Thanks alot import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.FileWriter; import java.io.PrintWriter; import java.io.IOException; class EnterNew extends JFrame implements ActionListener, ItemListener { //delcare arrayList ArrayList ...

19. item does not changed in JcomboBox    coderanch.com

20. JComboBox with muticolor items??    coderanch.com

21. JComboBox for large number of list items    coderanch.com

Hi, I'm using a JComboBox to display a very large number of items (>1000). As you can imagine it is not very responsive, as the loop for adding the items is taking a long time to complete. I have tried adding the items in a seperate thread which improves things a lot, but then actually scrolling through and selecting then items ...

22. how JComboBox can have unique items ?    coderanch.com

23. JComboBox item rendering    coderanch.com

class DataDetailsComboBoxRenderer extends DefaultListCellRenderer { public DataDetailsComboBoxRenderer() { setOpaque( true ); } public Component getListCellRendererComponent( JList list, Object value,int index,boolean isSelected, boolean cellHasFocus ) { setText( value.toString() ); if ( isSelected ) { setForeground( Color.red ); setBackground( Color.yellow ); } else { setForeground( list.getForeground() ); setBackground( list.getBackground() ); } return this; } }

26. Duplicate items in JCombobox    coderanch.com

Hi All, I have a jcombobox in GUI which contains some duplicate items also. Assume there are 3 items which is same as "Mutex". When i select second "Mutex" or third "Mutex", the selected item and selected index is always pointing to first occurance of "Mutex". How can i correct, so that the selected index/item is right one, instead of first ...

28. JComboBox select onself the item    coderanch.com

This is one of the things that bothers me about the SWING API. What you are requesting is a very common function. And it is common in almost all Desktops; Windows, Linux, MAC. And yet, there is no easy way to do this. I don't know why Sun couldn't have built this into the existing JComboBox. But alas, you have your ...

29. Selecting an Item in a JComboBox Component with Multiple Keystrokes    coderanch.com

Hi, I'm trying to put a JComboBox in a table. Once you click on a cell that is rendered as a JComboBox you can select an item with multiple key strokes. It also must work in Java 1.3. I have an example from http://javaalmanac.com/egs/javax.swing/combobox_CbMultiKey.html?l=find. It works but only if it is not in a JTable. I've looked at the bug database ...

30. ComboBox Item Display    coderanch.com

Hi, Ive got a JComboBox component, placed on a panel with gridbaglayout which in turn is placed on a JTabbedPane. I populate the combobox through coding from a SQL server database. My problem is that none of the records that i add to the combobox are being displayed. When i check the recordcount, it is equal to the number of records ...

31. JComboBox - Selecting an item    coderanch.com

Visual Basic's comboboxes allows the user to enter partcial information and it will find the first match. For example "Ron" will retun the "Ronnie" item. Is there away of doing this in Java? Java seems to work only with the current letter. In my previous example it would give me the first R entry, then the first "O" and than the ...

32. assigning jcombobox items    coderanch.com

hi, i have a jcombobox with items ranging from 5 to -5. my idea is whenever a user selects an item, a point in the form of 'filloval' will be plotted in a rectangle on the jpanel. the problem right now is that when i select the 5 value from the material ratings combobox & press the plot button the 'filloval' ...

38. How delete the specify item on the JComboBox immediately.    coderanch.com

I want to make a JComboBox like that the item has a text and label (the label with a delete icon) , and if I press the label ,the corresponded item is invisible ,and the dropdown menu is still visible. How I can do it ? I have write a render like it: package asd; import java.awt.Component; import java.awt.GridLayout; import java.awt.event.MouseAdapter; ...

39. [SOLVED] Item too big for JComboBox    java-forums.org

Is there a simple way to prevent the JComboBox from resizing in order to display a really long value? I have a combo box that displays the absolute path of a given file. The problem is that paths can get rather long. The panel my combo box is placed in has a minimum size, but no maximum size. So when the ...

40. Creating multiline item in JComboBox    java-forums.org

I am trying to create multiline items in JComboBox. The combo box items should be able to accommodate text of different lengths and displayed in different height and lines. I have attempted to add JTextArea using setCellRenderer for JComboBox, but the text entered is not wrapped around. I have attempted setLineWrap and the setWordWrap methods in JComboBox but do not work. ...

41. Databse items to Jcombobox    java-forums.org

The getSelectedItem method has nothing to do with getting values from your database. Write a separate class with a method that gets the values from the database. That method should no nothing about Comboboxes. It must just get the values you want from the database and return the data as an array. Test that method and make sure it works as ...

43. select item from combobox and continue to new window    java-forums.org

hi, we have to make a java program for our exams but we have problems with our combobox. (We use netbeans 6.8 - gui builder) We have to select a book we want to read from a combobox ( linked to our access database ). if we select a book and click proceed, we have to view our book in a ...

44. Get the item in JComboBox    java-forums.org

45. JComboBox-selected item    java-forums.org

Hello, I am interested is there any way to intercept event of selecting something in JComboBox pop-up container. What i want to do if user clicks on some item in pop-up: 1. I want to add item to editor component (this is default behaviour) 2. After that i want to get that item from editor and call some method. So user ...

46. Display items in the JCombo Box    java-forums.org

Hi all, I have to create a combo box in which I want to seperate one of items with the others through a line separator (similar to line separators which one sees in the various tab menus). Well right now I've just no idea of how it can be done. So can someone just give me a clue of how it ...

48. How to select the only item in a jcombobox    forums.oracle.com

49. ActionListener, specific JComboBox item events    forums.oracle.com

You only load strings into your combobox. Instead how about: * give the Company class a toString() method overload that outputs the String that you want displayed in the combobox. * load the market array into the combobox, so the combobox will hold objects with data, not just Strings. * use my ActionListener recommendation. Get the Company object from the combobox ...

50. JComboBox items not showing up properly ?    forums.oracle.com

First of all I can't really follow you code because of your non-standard naming conventions. Read the Java API. You don't see "_" used anywhere and you don't see method names upper cased. The simple answer is you need to share the model between the two combo boxes. How you do that is up to you because your code is too ...

51. JComboBox - clear Items    forums.oracle.com

52. I want to setMargin JComboBox Items.    forums.oracle.com