jcombobox

Adding ActionListener to JComboBox without items not working????

Below is the source code for UseTest.java :- import javax.swing.* ; import java.awt.* ; import java.awt.event.* ; class Test implements ActionListener{ JFrame f ; JPanel p ; JComboBox cb ; JLabel l ; Test(){ f = new JFrame("Test") ; f.setSize(200, 200) ; p = new JPanel() ; p.setLayout(new GridLayout(2, 1)) ; cb = new ...

Java Swing - JSlider and JCombobox causing runtime errors

Ok, I will post the code for the three classes as it's not too long. package guiDemonstration; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class TabbedGUI { //create fields private JFrame frame; private JTabbedPane ...

Java out of memory exception thrown when initializing the combo boxes

This is my code here the variable bq is a custom class called BasicQuery it returns a JavaDB connection... AutoCompleteDecorator is the class from swingX library used to implement the autocomplete functions... This code when rus about 3 times run properly but after that it keep getting frozen and after a while throws the out of memory ex...

Get input text without scanner

Hi! I work on a school project and I am now wondering if it is possible to get text from JTextField with get? // Textrutor JTextField textTitel = new JTextField(null, 20); textTitel.setToolTipText("ex. Flickan som lekte med elden"); JTextField textSort = new JTextField(null, 10); textSort.setToolTipText...

JCombobox's popup list is not painted completely

I have a JInternalFrame in a JDesktop, and I also have a JComboBox in the internal frame. The problem is shown below. How can I make JComboBox paint outside JInternalFrame, so that the popup list can be shown completely? Is using glass pane an optimal solution, or would it be bad practice? SOLUTION: I have found the solution; just...

Set JComboBox Items not Selectable

How can I make some of my JComboBox Items not Selectable? I tried this: @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (not...

Disabling JComboBox and retaining original item list

My action listener on a JComboBox invokes a thread. I would like the component to be disabled until the thread completes. I have tried calling seEnabled(false) when the thread start and setEnabled(true) when it completes. Unfortunately setEnabled(false) clears the combo box list as well. Is there a way of disabling the component but re...

Filling combobox from database by using hibernate in Java

Heyy; I am developing a small swing based application with hibernate in java. And I want fill combobox from database coloumn.How ı can do that ? And I don't know in where(under initComponents, buttonActionPerformd) ı need to do. For saving ı'am using jbutton and it's code is here : private void jButton1ActionPerformed(java.awt.event...

What is the point of JComboBox's getSelectedItem()?

I just read the JavaDoc for JComboBox (I promise I have a life... I wasn't reading through for fun. =P), and I think the problems I'm having with my program can be attributed to the getSelectedItem() method. The documentation says: Returns the current selected item. If the combo box is editable, then this value may not have bee...

can i add the combobox into particular cell of the JTable?

I want to add combobox into a cell of JTable. model=new DefaultTableModel(data,col); JTableHeader head=new JTableHeader(); head.setBackground(Color.BLUE); table=new JTable(model); table.add(head); JComboBox combo = new JComboBox(); combo.addItem("Names"); combo.addItem("Antony"); combo.addItem("Victor"); ...

how to set the selected item for a combobox on change of Jtable row value in java

Hi, I am using JTable and JCombobox in a swing application.In the JTable, I have 2 columns(no,name), the same details are in two JComboboxes in the application(JNo combo box, JName combobox). Now, When I click on first row of the table, below the the respective value should be selected in the two comboboxes.When I tried to see the logs t...

Implementing a recently used or favorites dropdown in JComboBox

I am looking for code that will add favorites / MRU type behavior to a JComboBox. I could code this myself, but it sure seems like someone else has probably already done it. I found the following (which looks exactly like what I want, but the source code is nowhere near complete): http://java.sys-con.com/node/36658 Any suggestions? I...

Invisible JComboBox

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). And here's my code : for(int i = 0; i<11; i++) { JComboBox jC = new JComboBox(posteList); jC.setBounds(300, posY, 100, 20); jC.setSelectedIndex(0); this.add(jC); p...

JCombobox containing enum values inside a table

Hello, I have a class containing Enum with values. (names) In other class I would like to enter inside a table a cell type of JCombobox that will use these enums values. my problem is to combain between string values and the enum. for example the enum class: enum item_Type {entree, main_Meal, Dessert, Drink} for example th...

how to use JComboBox using Enum in Dialog Box

Hi, I define enums: enum itemType {First, Second, Third}; public class Item { private itemType enmItemType; ... } How do I use it inside Dialog box using JComboBox? Means, inside the dialog box, the user will have combo box with (First, Secon...

how to show integer values in JComboBox?

Hello, I would like to know how to set a JComboBox that contain integers values that I could save. Here is the definitions of values: public class Item { private String itemDesc; private int itemType; public static int ENTREE=0; public static int MAIN_MEAL=1; public static int DESSERT=2; public static int DRIN...

How to configure JComboBox not to select FIRST element when created? (Java)

Hi all. Problem: Update: From the Java SE 6 API: public JComboBox() Creates a JComboBox with a default data model. The default data model is an empty list of objects. Use addItem to add items. By default the first item in the data model becomes selected. So I changed to JComboBox(model) as the API says: public JCom...

How to keep the popup menu of a JComboBox open on populating it ?

I have a JComboBox on my Panel. One of the popup menu items is 'More' and when I click that I fetch more menu items and add them to the existing list. After this, I wish to keep the popup menu open so that the user realizes that more items have been fetched however, the popup closes. The event handler code I am using is as follows publi...

Is this the intention behavior in JComboBox? How I can avoid this behavior?

I realize that if you are having a same selection in JComboBox, using up/down arrow key, will not help you to navigate the selection around. How I can avoid this behavior? See the screenshot below: public class NewJFrame extends javax.swing.JFrame { /** Creates new form NewJFrame */ public NewJFrame() { initComponen...

How to use Map element as text of a JComboBox

I am populating a JComboBox (using addItem()) with all the elements of a collection. Each element in the collection is a HashMap (so its a ComboBox of Hashmaps..). My question is - Given that I need each item to be a HashMap how do I set the text to apear in the combobox on the GUI? It needs to be the value of a certain key in the map...