JComboBox link

Hello,
new in Java and JDeveloper..
2 questions (basics...) and I hope clear (Jclient) :
1)
I have a panel with a jcombobox (a username from the raf_util table)) :
jComboBox1.setModel(JUComboBoxBinding.createLovBinding(panelBinding, jComboBox1, "RafTicketView1", null, "RafTicketView1Iter", new String[] {"CodeUtilApp"}, "RAfUtilAppView1", new String[] {"Username"}, new String[] {"Username"}, null, null));
jComboBox1.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
jComboBox1_actionPerformed(e);
The Username is an attribute from an EO and View (BC4J) - created from the table RAF_Ticket :
SQL> desc raf_ticket;
Nom NULL ? Type
NO_TICKET NOT NULL NUMBER(6)
HORODATE NOT NULL DATE
CODE_UTIL_APP NOT NULL VARCHAR2(30)
CODAGENC NOT NULL NUMBER(6)
DESCR_PB NOT NULL VARCHAR2(30)
CODE_UTIL_INTERV0 NOT NULL VARCHAR2(30)
CODE_UTIL_INTERV1 VARCHAR2(30)
REF_DOSS NOT NULL VARCHAR2(20)
CODE_ACT NOT NULL VARCHAR2(2)
NIV_URG NOT NULL NUMBER(2)
TOP_DOS_UT VARCHAR2(1)
DESCR_LIBRE VARCHAR2(1500)
DATE_DEB_PREV DATE
DATE_FIN_PREV DATE
DFP_NEGOC VARCHAR2(1)
CHARGE_PREV DATE
DATE_DEB_INTERV DATE
DATE_DERN_INTERV DATE
DATE_CLOT DATE
MOTIF_CLOT NUMBER(2)
DATE_VAL_UTIL DATE
TICKET_REF NUMBER(6)
PROJET_REF VARCHAR2(30)
I have below the jcombobox 2 Jtextfields where I want to put wordings for agency (LIBAGENCE) and company (LIBSOCIE) which belongs to these tables :
SQL> desc raf_AG;
Nom NULL ? Type
CODAGENC NOT NULL NUMBER(6)
LIBAGENCE NOT NULL VARCHAR2(40)
CODREGIO NOT NULL VARCHAR2(3)
CODSOCIE NOT NULL VARCHAR2(3)
USERCREAT VARCHAR2(30)
DATECREAT DATE
USERMODIF VARCHAR2(30)
DATEMODIF DATE
SQL> desc raf_soci;
Nom NULL ? Type
CODSOCIE NOT NULL VARCHAR2(3)
LIBSOCIE NOT NULL VARCHAR2(40)
ADRESSE1 VARCHAR2(40)
ADRESSE2 VARCHAR2(40)
CODPOSTA NUMBER(5)
LIBVILLE VARCHAR2(40)
SQL> desc raf_util;
Nom NULL ? Type
USERNAME NOT NULL VARCHAR2(30)
USER_ID NOT NULL NUMBER(3)
CODAGENC NOT NULL NUMBER(6)
TYPE_UTIL VARCHAR2(1)
The relation between them is in Sql :
"select libagence, libsocie from raf_util, raf_ag, raf_soci where raf_util.codagenc=raf_ag.CODAGENC and raf_ag.CODSOCIE=raf_soci.CODSOCIE and raf_util.username= ?";
? = the data selected in the jcombobox.
do I have to write code for this. If yes, is the private void jComboBox1_actionPerformed(ActionEvent e), the right method?
How can i get the selected data from the jcombobox to pass it to the Sql parameter? I have tried
String strSelItem = jComboBox1.getSelectedItem().toString(); but it seems that It is not the right way.
And the first time, when I enter in the form, how to make the first value "selected" from the jcombobox?
Or could I put some automatic links between the 3 fields (BC4J, View, Module) in the document inspector properties for the 2 Jtextfield? so that when I choose a username, the 2 fields will display automatically the wordings.
2) this form could be called from a "RootForm" (menu) in various manners. today :
private void jButton8_actionPerformed(ActionEvent e)
JUApplication app = panelBinding.getApplication();
if (app.findFormBinding(TICKET) == null)
// instead of 'ordersPanelBinding.setApplication(app)', register
// the panelBinding under an explicit key
app.addFormBinding(TICKET, TicketPanelBinding);
TicketForm.setPanelBinding(TicketPanelBinding);
TicketPanelBinding.execute();
TicketForm.setVisible(true);
else
TicketForm.setVisible(true);
Depending on these various call (Jbutton), I want to do different treatments in the Panelview.java for Ticket.
How can I pass parameters from the menu to the form ?
Instructions?
Thanks and best regards.
Thierry (France)

frank,
1) yes, that's it. the combo box selection just query existing records (UI Editor - property inspector - model - Jclient LOV Binding). How to get the field selected in my form program (java class) or is it possible automatically ?
2) Yes, I have differents Jbutton in the menu. They action is to call the same form but with a parameter so that I can put different controls in the form depending on this parameter received. Basic but I don't know how to do that with java and jdev.
3) how to select a data in the jcombobox by default ?

Similar Messages

  • 2 JComboBox  sync problem

    Hi, im getting crazy with this error. I have two different JComboBox with two differents DefaultComboBoxModel.
    The first shows a list of files.
    The second shows a data list from the selected file in the first.
    When i select a different file in the first combo, i want to change the data list in the second combo. So i call the removeAllElements method in the DefaultComboBoxModel, but i dont know why, then the second combo code is executed too (it shouldnt) and i get an error.
    The code is something like this:
    cmb1 is a jcombobox linked to dcbm1, which is a defaultcomboboxmodel
    cmb2 is a jcombobox linked to dcbm2, which is a defaultcomboboxmodel
    MyObject is a customized class which has two fields: a Vector and a String. There is a Vector of MyObject, where is load the file data.
      void cmb1_actionPerformed(ActionEvent e){
        dcbm2.removeAllElements();
        // Load the file
        // Get data load on vector (class Vector)
        // Then, send data from vector to 2nd combomodel:
        for (int i=0; i<vector.size(); i++){
          mo = (MyObject)vector.get(i);
          dcbm2.addElement(mo.getString());
      void cmb2_actionPerformed(ActionEvent e){
        dlm.clear();                                                    // ListModel which i use to show data
        int x = cmb2.getSelectedIndex();
        m = (MyObject)vector.get(x);                       // This line throws the error (ArrayOutOfBounds). x=-1
        vector2 = m.getVector();
        for (int i=0; i<vector2.size(); i++){
          dlm.addElement((vector2.getString()
      }So thats my problem. When i select an item in the 1st combo, the 2nd combo code is executed too, throwing an ArrayIndexOutOfBounds because there is no item selected

    as I see, in this listing, you did not try using what I told you before, try using this:
    public void actionPerformed(ActionEvent e) {
         Object obj = e.getSource();
         if (obj == cmbFiles) {
              parser = new MyXMLParser((String) dcbmFiles.getSelectedItem());
              try {
                   carrera = parser.read();
              } catch (Exception z) {
                   z.printStackTrace();
              cursos = carrera.getCursos();
              for (int i = 0; i < cursos.size(); i++) {
                   cur = (Curso) cursos.get(i);
                   dcbmCursos.addElement(cur.getCurso());
         } else if (obj == cmbCursos) {
              dlmAsignaturas.clear();
              int x = cmbCursos.getSelectedIndex();
              cur = (Curso) cursos.get(x);
              asignaturas = cur.getAsignaturas();
              for (int i = 0; i < asignaturas.size(); i++) {
                   dlmAsignaturas.addElement(
                        ((Asignatura) asignaturas.get(i)).getId()
                             + ((Asignatura) asignaturas.get(i)).getGrupo().toLowerCase());
    }

  • Problems with linked ComboBoxes

    Hi everyone, and thanks to those who will reply
    It's been 3 days since i'm having the same problem :
    I have 2 comboboxes in a JPanel, and the things to be displayed in the second one depends on the first (for example selecting 'Hewlett-Packard' in the first combo box display all HP model in the second one)
    When i select a item in the first combobox, an actionPerformed is fired, and i can populate the second combobox. Unfortunately, the combobox disappear in my panel, but if i click on the place where it used to be, the popup list display correctly... !
    I just want to know hox can i make it visible anyway. I've tried combobox2.repaint() method within the actionperformed method (combobox2 is the name of my second combo box as you've guessed), but it doesnt work...
    Something else too : in my first list, if i select another vendor, the list in the second is not removed, but the list of workstation of the second-select manufacturer is appended... I've tried here the combobox2.removeall() method, but here again, no results....
    this is my code :
    public class DocPCConfig extends JFrame implements ActionListener, WindowListener
    /** D�clare les variables utilis�es **/
    JComboBox comboConstructeurs, comboMachines;
    private JPanel imagePanel, panelConstructeur, panelMachines;
    * DocPCConfig()
    * Constructeur par d�faut
    * - But : Initialise les composants Swing de la fen�tre principale
    * - E : -/-
    * - S : -/-
    public DocPCConfig()
    /** Ajoute les composants dans l'onglet **/
    ajoutCompoCstr();
    /** Ajoute un �couteur d'�v�nement de fen�tre **/
    addWindowListener(this);
    * main()
    * - But : Point d'entr�e de l'application
    * - E : String args[] : Tableau de param�tres
    * - S : -/-
    public static void main(String args[])
    System.out.println("Lancement de l'application de configuration");
    new BdD();
    mainFrame = new DocPCConfig();
    mainFrame.setSize(1024,738);
    mainFrame.setTitle("DocPCConfig");
    mainFrame.setVisible(true);
    * ajoutCompoCstr()
    * - But : Ajoute les composants pour le panel de s�lection constructeur/machine (1er onglet)
    * - E : -/-
    * - S : -/-
    public void ajoutCompoCstr()
    java.awt.GridBagConstraints gridBagConstraints1;
    /** Cr�e le vecteur stockant les r�sultats provenant de la BdD **/
    Vector listeConstructeurs = new Vector(10,5);
    /** Se connecte � la BdD **/
    BdD.connecteBdD();
    /** R�cup�re la liste des constructeurs depuis la BdD **/
    listeConstructeurs = BdD.getConstructeurs();
    DefaultComboBoxModel comboModele = new DefaultComboBoxModel(listeConstructeurs);
    BdD.deconnecteBdD();
    /** Lance le constructeur pour la liste d�roulante avec le vecteur de liste
    comme param�tre **/
    comboConstructeurs = new JComboBox(comboModele);
    /** R�gle les param�tres suppl�mentaires **/
    comboConstructeurs.setMaximumSize(new Dimension(5,5));
    comboConstructeurs.setSelectedIndex(-1);
    // comboConstructeurs.setEditable(true);
    /** Ajoute les contraintes graphiques pour la liste des constructeurs **/
    gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.gridx = 1;
    gridBagConstraints1.gridy = 1;
    gridBagConstraints1.insets = new Insets(10, 10, 10, 10);
    panelConstructeur.add(comboConstructeurs, gridBagConstraints1);
    comboConstructeurs.addActionListener(this);
    /** Cr�e les �l�ments de la liste d�roulante **/
    String[] listeMachines = { "                             " };
    comboMachines = new JComboBox(listeMachines);
    comboMachines.setSelectedIndex(0);
    /** Ajoute les contraintes graphiques pour la liste des machines **/
    gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.gridx = 1;
    gridBagConstraints1.gridy = 2;
    gridBagConstraints1.insets = new Insets(10, 10, 10, 10);
    panelConstructeur.add(comboMachines, gridBagConstraints1);
    * actionPerformed(ActionEvent ae)
    * - But : Traiter les op�ration quand une action est effectu�e sur les boutons
    * de l'interface de la fen�tre principale.
    * - E : ActionEvent ae : Un pointeur sur l'action courante.
    * - S :-/-
    public void actionPerformed(ActionEvent ae)
    Object source = ae.getSource();
    /** Liste d�roulante des constructeurs **/
    if (source == comboConstructeurs)
    /** R�cup�re la ligne s�lectionn�e dans la liste **/
    String constructeur = (String)comboConstructeurs.getSelectedItem();
    /** Creation des �l�ments de la liste d�roulante **/
    Vector listeMachines = new Vector(50,1);
    /** Se connecte � la BdD **/
    BdD.connecteBdD();
    listeMachines = BdD.getMachines(constructeur);
    /** Se d�connecte de la BdD **/
    BdD.deconnecteBdD();
    /** Supprime toutes les pr�c�dentes entr�es de la liste des machines **/
    comboMachines.removeAll();
    int i = 0;
    System.out.println(listeMachines.size());
    /** Tant que la liste n'a pas �t� parcourue **/
    while(i < listeMachines.size())
    /** Copie l'�l�ment du vecteur et l'ajoute dans la liste d�roulante **/
    comboMachines.addItem(listeMachines.elementAt(i).toString());
    i++;
    comboMachines.repaint();
    I've removed all the things I found useless, but maybe i've removed too much ;-) I hope that this code is enough.
    Thanks for your help (can you send a copy of your answers at : [email protected] - if you're too lazy to do this that's not a matter, but i don't know how i can find my post in all these posts... so that'd be cool ;-)

    Thanks Martin
    that makes sense now was driving me mad as I couldnt find anything saying it wasnt supported, makes sense seeing as its a flash server. Annoyning thing was it was playing in the content viewer locally when I previewd the folio you would think that would not be the case if it was not supported. Im going to try the rtmp links in a player in a web page and view it on the ipad out of curiosity and ill let you know. Out of interest have you done anyting with imported html into indesign as part of your folios ? I havent as yet but am curious to know how it holds up ?
    Thanks again
    Neil

  • Issue while creating location with database link

    Hi all,
    I am using OWB 10.2.0.4.0 (same Oracle DB version). I am trying to create a location using a database link.
    When I select the location which the database link is located (From location drop-down list), I face the following error.
    >
    ENV0036: The selected location is not valid.
    ENV0036: The selected location is not valid.
         at oracle.wh.service.sdk.integrator.RepositoryUtils.createDBLinkWithLocation(RepositoryUtils.java:156)
         at oracle.wh.ui.environment.wizards.DatabaseLinkComponent.init(DatabaseLinkComponent.java:61)
         at oracle.wh.ui.environment.wizards.DatabaseLinkComponent.reload(DatabaseLinkComponent.java:204)
         at oracle.wh.ui.environment.wizards.FromLocationComponent.itemStateChanged(FromLocationComponent.java:111)
         at javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1162)
         at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1219)
         at javax.swing.JComboBox.contentsChanged(JComboBox.java:1266)
         at javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:100)
         at javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.java:88)
         at javax.swing.JComboBox.setSelectedItem(JComboBox.java:551)
         at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:597)
         at javax.swing.plaf.basic.BasicComboPopup$ListMouseHandler.mouseReleased(BasicComboPopup.java:749)
         at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:232)
         at java.awt.Component.processMouseEvent(Component.java:5100)
         at javax.swing.plaf.basic.BasicComboPopup$2.processMouseEvent(BasicComboPopup.java:452)
         at java.awt.Component.processEvent(Component.java:4897)
         at java.awt.Container.processEvent(Container.java:1569)
         at java.awt.Component.dispatchEventImpl(Component.java:3615)
         at java.awt.Container.dispatchEventImpl(Container.java:1627)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
         at java.awt.Container.dispatchEventImpl(Container.java:1613)
         at java.awt.Window.dispatchEventImpl(Window.java:1606)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
         at java.awt.Dialog$1.run(Dialog.java:542)
         at java.awt.Dialog$3.run(Dialog.java:569)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.awt.Dialog.show(Dialog.java:567)
         at java.awt.Component.show(Component.java:1133)
         at java.awt.Component.setVisible(Component.java:1088)
         at oracle.bali.ewt.wizard.WizardDialog.runDialog(Unknown Source)
         at oracle.bali.ewt.wizard.WizardDialog.runDialog(Unknown Source)
         at oracle.wh.ui.owbcommon.OWBWizard.initialize(OWBWizard.java:815)
         at oracle.wh.ui.owbcommon.OWBWizard.<init>(OWBWizard.java:168)
         at oracle.wh.ui.owbcommon.OWBWizard.<init>(OWBWizard.java:147)
         at oracle.wh.ui.owbcommon.IdeUtils._doLaunchDefinition(IdeUtils.java:1188)
         at oracle.wh.ui.owbcommon.IdeUtils.showWizard(IdeUtils.java:471)
         at oracle.wh.ui.owbcommon.IdeUtils.showWizard(IdeUtils.java:427)
         at oracle.wh.ui.jcommon.tree.WBRepositoryObjectTree.launchWizard(WBRepositoryObjectTree.java:502)
         at oracle.wh.ui.console.commands.CreateByWizardCmd.showUI(CreateByWizardCmd.java:33)
         at oracle.wh.ui.console.commands.CreateCmd.performAction(CreateCmd.java:76)
         at oracle.wh.ui.console.commands.TreeMenuHandler$1.run(TreeMenuHandler.java:188)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:189)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    >
    Could you please let me know how to solve this and how to create such location with OMB*Plus?
    Thanks,
    Sebastian

    Hi David,
    Thanks a lot for the tip. Now I was able to use this and using a registered location.
    OMBCREATE LOCATION 'X' SET PROPERTIES (TYPE,VERSION,CONNECTION_TYPE, SCHEMA) VALUES ('ORACLE_DATABASE','11.1','DATABASE_LINK','MY_SCHEMA')
    OMBCREATE CONNECTOR 'REGISTERED_LOC/X SET PROPERTIES (DATABASE_LINK_NAME) VALUES ('MY_DBLINK') SET REF LOCATION 'X'
    OMBCOMMIT
    OMBCC '/MY_PROJECT'
    OMBCAC 'DEFAULT_CONFIGURATION'
    OMBCONNECT CONTROL_CENTER USE 'owb_user/owb_user'
    OMBREGISTER LOCATION 'X' REUSE
    OMBCOMMITBut now my question is the following.
    I am having problems to import the metadata from X.
    When create a module (source), I am able to make "data location" from location 'X' but when I want to import a table from location 'X' is not possible, because it shows as a plausible metadata location as "REGISTERED_LOC"
    Could you please let me know how to use 'X' as metadata location?
    Thanks!
    Sebastián

  • DropDown in JComboBox

    Hallo
    Does someone know, how i can set the width of the DropDown-Menu from the JComboBox manually??
    i want that the list is larger than the width of the JComboBox.
    thx for help :)
    eagle

    That link above might not work so just use:
    http://www.objects.com.au/java/examples/swing/SteppedComboBox.do

  • How to cause JComboBox to open to preselected item?

    If you initialize a JComboBox to an item (using setSelectedIndex, for instance), the first time that the comboBox is opened, it will open at the top of the list, not at the selected item. For example:
    JComboBox jComboBoxHourPicker = new JComboBox();
    // Add comboBox items here
    jComboBoxHourPicker.setSelectedIndex(22);
    The comboBox will correctly show the 23rd item selected. When the user opens the comboBox, however, it will open at the first item, not at the 23rd. If the user closes the comboBox without changing the selection, though, the next time that the comboBox is opened it will have scrolled to the selected item.
    The JList class has the ensureIndexIsVisible() method. Does anyone know how to get the same behavior for the JComboBox class?

    This is a known bug that has been fixed in v1.4. Check out the thread below, by me, for all the details. You're following in my footsteps.
    If you need a workaround for 1.3, follow the link into the bug database and there's a pretty decent one there.
    http://developer.java.sun.com/developer/bugParade/bugs/4337516.html

  • Help with a JComboBox

    How do I store id's with items in a JComboBox???
    This is pretty important functionality of a combobox so I am sure it is there, I just can't seem to find it.
    For example, I have 3 items. Dog, Cat, Bird with id's 100, 106, 114 respectively. I want to display the names, not the id's but when I get the selected item all I care about is the id... is there anyway to link them in the combo box??? This is simple in C++ to do not sure why I can't do it in Java.

    Create a class that contains the String to display and the key value. Implement the toString method to return the string value. When you get the selected item (object) read the key.
    class ComboItem {
      public String display;
      public int     key;
      public ComboItem(String display, int key) {
        this.display = display;
        this.key     = key;
    public String toString() { return display;}
    combo.addItem( new ComboItem("item 1",1));
    int key = ((ComboItem)combo.getSelectedItem()).key;
    ...

  • JComboBox : colors in the selected value field

    I have a JComboBox with a custom ListCellRenderer. However the JComboBox seems to change the colors of the Component that my ListCellRenderer creates when the Component is in the Selected value field. Some code is below...
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class ComboBoxTest {
      public static final void main(String[] args) {
        JComboBox cbox;
        Vector elements;
        elements = new Vector();
        elements.add("One");
        elements.add("Two");
        elements.add("Three");
        cbox = new JComboBox(elements);
        cbox.setRenderer(new MyRenderer());
        cbox.setEditable(false);
        JFrame frame = new JFrame();
        JPanel content = (JPanel) frame.getContentPane();
        content.add(cbox);
        frame.pack();
        frame.setVisible(true);
    class MyRenderer implements ListCellRenderer {
      public Component getListCellRendererComponent(
        JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus)
        String strValue;
        JLabel label;
        strValue = (String) value;
        label = new JLabel("<" + strValue + ">");
        label.setOpaque(true);
        if( isSelected ) {
          label.setForeground(Color.black);
          label.setBackground(Color.green);
        } else {
          label.setForeground(Color.white);
          label.setBackground(Color.black);
        return label;
    }This code simply creates a JComboBox with 3 String values, "One", "Two", and "Three". The renderer creates a JLabel with the String value enclosed in triangle brackets. The renderer also sets the colors of the JLabel to white on black if unselected and black on green if selected.
    When I run this program, the list portion of the JComboBox looks correct, but the entry in the edit field is wrong. It has the enclosing triangle brackets around the selected String, but the colors are still the default black on gray.
    What do I need to do to get the colors in the edit field to display correctly?
    - James

    A JComboBox is similar to a JSpinner in the sense that it has an associated editor that has an associated textfield....check out the link shown below
    http://forum.java.sun.com/thread.jsp?forum=57&thread=385077
    ;o)
    V.V.

  • How to put multi columns in JComboBox?

    I only need a table with two columns in combo box. For example, id and title. The id can be auto complete search. The two columns only are displayed in pop up. Thank you for any suggestion!

    I searched the forum using "jcombobox multiple columns". The first posting I read had a link to a posting with 4 different solutions.
    Why is it so hard to search the forum before posting a question????

  • JComboBox in JTreeTable

    One column in my JTreeTable (or JTable, doesn't matter) is a JComboBox. If it's a Checkbox the cell must be a "Boolean" and it's selected automatically if it's true. If I have a JLabel of JTextField the cell must be a String.
    But how do I set the selectedIndex of the ComboBox from my DataTable? For Instance:
    The ComboxBox has the items: "Michael", "Peter" and "Paul". The Cell is a String and is "Peter".
    What do I have to do in my ColumnModel that the ComboxBox for that cell shows "Peter". For all rows is always the first item visible.
    Thank you
    Jonas

    hi
    this is one link u can refer
    http://www.codeguru.com/java/articles/185.shtml
    http://www.devx.com/premier/mgznarch/javapro/2001/01jan01/vc0101/vc0101.asp
    i have tried first link that works fine
    Hope this helped u
    Renjith

  • JComboBox don't work here

    I have a code like below, it complile fine, but the JComboBox don't work. If I resize the GUI manaually to very small height, these JComboBox start work. I don't understand why this happens. Any idea is high appreciated. Please email me at [email protected] Many thanks.
    import javax.swing.*;
    import java.awt.HeadlessException;
    import java.awt.*;
    public class testComboBox extends JFrame {
    String[] _tmp={"XY PLOT", "AREA", "PIE", "BAR", "CANDLE"};
    JComboBox cb1= new JComboBox(tmp);
    String[] _tmp1={"Top", "Bottom"};
    JComboBox cb2=new JComboBox(tmp1);
    String[] _tmp2={"SOUTH","EAST"};
    JComboBox cb3=new JComboBox(tmp2);
    public testComboBox() throws HeadlessException {
    this.setSize(new Dimension(200, 180));
    JPanel _jp=new JPanel();
    _jp.setSize(new Dimension(200, 160));
    _jp.setLayout(new GridBagLayout());
    GridBagConstraints _myBag= new GridBagConstraints();
    _myBag.insets=new Insets(2,2,2,2);
    _myBag.weightx=1.0;
    _myBag.weighty=1.0;
    _myBag.gridx=0;
    _myBag.gridy=0;
    jp.add(cb1, _myBag);
    _myBag.gridx=0;
    _myBag.gridy=1;
    jp.add(cb2, _myBag);
    _myBag.gridx=0;
    _myBag.gridy=2;
    jp.add(cb3, _myBag);
    this.getRootPane().setLayout(new GridBagLayout());
    GridBagConstraints _myBag1= new GridBagConstraints();
    _myBag1.insets=new Insets(2,2,2,2);
    _myBag1.weightx=1.0;
    _myBag1.weighty=1.0;
    _myBag1.gridx=0;
    _myBag1.gridy=0;
    this.getRootPane().add(_jp, _myBag1);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);
    public static void main(String[] args) throws HeadlessException {
    testComboBox testComboBox1 = new testComboBox();
    testComboBox1.show();

    try adding testComboBox1.pack() before the show()
    honestly, you'll get a better answer posing a link to this in the swing forum (do not X-post, just put in a link to this)

  • PopupMenuListener event on JComboBox fires multiple times per selection

              // webAddressBox IS OF TYPE javax.swing.JComboBox
               webAddressBox.addPopupMenuListener(new PopupMenuAdapter() {
                    /** @uses {@link com.ppowell.tools.ObjectTools.SimpleBrowser.Surf} */
                    final Surf surf = new Surf(webAddressBox.getSelectedItem().toString());
                     * Perform {@link #surf} processing
                     * @param evt {@link javax.swing.event.PopupMenuEvent}
                    public void popupMenuWillBecomeInvisible(PopupMenuEvent evt) {
                        System.out.println("you selected:");
                        surf.doURLProcessing();
    * PopupMenuAdapter.java
    * Created on February 16, 2007, 11:53 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package com.ppowell.tools.ObjectTools.SwingTools;
    import javax.swing.event.PopupMenuEvent;
    import javax.swing.event.PopupMenuListener;
    * Will allow for greater flexibility by implementing {@link javax.swing.event.PopupMenuListener}
    * @author Phil Powell
    * @version JDK 1.6.0
    public abstract class PopupMenuAdapter implements PopupMenuListener {
        /** Creates a new instance of PopupMenuAdapter */
        public PopupMenuAdapter() {}
         * Overrides {@link javax.swing.event.PopupMenuListener} method popupMenuCanceled
         * @param evt {@link javax.swing.event.PopupMenuEvent}
        public void popupMenuCanceled(PopupMenuEvent evt) {}
         * Overrides {@link javax.swing.event.PopupMenuListener} method popupMenuWillBecomeInvisible
         * @param evt {@link javax.swing.event.PopupMenuEvent}
        public void popupMenuWillBecomeInvisible(PopupMenuEvent evt) {}
         * Overrides {@link javax.swing.event.PopupMenuListener} method popupMenuWillBecomeVisible
         * @param evt {@link javax.swing.event.PopupMenuEvent}
        public void popupMenuWillBecomeVisible(PopupMenuEvent evt) {}
    }This code is supposed to handle a single selection from a JComboBox webAddressBox. The front-end functionality of this code blocks works just fine to the user, however, upon viewing the "behind the scenes action", I noticed that the overriden popupMenuWillBecomeInvisible() method within the anonymous inner class instance of PopupAdapter is being called 2 times upon the first time you select something from webAddressBox, 4 times the next time you select something, 8 times the next time, and so on..
    Obviously this is a tremendous waste of resources to have it call that many times exponentially - it should only call once each time you select something from webAddressBox, but I can't figure out how to get that to happen.
    What suggestions might you have to accomplish this? I already have an ActionListener that runs separately from PopupMenuAdapter that handles the user either clicking a JButton or hitting ENTER - this works just fine.
    Thanx
    Phil

    is being called 2 times upon the first time youselect something from
    webAddressBox, 4 times the next time you selectsomething, 8 times the next time, and so on..
    Then you are adding the listener to the component
    multiple times.WTO sigh.. thanx! :)

  • Complete a JComboBox in netbeans

    Hi!
    I need to complete the info that a JCombobox shows when it is click?
    How do i do that?
    I tried:
    jComboBox1.addItem("Host Master Key");
    jComboBox1.addItem("Main Communication Key");
    jComboBox1.setSelectedIndex(0);
    But it doesn�t work, when i execute it, it doesn�'t show "Host Master Key"or "Main Communication Key"
    can you help me?

    can you help me? Based on 3 lines of code we have no idea whats wrong.
    So here is a link to the Swing tutorial on "How to Use Combo Boxes":
    http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html
    It has working examples which you can compare to your own code.

  • Question about JComboBox

    Hello, I've a little problem with a JComboBox. I'm going to explain what's going wrong:
    I have a MySQL database with a table "Swimmers" (id, name, address,..). I want to show the swimmers in a JComboBox and that's no problem. I just get the id + name of all the swimmers with SQL and put their name into the JComboBox with addItem().
    But when I click on a button "Modify", the user can modify the swimmer he selected in de JComboBox. So it's important that there is a link between the items/swimmers in the JComboBox and the id of the swimmer. And that's my problem...
    With getSelectedIndex(), I can get the index of the selected item. But I don't want to get the index, I want to get the ID of the selected swimmer. So the ID of the selected swimmer in the JComboBox.
    So, a litle example:
    In my database, I have the following items:
    ID                    Name                                Address
    ========================================================
    1                     Jos Vermeulen                   Apenstraat 54, Brussel
    4                     Geert De Greef                   Kerkstraat 1, Antwerpen
    8                      Sandra Geeroms                Blastraat 45, GentThe dropdown likes has the following items:
    Jos Vermeulen      (at index 0)
    Geert De Greef      (at index 1)
    Sandra Geeroms    (at index 2)For example: I select "Geert De Greef" and click on the button "Modify". Than the program has to know that the ID of "Geert De Greef" is 4. So I have to add the ID as a value in the JComboBox.. But how?
    Do you understand what I mean?
    I have to know the ID (in the database) of the selected item.. How can I get it?
    Edited by: geertgreef on Apr 28, 2009 4:17 AM

    How do I have to add the array into the JComboBox?Its no different using an array of Swimmers than it would be using an array of Strings. So just try it.
    An how can I "decide" that only the string that is returned by method toString() has to be visible?Thats the way the default renderer works. Read the Swing tutorial on "How to Use Combo Boxes".
    Again just try it. If you have a problem then you post a question. Don't assume you will have a problem.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • JComboBox as a cell in Jtable

    Hi
    I added JComboBox objects as the cell values for some specific rows of a JTable.
    But when I click on the combobox for the value selection, expansion is not visible. Ineterestingly, I figured out it is expanding, but at the behind the table.
    I mean if last row of the table has a combobox with more values(the list length exceeds table boundaries), broken values list is displayed from the border of the table.
    So it appears other combo boxes are also expanded but behind the table.
    Can any one help how to make this expansion visible.?
    Thanks

    Read the JTable API and follow the link to the Swing tutorial on "How to Use Tables" for working examples of using a combo box in a table.

Maybe you are looking for