New entry in editable JComboBox

I have been looking through the forum to try and find an answer to this, but I can only find queries about positioning in an editable combo box. what i want to do is for a person to be able to select an item from a combo box, or enter a new item. is this possible?

JComboBox myComboBox = new JComboBox();
myComboBox.setEditable(true);
myComboBox.addItem("Hello");
myComboBox.addItem("There");
myComboBox.addActionListener(new java.awt.event.ActionListener() {
  public void actionPerformed(ActionEvent e) {
    if (myComboBox.getSelectedIndex()==-1) {
      myComboBox.addItem(myComboBox.getSelectedItem());
});

Similar Messages

  • Editable JComboBox -Saving itz new value in the database.

    Hi,
    I have a Combobox say Product , in which some fields (like -> tv , hand blender etc) comes from Database and i have added one more field say others ,
    in others field user can enter new product name and it shd be saved in the same database, i have used editable jcombobox but dnt no how to proceed further.
    Thanks & Regards
    Komal

    And make a provision to delete wrong entries, or you'll end up with all the typos stored separately.
    I speak from experience. I actually have such a combo in several of my VFP applications (not in Java though)
    db

  • Editable JCombobox cell editor length limit

    Hi All,
    I have an editable JCombobox as a celleditor to one of the column in JTable, How do I limit the characters in the cell editor?
    Thanks

    A JComboBox uses a JTextField as it's cell editor. You should read up on how you would do this for a normal JTextField by using a custom Document:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
    Here's an example using JComboBox. I haven't tried it in a JTable but I assume it should work.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.plaf.basic.*;
    public class ComboBoxNumericEditor extends BasicComboBoxEditor
         public ComboBoxNumericEditor(JComboBox box)
              editor.setDocument( new NumericListDocument(box.getModel()) );
         public static void main(String[] args)
              String[] items = { "one", "two", "three", "four" };
              JComboBox list = new JComboBox( items );
              list.setEditable( true );
              list.setEditor( new ComboBoxNumericEditor( list ) );
              JFrame frame = new JFrame();
              frame.getContentPane().add( list );
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
         class NumericListDocument extends PlainDocument
              ListModel model;
              public NumericListDocument(ListModel model)
                   this.model = model;
              public void insertString(int offset, String text, AttributeSet a)
                   throws BadLocationException
                   //  Accept all entries in the ListModel
                   for (int i = 0; i < model.getSize(); i++)
                        Object item = model.getElementAt(i);
                        if (text.equals( item.toString() ))
                             super.insertString(offset, text, a);
                             return;
                   //  Build the new text string assuming the insert is successfull
                   String oldText = getText(0, getLength());
                   String newText =
                        oldText.substring(0, offset) + text + oldText.substring(offset);
                   //  Edit the length of the new string
                   if (newText.length() > 2)
                        Toolkit.getDefaultToolkit().beep();
                        return;
                   //  Only numeric characters are allowed in the new string
                   //  (appending the "0" will allow an empty string to be valid)
                   try
                        Integer.parseInt(newText + "0");
                        super.insertString(offset, text, a);
                   catch (NumberFormatException e)
                        Toolkit.getDefaultToolkit().beep();
    }

  • JTable with editable JComboBoxes

    For some reason once I added editable JComboBoxes to a JTable I can no longer tab among the fields in the table. If I just select a cell, I can tab to the other cells in that row, and then to proceeding rows as I reach the end of each. However if I double click the cell and enter data or select from the combobox. I no longer can tab to the next cell. At that point once I do hit tab, I am taken to the next table. Not the next cell in the row, or the next row in the current table.
    I have tried messing with a bunch of listeners, but I am not using the right listener on the right object? What listerner and object should the listener belong to? Table, model, cell editor, combobox, jpanel, jframe ? I hope this is not to vague.

    Well I am starting to think it's an implementation issue. Like I am not doing it how I should. I am basically doing
    JComboBox jcb = new JComboBox();
    jcb.setEditable(true);
    column.setCellEditor(new DefaultCellEditor(jcb));
    When I think I should be inheriting, and creating my own editor and/or renderer? Now my combobox vars are globally available in the class, so I can set and clear their contents. It does not matter that each row in the table has the same content in the combo boxes, that's basically what I want. User to be able to select an existing entry or make a new one.
    What I am trying to do is on tables have a drop down box that shows up when a user types a matching entry. If no entry matches, no popup box. If entry matches, box pops up and shows possible entries starting with what they are typing. Like code completion in IDE's like Netbeans. However I am doing this in a table. I thought a JComboBox would be a good widget to start with?

  • How can I use a FocusEvent to distinguish among editable JComboBoxes?

    Hi,
    I have a Frame with multiple editable JComboBoxes, but I am at a loss as to how to sort them out in the focusGained() method.
    It is easy when they are not editable, because the FocusEvent getSource() Method returns the box that fired the event. That lets me read an instance variable that is set differently for each box.
    But with editable boxes, the FocusEvent is not fired by the box. It is fired by a Component object returned by getEditor().getEditorComponent(). So far I cannot find a way to query that object to find the box it it tied to. (I hope this isn't going to be painfully embarassing.).
    Anyway, the code below produces a frame with four vertical components: a JTextField (textField), a NON-Editable JComboBox (comboBox1) and two Editable JComboBoxes (comboBox2 & comboBox3).
    This is the command screen produced by :
    - Running the class
    - Then tabbing through all the components to return to the text field.
    I am not sure why, but it gives the last component added the foucus on startup.Focus Gained - Begin: *****
       This is the comboBox that Is Not Editable
    Focus Gained - End: *******
    Focus Gained - Begin: *****
       This Is The TextField
    Focus Gained - End: *******
    Focus Gained - Begin: *****
       Class: class javax.swing.plaf.metal.MetalComboBoxEditor$1
       Name: javax.swing.plaf.metal.MetalComboBoxEditor$1
    Focus Gained - End: *******
    Focus Gained - Begin: *****
       Class: class javax.swing.plaf.metal.MetalComboBoxEditor$1
       Name: javax.swing.plaf.metal.MetalComboBoxEditor$1
    Focus Gained - End: *******
    Focus Gained - Begin: *****
       This is the comboBox that Is Not Editable
    Focus Gained - End: *******
    Focus Gained - Begin: *****
       This Is The TextField
    Focus Gained - End: *******As you can see, the FocusEvent source for both editable boxes is a MetalComboBoxEditor. Both have identical names.
    Can anyone help me get from there back to the actual combo box so I can read the instance variable to see which one fired the event?
    The (painfully tedious and inelegant ) code that produced the above output is:import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class TestListeners extends JFrame
      implements ActionListener, DocumentListener,
                             FocusListener,  ItemListener {
      // Constructor
       TestListeners () {
          super ();
          panel.setLayout (new GridLayout (4, 1));
          textField.addActionListener (this);
          textField.getDocument ().addDocumentListener (this);
          textField.addFocusListener (this);
          panel.add(textField);
          comboBox2.addActionListener (this);
          comboBox2.getEditor().getEditorComponent ().addFocusListener (this);
          comboBox2.addItemListener (this);
          comboBox2.setEditable (true);
          panel.add (comboBox2);
          comboBox3.addActionListener (this);
          comboBox3.getEditor().getEditorComponent ().addFocusListener (this);
          comboBox3.addItemListener (this);
          comboBox3.setEditable (true);
          panel.add (comboBox3);
          comboBox1.addActionListener (this);
          comboBox1.addFocusListener (this);
          comboBox1.addItemListener (this);
          comboBox1.setEditable (false);
          panel.add (comboBox1);
          this.getContentPane ().add(panel);
          this.setVisible (true);
          pack ();
       // Nested class
        public class CB extends JComboBox {
           // Nested Constructor
          public CB  (Vector items, String str) {
             super (items);
             this.type = str;
          public String type;
       // Instance Members
       JTextField     textField = new JTextField ("Test Listener TextField");
       JPanel panel  = new JPanel ();
       String[] str = {"one", "two", "three"};
       Vector items = new Vector (Arrays.asList (str));
       CB comboBox1 = new CB (items, "Is Not Editable");
       CB comboBox2 = new CB (items, "Is Editable 2");
       CB comboBox3 = new CB (items, "Is Editable 3");
       // Methods
       public static void main(String args[]) {
          TestListeners frame = new TestListeners ();
       public void actionPerformed (ActionEvent ae) {
          System.out.print ("ActionEvent: This is ");
           if (ae.getSource ().getClass () == CB.class) {
             System.out.print ( ((CB) ae.getSource ()).type + " ");
          System.out.println (" "+ae.getActionCommand() + "\n" );
       public void focusGained (FocusEvent fge) {
          System.out.println ("Focus Gained - Begin: ***** ");
          if (fge.getSource ().getClass () == CB.class) {
          System.out.println ( "   This is the comboBox that "+((CB) fge.getSource ()).type);
          } else if (fge.getSource ().getClass () == JTextField.class) {
             System.out.println ( "   This Is The TextField");
         } else {
             System.out.println ("   Class: "+fge.getSource ().getClass());
             System.out.println ("   Name: "+fge.getSource ().getClass ().getName ());
         System.out.println ("Focus Gained - End: *******\n*\n");
       public void focusLost (FocusEvent fle) { }
       public void changedUpdate (DocumentEvent de) { }
       public void insertUpdate (DocumentEvent de) { }
       public void removeUpdate (DocumentEvent de) { }
       public void itemStateChanged (ItemEvent ie) { }
    }

    I added the following in your focusGained() method and it seemed to work:
    Component c = ((Component)fge.getSource ()).getParent();
    if (c instanceof JComboBox)
         JComboBox cb = (JComboBox)c;
         System.out.println("Selected: " + cb.getSelectedItem());
    }

  • Cannot create and add a new entry to LDAP

    Hi,
    I'm pretty new at LDAP and JNDI, i've been trying to create and add a new entry to the directory but somehow it's not working.
    here is my code and I would appreciate it if someone can help.
    import java.util.Hashtable;
    import javax.naming.ldap.*;
    import javax.naming.directory.*;
    import javax.naming.*;
    import javax.net.ssl.*;
    import java.io.*;
    public class Newuser
         public static void main (String[] args)
              //LDAPEntry myEntry = new LDAPEntry();
              Hashtable<String, String> env = new Hashtable<String, String>(11);
              String adminName = "CN=ldap_admin,o=JNDITutorial,dc=img,dc=org";
              String adminPassword = "secret";
              env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
              //set security credentials, note using simple cleartext authentication
              env.put(Context.SECURITY_AUTHENTICATION,"simple");
              env.put(Context.SECURITY_PRINCIPAL,adminName);
              env.put(Context.SECURITY_CREDENTIALS,adminPassword);
              //connect to my domain controller
              env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial,dc=img,dc=org");
                   // Create the initial directory context
                   //JNDILDAPConnectionManager jndiManager = new JNDILDAPConnectionManagerImpl();
                  try{
                       DirContext ctx = new InitialDirContext(env);
                        System.out.println("Connection to LDAP server done" );
                       final String groupDN ="ou=people,o=JNDITutorial,dc=img,dc=org";
                      //DirContext dirCtx = jndiManager.getLDAPDirContext();
                      People people = new People("Thiru","Thiru","Thiru Ganesh","Ramalingam","ou=people","[email protected]");
                      // The Common name must be equal in Attributes common Name
                      ctx.bind("cn=Thiru," + groupDN, people);
                      System.out.println("** Entry added **");
                      //jndiManager.disConnectLDAPConnection(ctx);
                  }catch(NamingException exception){
                      System.out.println("**** Error ****");
                      exception.printStackTrace();
                      System.exit(0);
    }here is the Object class People that i'm trying to instantiate
    public class People implements DirContext {
         public People(String uid,String cn,String givenname,String sn,String ou,String mail) {
        BasicAttributes myAttrs = new BasicAttributes(true);  //Basic Attributes
        Attribute objectClass = new BasicAttribute("objectclass"); //Adding Object Classes
        objectClass.add("inetOrgPerson");
        /*objectClass.add("organizationalPerson");
        objectClass.add("person");
        objectClass.add("top");*/
        Attribute ouSet = new BasicAttribute("ou");
        ouSet.add("people");
        ouSet.add(ou);
        myAttrs.put(objectClass);
        myAttrs.put(ouSet);
        myAttrs.put("cn",cn);
        myAttrs.put("sn",sn);
        myAttrs.put("mail",mail);
    ...the message i keep getting is:
    javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - entry has no objectClass attribute]
    the thing is that I can create and add a new entry in openLDAP from the console and it works.
    and here is how I proceed
    I create a text file: new.txt
    dn:cn=Hamido Saddo,ou=People,o=JNDITutorial,dc=img,dc=org
    cn:Hamido Saddo
    mail:[email protected]
    telephonenumber:3838393038703
    sn:hamdio
    objectclass:top
    objectclass:person
    objectclass:organizationalPerson
    objectclass:inetOrgPersonand i use this command to add the entry:
    ldapadd -D "cn=ldap_admin,O=JNDITutorial,dc=img,dc=org" -W -f new.txtand everything works, i get no errors.
    does anyone has a clue maybe???

    You must have an IMAP email account in order to add additional folders on the iPad mail app.
    If you go to your email account in the Mail app and look at the window where your inbox, trash folder and sent folder are - if there is an Edit button at the top of the window - tap that and then tap Add Mailbox at the bottom.
    If the Edit button is not there - you cannot create folders on the iPad. Your email account is not IMAP. Only IMAP email accounts can create folders on the iPad. Any folders that you would already have in an IMAP account would sync to the device as well.

  • Not able to create new entry in RSADMIN Table

    Hi All,
            I am going thru the OSS note 1275837  (Note 1275837 - PrecServer: process based load distribution (ABAP part)), as it recommends
            add the entry "BWPREC_USE_NEW_LOAD" with value "X" in table "RSADMIN"
          When I check in SE11 and SE16 there is no option to create button for above entry in table RSADMIN.
          Please advise for any help to create above entry.
    Thanks
    Ganesh Reddy.
    Edited by: Ganesh Reddy on Jan 11, 2010 4:20 PM
       I got access key from our basis team. But still not able to create new entry as mentioned in OSS note. Any further help....
    Thanks
    Ganesh Reddy.
    Edited by: Ganesh Reddy on Jan 11, 2010 9:13 PM

    Hi
    Goto SM30 - Table Maintanance Generator and enter the table name and click on button maintain ,it will show the error message
    "The maintenance dialog for RSADMIN is incomplete or not defined" because the table maintenance is not allowed manually.
    First Option
    When you double click the error message  a performance assistant screen will open in that you can see Procedure
    "Generate the required maintenance dialog" click on that and try to maintain the table using Access Key, as i dont have access key i have not tried this option.
    Second Option
    You can write an SE38 program with an insert statement.
    TABLES rsadmin.
    DATA: wa TYPE rsadmin.
    wa-object = 'object name'.
    wa-value = 'X'.
    INSERT into rsadmin values wa.
    Thanks

  • Unable to create new entry in table that has no primary key

    Hi
       I have a table which is required to have no primary key (except mandt). After i generate table maintanance, when I go to create new entries, the table control to enter the new values does not appear. When I click on edit->new entries, it goes back to the fields tab of the table. Same when i check through SM30.
    If i maintain atleast one primary key, I am able to get the table control in new entries screen. However the requirement permits no primary keys except mandt. How can this be resolved?
    Thanks
    NM

    Hi,
    THE PROBLEM WITH UR TABLE IS
    YOU HAD DECLARED MANDT AS THE PRIMARY KEY AND THERE IS NO OTHER KEY IN UR TABLE
    iT'S NOT ALLOWING YOU TO ADD NEW ENTRIES BECAUSE MANDT IS THE ONLY PRIMARY KEY IN YOUR TABLE AND IT WILL HAVE A DEFAULT VALUE BASED ON THE CLIENT. SO  IT'S NOT SHOWING YOU THE CREATE NEW ENTRIES OPTION.
    SO TRY TO PUT ONE MORE FIELD AS THE PRIMARY KEY SO THAT YOUR PROBLEM WILL SOLVE VERY EASILY  ALSO MAKE SURE THAT TABLE IS ACTIVATED.
    REVERT IF U NEED SOME MORE HELP
    Thanks &Regards.
    Pavan.

  • New entry for a view in SM30 does not save

    Hi all,
    I created a new entry for a view in SM30.
    Then when I tried to SAVE it, it does not SAVE and comes back to the same screen with the new entry. And it continues, until you CANCEL and come out.
    Please let me know the reason for it.
    Thanks and regards,
    Anishur

    copy the sap view to a zview make the modifications and generate in se11 the table maintenance generator.
    why was it necessary to make the modification to the original SAP view ??
    kind regards
    arthur
    Edited by: A. de Smidt on Apr 16, 2009 9:08 AM

  • Adding new entry in table J_1INEXCGRP

    Hi,
    I am MM functional,  due to some system error , for the excsie group I required to manitain the entry in table J_1INEXCGRP,  as that customization part is not included in request,  now I want to confirm which methode to be use
    SE12->Utilities -> Table content -> create entry   or  with SE16N
    can you please give the stpes for adding a new entry in this table it has only two fileds
    MANDT
    J_1IEXCGRP
    regards,
    zafar
    Moderator Message: Spoon-feeding is not entertained here.
    Edited by: kishan P on Jan 25, 2011 4:58 PM

    Hi Alok,
    Hope this steps - code will help you to resolve this issue.
    1. Create A Group for your table control. In Screen Painter.
    2. Write Screen modification routine for the same
    it can be like this..
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
      LOOP AT SCREEN.
        IF screen-group1 = 'MOD'.
          IF flag = ' '.
            screen-input = '0'.
          ELSEIF flag = 'X'.
            screen-input = '1'.
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    ENDMODULE.
    3. This will disable the display of the Fields in TABLE Control.
    4. in the PBO loop of the table control. Identify the lines which u want to keep active.
    Hope this will help
    <i><b>** Reward points to helpful answer</b></i>

  • Blank values for editable JComboBox

    Hello,
    I have a editable JComboBox that the user can erase its current value and if they simple change focus (like click on a text field on the same panel) the combo box is left blank. i would like to have it so that if the user leaves focus of the box and its blank that current value goes back to what it was before they erased it.
    Many thanks,
    Jonathan

    import java.awt.FlowLayout;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    public class NonBlankCombo {
       JComboBox comboBox;
       Object previousContent;
       void makeUI() {
          Object[] data = {"One", "Two", "Three", "Four", "Five"};
          previousContent = data[0];
          comboBox = new JComboBox(data);
          comboBox.setEditable(true);
          comboBox.addItemListener(new ItemListener() {
             public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED
                      && !((String) comboBox.getSelectedItem()).trim().isEmpty()) {
                   previousContent = comboBox.getSelectedItem();
          comboBox.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
             public void focusGained(FocusEvent e) {
                previousContent = comboBox.getSelectedItem();
             public void focusLost(FocusEvent e) {
                if (((String)comboBox.getSelectedItem()).trim().isEmpty()) {
                   comboBox.setSelectedItem(previousContent);
          JFrame frame = new JFrame("Non-blank Combo");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(200, 100);
          frame.setLayout(new FlowLayout());
          frame.add(comboBox);
          frame.add(new JButton("Click"));
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                new NonBlankCombo().makeUI();
    }db

  • Editable JComboBox in a JTable

    I posted my problem into the "Java Essentials/Java programming" forum but it would be much better if I'd posted it here into the swing theme :).
    Here it is what I posted:
    Funky_1321
    Posts:8
    Registered: 2/22/06
    editable JComboBox in a JTable
    Oct 21, 2006 1:32 PM
    Click to email this message
    Hello!
    Yesterday I posted a problem, solved it and there's another one, referring the same theme.
    So it's about a editable JComboBox with autocomplete function. The combo is a JTables cellEditors component. So it's in a table. So when the user presses the enter key to select an item from the JComboBox drop down menu, I can't get which item is it, not even which index has the item in the list. If for exemple the JComboBox isn't in a table but is added on a JPanel, it works fine. So I want to get the selectedItem in the actionPerformed method implemented in the combo box. I always get null instead of the item.
    Oh... if user picks up some item in the JComboBox-s list with the mouse, it's working fine but I want that it could be picked up with the enter key.
    Any solutions appreciated!
    Thanks, Tilen
    YAT_Archivist
    Posts:1,321
    Registered: 13/08/05
    Re: editable JComboBox in a JTable
    Oct 21, 2006 1:55 PM (reply 1 of 2)
    Click to email this message
    I suggest that you distill your current code into a simple class which has the following attributes:
    1. It can be copied and pasted and will compile straight out.
    2. It has a main method which brings up a simple example frame.
    3. It's no more than 50 lines long.
    4. It demonstrates accurately what you've currently got working.
    Without that it's hard to know exactly what you're currently doing, and requires a significant investment of time for someone who hasn't already solved this problem before to attempt to help. I'm not saying that you won't get help if you don't post a simple demo class, but it will significantly improve your chances.
    Funky_1321
    Posts:8
    Registered: 2/22/06
    Re: editable JComboBox in a JTable
    Oct 21, 2006 2:11 PM (reply 2 of 2)
    Click to email this message
    Okay ... I'll write the code in short format:
    class acJComboBox extends JComboBox {
      public acJComboBox() {
        this.setEditable(true);
        this.setSelectedItem("");
        this.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) {
         // ... code code code
         // that's tricky ... the method getSelectedItem() always returns null - remember; the acJComboBox is in a JTable!
         if (e.getKeyCode() == 10 && new String((String)getEditor().getItem()).length() != 0) { getEditor().setItem(getSelectedItem()); }
    }And something more ... adding the acJComboBox into the JTable:
    TableColumn column = someTable.getColumn(0);
    column.setCellEditor(new DefaultCellEditor(new acJComboBox());
    So if the user presses the enter key to pick up an item in the combo box drop down menu, it should set the editors item to the selected item from the drop down menu (
    getEditor().setItem(getSelectedItem());
    When the acJComboBox is on a usual JPanel, it does fine, but if it's in the JTable, it doesn't (getSelectedItem() always returns null).
    Hope I described the problem well now ;).

    Okay look ... I couldn't write a shorter code just for an example. I thought that my problem could be understoodable just in mind. However ... type in the first combo box the letter "i" and then select some item from the list with pressing the enter key. Do the same in the 2nd combo box who's in the JTable ... the user just can't select that way if the same combo is in the JTable. Why? Thanks alot for future help!
    the code:
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.Vector;
    import javax.swing.DefaultCellEditor;
    import javax.swing.DefaultComboBoxModel;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableColumn;
    class Example extends JFrame {
        private String[] columns = { "1", "2", "3" };
        private String[][] rows = {};
        private DefaultTableModel model = new DefaultTableModel(rows, columns);
        private JTable table = new JTable(model);
        private JScrollPane jsp = new JScrollPane(table);
        private acJComboBox jcb1 = new acJComboBox();
        private acJComboBox jcb2 = new acJComboBox();
        public Example() {
            // initialize JFrame
            this.setLayout(null);
            this.setLocation(150, 30);
            this.setSize(300, 300);
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            // initialize JFrame
            // initialize components
            Vector<String> v1 = new Vector<String>();
            v1.add("item1");
            v1.add("item2");
            v1.add("item3");
            jcb1.setData(v1);
            jcb2.setData(v1);
            jcb1.setBounds(30, 30, 120, 20);
            jsp.setBounds(30, 70, 250, 100);
            add(jcb1);
            add(jsp);
            TableColumn column = table.getColumnModel().getColumn(0);
            column.setCellEditor(new DefaultCellEditor(jcb2));
            Object[] data = { "", "", "" };
            model.addRow(data);
            // initialize components
            this.setVisible(true);
        public static void main(String[] args) {
            Example comboIssue = new Example();
    class acJComboBox extends JComboBox {
        private Vector<String> data = new Vector<String>();
        private void init() {
            this.setEditable(true);
            this.setSelectedItem("");
            this.setData(this.data);
            this.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) {
                        if (e.getKeyCode() != 38 && e.getKeyCode() != 40) {
                            String a = getEditor().getItem().toString();
                            setModel(new DefaultComboBoxModel());
                            int st = 0;
                            for (int i = 0; i < getData().size(); i++) {
                                String str1 = a.toUpperCase();
                                String tmp = (String)getData().get(i).toUpperCase();
                                if (str1.length() <= tmp.length()) {
                                    String str2 = tmp.substring(0, str1.length());
                                    if (str1.equals(str2)) {
                                        DefaultComboBoxModel model = (DefaultComboBoxModel)getModel();
                                        model.insertElementAt(getData().get(i), getItemCount());
                                        st++;
                            getEditor().setItem(new String(a));
                            JTextField jtf = (JTextField)e.getSource();
                            jtf.setCaretPosition(jtf.getDocument().getLength());
                            hidePopup();
                            if (st != 0 && e.getKeyCode() != 10 && new String((String)getEditor().getItem()).length() != 0) { showPopup(); }
                            if (e.getKeyCode() == 10 && new String((String)getEditor().getItem()).length() != 0) { getSelectedItem(); }
                            if (new String((String)getEditor().getItem()).length() == 0) { whenEmpty(); }
            this.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) {
                hidePopup();
        // - constructors -
        public acJComboBox() {
            init();
        public acJComboBox(Vector<String> data) {
            this.data = data;
            init();
        // - constructors -
        // - interface -
        public void whenEmpty() { } // implement if needed
        public void setData(Vector<String> data) {
            this.data = data;
            for (int i = 0; i < data.size(); i++) {
                this.addItem(data.get(i));
        public Vector<String> getData() {
            return this.data;
        // - interface -
    }

  • Table Maintenance Object - Hide New Entries button

    Hello,
    Does anyone know how to hide the "New Entries" button in a table maintenance object?
    I want to allow editing of the table, but I don't want to allow new lines to be inserted.
    The generated screens do not have a gui status.  I guess the gui status is part of SM30 and not part of the maintnenance object itself.
    Thanks
    Doug

    hi
    check the below link, this might solve your issue
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2082425f-416b-2d10-25a3-85b8b6c5302c?quicklink=index&overridelayout=true
    thanks

  • Distribute new entries against existing reference data, Integrated Planning

    Dear Experts,
    Within IP, I struggle with how to distribute new entries against existing reference data.
    Example:
    Reference data:
    Product   /   Customer   /   amount
    P1               C1                  100
    P1               C2                  150
    P2               C2                  120
    P2               C3                  100
    New data:(data entered on product level, therefore not assigd to customer yet)
    P3          #                    150
    How can I distribute product P3 to Customers with reference to the data on product P1 ?
    Many thanks,
    Erik Pos
    Edited by: Erik Pos on Jan 5, 2010 3:52 PM
    Edited by: Erik Pos on Jan 5, 2010 3:54 PM

    Hi Hyma,
    This documentation indeed indicates that you can use other characteristic values in the parameter group to be used for reference, good news !, but this is based on SAP-BPS ?
    The SAP-BW IP documentationn does not include this information can you confirm this solution works for Integrated Planning using the conditions within the function distribute with reference data ?
    Many thanks,
    Erik Pos

  • Can JOptionPane produce an editable JComboBox?

    Can I use JOptionPane for an input dialog component with a data input area represented by an editable JComboBox ?
    For example :
    JOptionPane.showInputDialog( parent,
    � How Much?�,
    �This is the title�,
    JOptionPane.QUESTION_MESSAGE,
    null,
    new Object[]
    { � �, �un peu�,�beaucoup�,�passionnement�},
    �passionnement�);
    This one statement produces the input dialog I want, except that it does not allow an input such as �pas du tout� which is not in the list of selections.
    Does any one knows if somehow I could get to this JComboxBox and make it editable? (still using JOptionPane of course)?
    Thank you to any one who can answer me.

    Hi,
    You could use the JOptionPane.showMessageDialog() in the following way:
    JComboBox comboBox = //Make your own JComboBox here
    Object[] message = new Object[] {
    "Make your choice:",
    comboBox
    JOptionPane.showMessageDialog(parent, message);
    In this way you are able to add every Component to your message dialog you want to.
    Hope that helps, Mathias

Maybe you are looking for

  • SAP PI JDBC Stored Procedure Call

    Dear All, I have a requirement, where i have to call a stored procedure through reciever JDBC adapter by providing multiple records at a time as input to the stored procedure, and also recieve multiple records at a time. Can any one tell me, how the

  • Any Guide for Modifying Templates/Adding Custom CSS???

    I have purchased (and, yes, read...smarty pants) all of the APress, Oracle Application Express 4 books. I have searched The Google. We need just one, step-by-step, excruciatingly detailed example of modifying a template, for example to add in a custo

  • Please explain me constructor

    Hello all, could you please exaplain me the meaning of the following constructor: public class Details {     Hashtable mapping = new Hashtable();     Vector values = new Vector();     char optionChar;     public Details() {         this('/'); }Thakns

  • Discrete Manufacturing Purging data

    Anyone experience or have knowledge that can help us in the area of Discrete Manufacturing Purging data? Is someone done it already and can assist us? Where can we find more detailed technic information than in the user guides about the frame and sco

  • Quicktime export looks squashed.

    I imported several powerpoint slides converted to jpegs at 720X540. The pixel aspect ratio was square. The final destination for this presentation is youtube so i'm assuming that I want square pixel output in FCP. Everything looks fine in FCP but qui