How to add an item  in the combobox list at runtime

i want to add an item to the list of items in the combobox. How can I do this? I tried to use the methods getselecteditem() and getitem() from the actionlistener but no success.
so after i add an item, the next time when i run that frame, that item should be displayed in the list of items in the combobox. Can anybody help me with this?

Thanks Encephalophathic.
Let me explain you the whole design -
I have a frame having textfields and comboboxes. Now in the combobox, i have added some fields during design time and some i want the user to add at runtime. After the user clicks the Save button, i want the new string if entered in the combobox by the user at runtime to be added in the list of items of the combobox. So the next time when that frame is run, the item added by the user at runtime previously should be there in the list of items displayed in the combobox.
What I am trying to do in this code at the combobox is if the user enters a new string in the combobox, then if he presses enter key, the value entered in the list of the combobox should be entered in the list of items of the combobox. Actually i m just trying to get the item typed in by the user, so just testing with enter key, but really i want it on the button click. I tried to add the code for adding an item to the combobox in the actionperformed, but i m not able to add it so confused what to do. Please help me with this.
Here's the whole code for that -
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JDialog.*;
import javax.swing.JComboBox;
public  class EnterFD implements ActionListener{
  private JFrame frame;
   private JPanel mainpanel,menupanel,userinputpanel,buttonpanel;
   private JMenuBar menubar;
   private JMenu menu,submenu;
   private JMenuItem menuitem;
   private JCheckBoxMenuItem cbmenuitem;
   private JLabel fdnumber;
   private JLabel bankname;
   private JLabel beneficiaryname;
   private JLabel entereddate;
   private JLabel maturitydate;
   private JLabel rateofinterest;
   private JLabel amount;
   private JLabel maturityamount;
   private JTextField fdnumbertxtfield;
   private JComboBox banknamecombobox;
   private JTextField beneficiarynametxtfield;
   private JComboBox entereddatecombobox;
   private JComboBox maturitydatecombobox;
   private JTextField rateofinteresttxtfield;
   private JTextField amounttxtfield;
   private JTextField maturityamounttxtfield;
   private JButton savebutton;
   private JButton clearbutton;
public EnterFD() {
        initComponents();}
    private final void initComponents(){
        fdnumber = new JLabel("FD Number:");
        bankname = new JLabel("Bank Name:");
        beneficiaryname = new JLabel("Beneficiary Name:");
        entereddate = new JLabel("Entered Date:");
        maturitydate = new JLabel("Maturity Date:");
        rateofinterest = new JLabel("Rate Of Interest:");
        amount = new JLabel("Amount:");
        maturityamount = new JLabel("Maturity Amount:");
        fdnumbertxtfield = new JTextField();
        banknamecombobox = new JComboBox();
        banknamecombobox.addItem("State Bank Of India");
        banknamecombobox.addItem("Bank Of Baroda");
        banknamecombobox.addItem("IDBI Bank");
        banknamecombobox.addItem("ICICI Bank");
        banknamecombobox.addItem("Punjab National Bank");
        banknamecombobox.setEditable(true);
        banknamecombobox.setSelectedIndex(-1);
        banknamecombobox.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyTyped(java.awt.event.KeyEvent evt) {
                banknamecomboboxKeyTyped(evt);
        banknamecombobox.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyReleased(java.awt.event.KeyEvent evt) {
                banknamecomboboxKeyReleased(evt);
        beneficiarynametxtfield = new JTextField();
        entereddatecombobox = new JComboBox();
        maturitydatecombobox = new JComboBox();
        rateofinteresttxtfield = new JTextField();
        amounttxtfield = new JTextField();
        maturityamounttxtfield = new JTextField();
        menubar = new JMenuBar();
         menu = new JMenu("File");
         menubar.add(menu);
         menuitem = new JMenuItem("New");
         menu.add(menuitem);
         menuitem.addActionListener(this);
         menuitem = new JMenuItem("Save");
         menu.add(menuitem);
         menuitem.addActionListener(this);
         menuitem = new JMenuItem("Close");
         menu.add(menuitem);
         menuitem.addActionListener(this);
         menuitem = new JMenuItem("Exit");
         menu.add(menuitem);
         menuitem.addActionListener(this);
         menu = new JMenu("Edit");
         menubar.add(menu);
         menuitem = new JMenuItem("View FD");
         menu.add(menuitem);
         menuitem.addActionListener(this);
        mainpanel = new JPanel(new BorderLayout());
        menupanel = new JPanel(new BorderLayout());
        menupanel.add(menubar);
         userinputpanel = new JPanel(new GridLayout(8,2,5,20));
        userinputpanel.setBorder(BorderFactory.createEmptyBorder(50,50,80,80));
        userinputpanel.add(fdnumber);
        userinputpanel.add(fdnumbertxtfield);
        fdnumbertxtfield.setColumns(50);
        userinputpanel.add(bankname);
        userinputpanel.add(banknamecombobox);
        userinputpanel.add(beneficiaryname);
        userinputpanel.add(beneficiarynametxtfield);
        beneficiarynametxtfield.setColumns(50);
        userinputpanel.add(rateofinterest);
        userinputpanel.add(rateofinteresttxtfield);
        rateofinteresttxtfield.setColumns(50);
        userinputpanel.add(amount);
        userinputpanel.add(amounttxtfield);
        amounttxtfield.setColumns(50);
        userinputpanel.add(maturityamount);
        userinputpanel.add(maturityamounttxtfield);
        maturityamounttxtfield.setColumns(50);
        savebutton = new JButton("Save");
        clearbutton = new JButton("Clear");
        JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        buttonpanel.add(savebutton);
        buttonpanel.add(clearbutton);
        savebutton.addActionListener(this);
        clearbutton.addActionListener(this);
        mainpanel.add(menupanel,BorderLayout.NORTH);
        mainpanel.add(userinputpanel,BorderLayout.CENTER);
        mainpanel.add(buttonpanel,BorderLayout.SOUTH);
        frame = new JFrame("Enter FD");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(3000,3000);
        frame.setContentPane(mainpanel);
        frame.pack();
        frame.setVisible(true); }

Similar Messages

  • How to add an item into the Newsstand

    How to add an item into the Newsstand.  Please do NOT reply using  "tech-language." Use standard- normal everyday English. Thanks,
    Don Otlin
    Franklin Square, NY

    Open Newsstand. Tap on the "Store" button in the upper right. Any newspaper or magazine you download from the store will appear in Newsstand.

  • How do you delete items from the reading list?

    How do you delete items from the reading list?

    I'm trying to mark your reply as "solved my problem", but I can't see where to mark it. I tried to mark it in the email that came to me with your answer, but it went to a screen that said NOT FOUND. Help?

  • How to show all items in the reading list? I think this option has been removed in Safari Version 7.0.2

    How to show all items in the reading list? I think this option has been removed in Safari Version 7.0.2

    Thanks. That solved it. I had my doubts since I wasn't concerned about my lost bookmarks. I was concerned about the broken functionality. In any event, restoring from a backup solved both the functionality and the lost bookmarks. I appreciate the response!

  • How to delete an item in the Source List?

    LimeWire arbitrarily entered an item in the source list of iTunes entitled "Buck's LimeWire Tunes". The item is a blue box with a musical note on it. How may I eliminate this box and the files associated with it?

    item is a blue box with a musical note on it. How may
    I eliminate this box and the files associated with it?
    Uninstall Limewire.

  • How do i delete items from the reading list

    how di i delete items from the reading list

    Swipe your finger across the item in the list and a delete button will pop up.

  • How do you remove items from the popular list

                   How can I remove unwanted items in the popular list?

    Click here
    and then click Edit in the lower left corner of the window that opens

  • How to add a Field to the Result List in Activity

    Hello Experts !
    We are on CRM 7.0. I want to add a field to the Result List of Activity (Component: BT126S_APPT / View: ApptSR). This field is the address of the "Employee Responsible".
    So, how can I add a field to the Result List? AET is not a relevant tool for us because we don't want to create an attribute it already exist in the BOL. We just have to enhance the result list with BOL existing attributes.
    Also, after I add the field, I will need to populate my field with Data via some method.
    Thanks in Advance to all !
    Mariano.-
    SAP.

    Hi Mariano,
    The component was missing some technical data. Implement sap notes 1226612, 1363752, and then follow the manual procedure shown below.
    u2022     Execute transaction SE11.
    u2022     Choose the Radio button "Data Type" and enter value
                  "CRMST_QUERY_R_ACT_BTIL" in the Data Type field.
    u2022     Click on "Change" button.
    u2022     Position the cursor before the Includes added to this structure. Click
                 On the "+" button to add a new attribute.
    u2022     Enter the following details in the newly added blank row.
         Component: PERSON_RESP_LIST
         Component Type: CRMT_PERSON_RESP_LIST.
    u2022     Save the changes and activate the structure.
    u2022     Add the "Employee Responsible" field to the View configuration.
    u2022     Open the BSP application BT126S_APPT.
    u2022     Double-click on the view BT126S_APPT/ApptSR in the left side panel.
    u2022     Choose tab "Configuration" in right side panel.
    u2022     Choose the right configuration by using the "Choose Configuration" button.
    u2022     Click on the Edit button.
    u2022     Add the "Employee Responsible" attribute from the "Available fields" list to "Displayed fields" list.
    u2022     Save the changes
    Regards
    Krishna

  • How to add a button on the ALV LIST pop up

    Hi ,
    Can any one help me to add a button on the ALV list which is a pop up using ABAP Objects.
    Thanks in advance.
    Regards,
    Kavya.

    HI ,
    I want to add a push button on the ALV list out put which is comming as a pop up and I want this using classes and methods.
    I have got a method IF_SREL_BROWSER_COMMANDS~ADD_BUTTONS from class cl_gos_attachment_list  but still I am unable to get any additional button on the output ALV popup.
    Please help.
    Regards,
    Kavya.

  • How do I remove items from the "favorites" list on the sidebar?

    When I open up a new folder there is a favorite list on the side.  Somehow, random documents and folders appear there.  When I went to the settings I couldn't find how to remove them and when I went to the preferences for finders I saw how to add different icons, but not how to remove these docs/folders from showing up there.  Any suggestions?

    I figured it out.  I read a few of the things on this site and they weren't totally helpful, but messed around and from their suggestions I figured it out!
    Hold Control
    Click on the item you wish to remove
    A list will appear with one of the options being "Remove from Sidebar"
    Click Remove from Sidebar

  • How do I remove items from the reading list in safari?

    I have old items on my reading list in Safari.   I can delete unused book marks but how do I remove reading list items?

    Swipe across their name in the reading list and you should get a Delete button appear

  • How can we remove items from the VF04 list?

    We have a long list of items in VF04 that, for various reasons (some process related, some due to errors), are not to be billed. We have looked at applying filters to the list but there is nothing really suitable to hide these individual documents e.g. we could filter out some dates where none of the items on that date are to be billed but other dates have a mix of items we want to bill and others we don't.
    I have done a search of this forum but didn't find a previous topic with a quick and simple method to remove items from the list .
    Is there a method, other than billing them or sorting each issue individually, to permanently remove individual documents from the VF04 list?
    Thanks in advance for any help.
    David

    Hi,
    David,
    Download a list of Pending delivers doc form VF04.
    Paste the list in T.Code : VL09 (Delivery reversal) and reverse the delivery.
    Then go to T.Code: VL06G Select the list of deliveries that has been reversed, select/delete all un- wanted deliveries.
    This way you can remove all unwanted pending deliveries forn Billing due list (VF04).
    Thanks & Regards,
    R.Janakiraman

  • How to add an item to the dock

    I accidentally removed "downloads" from the dock.  how do i get it back?  the help text says to use "command-shift-T, but that does not work.

    Select the Downloads folder and drag it to the right side of the Dock.

  • How to delete an item from the addItem list after it is entered in a field

    I have a form which contains a list of names. My problem is, I would like the form to remove a name after it is entered so that on the next row that name does not appear. For example, I have on the preopen event:
    Name.addItem("Andrew")
    Name.addItem("Bernie")
    Name.addItem("Chris")
    Name.addItem("Doug")
    and I select  'Bernie", I would like the next row to only have 3 names excluding the one I previously selected. And in the end, it should have no names if all four names have been selected, or should display a message.
    Is it possible to do this in LC. either in javascript or Formcalc.
    Thanks.

    I have checked the above example and it works perfectly for static fields. My problem is that the form I am using using employs the addinstance script to add new rows. How do you script for the new rows to not include names that have already been selected.
    In the example, I would like for new rows to exclude names that have previously been selected.
    Thanks.

  • How to add check box in the ALV list

    dear Experts,
                 i have a requirement.
    i want show the check boxes in my ALV list.
    can u please give the solution.
    thanks

    TYPE-POOLS: slis.
    *---internal tables
    DATA: BEGIN OF it_flight OCCURS 0,
    SEL, " add a single character field in the final output table
    carrid LIKE sflight-carrid,
    connid LIKE sflight-connid,
    fldate LIKE sflight-fldate,
    seatsmax LIKE sflight-seatsmax,
    seatsocc LIKE sflight-seatsocc,
    END OF it_flight,
    *--internal tables for alv
    it_fieldcat TYPE slis_t_fieldcat_alv,
    wa_fcat LIKE LINE OF it_fieldcat,
    layout TYPE slis_layout_alv,
    it_sort type slis_t_sortinfo_alv,
    wa_sort like line of it_sort.
    DATA: BEGIN OF it_flight_sel OCCURS 0,
    SEL,
    carrid LIKE sflight-carrid,
    connid LIKE sflight-connid,
    fldate LIKE sflight-fldate,
    seatsmax LIKE sflight-seatsmax,
    seatsocc LIKE sflight-seatsocc,
    END OF it_flight_sel.
    data: wa_flight like it_flight.
    In the layout set give the name of the field
    whose checkbox will be created ( SEL as it has 1 char only )
    layout-box_fieldname = 'SEL'.
    *---start-of-selection .
    START-OF-SELECTION.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = sy-repid
    i_internal_tabname = 'IT_FLIGHT'
    i_inclname = sy-repid
    CHANGING
    ct_fieldcat = it_fieldcat
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2.
    *----get data
    SELECT carrid
    connid
    fldate
    seatsmax
    seatsocc
    FROM sflight
    INTO CORRESPONDING FIELDS OF TABLE it_flight
    UP TO 20 ROWS.
    wa_fcat-do_sum = 'X'.
    MODIFY it_fieldcat FROM wa_fcat TRANSPORTING do_sum
    WHERE fieldname = 'SEATSOCC' .
    wa_sort-fieldname = 'CARRID'.
    wa_sort-group = 'UL'.
    wa_sort-up = 'X'.
    APPEND wa_sort TO it_sort.
    clear wa_sort.
    wa_sort-fieldname = 'CONNID'.
    wa_sort-subtot = 'X'.
    wa_sort-up = 'X'.
    APPEND wa_sort TO it_sort.
    clear wa_sort.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    is_layout = layout
    it_fieldcat = it_fieldcat
    it_sort = it_sort
    TABLES
    t_outtab = it_flight
    EXCEPTIONS
    program_error = 1.
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
    Check function code
    CASE r_ucomm.
    WHEN '&IC1'.
    Check field clicked on within ALVgrid report
    IF rs_selfield-fieldname = 'EBELN'.
    Read data table, using index of row user clicked on
    READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    Set parameter ID for transaction screen field
    SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    Sxecute transaction ME23N, and skip initial data entry screen
    CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    ENDIF.
    WHEN '&IC1'. "'&DATA_SAVE'. "user presses SAVE
    loop at it_flight into wa_flight.
    if wa_flight-Sel EQ 'X'.
    collecting records in table it_flight_sel to process further
    append wa_flight to it_flight_sel.
    clear wa_flight.
    TYPE-POOLS: slis.
    *---internal tables
    DATA: BEGIN OF it_flight OCCURS 0,
    SEL, " add a single character field in the final output table
    carrid LIKE sflight-carrid,
    connid LIKE sflight-connid,
    fldate LIKE sflight-fldate,
    seatsmax LIKE sflight-seatsmax,
    seatsocc LIKE sflight-seatsocc,
    END OF it_flight,
    *--internal tables for alv
    it_fieldcat TYPE slis_t_fieldcat_alv,
    wa_fcat LIKE LINE OF it_fieldcat,
    layout TYPE slis_layout_alv,
    it_sort type slis_t_sortinfo_alv,
    wa_sort like line of it_sort.
    DATA: BEGIN OF it_flight_sel OCCURS 0,
    SEL,
    carrid LIKE sflight-carrid,
    connid LIKE sflight-connid,
    fldate LIKE sflight-fldate,
    seatsmax LIKE sflight-seatsmax,
    seatsocc LIKE sflight-seatsocc,
    END OF it_flight_sel.
    data: wa_flight like it_flight.
    In the layout set give the name of the field
    whose checkbox will be created ( SEL as it has 1 char only )
    layout-box_fieldname = 'SEL'.
    *---start-of-selection .
    START-OF-SELECTION.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = sy-repid
    i_internal_tabname = 'IT_FLIGHT'
    i_inclname = sy-repid
    CHANGING
    ct_fieldcat = it_fieldcat
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2.
    *----get data
    SELECT carrid
    connid
    fldate
    seatsmax
    seatsocc
    FROM sflight
    INTO CORRESPONDING FIELDS OF TABLE it_flight
    UP TO 20 ROWS.
    wa_fcat-do_sum = 'X'.
    MODIFY it_fieldcat FROM wa_fcat TRANSPORTING do_sum
    WHERE fieldname = 'SEATSOCC' .
    wa_sort-fieldname = 'CARRID'.
    wa_sort-group = 'UL'.
    wa_sort-up = 'X'.
    APPEND wa_sort TO it_sort.
    clear wa_sort.
    wa_sort-fieldname = 'CONNID'.
    wa_sort-subtot = 'X'.
    wa_sort-up = 'X'.
    APPEND wa_sort TO it_sort.
    clear wa_sort.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    is_layout = layout
    it_fieldcat = it_fieldcat
    it_sort = it_sort
    TABLES
    t_outtab = it_flight
    EXCEPTIONS
    program_error = 1.
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
    Check function code
    CASE r_ucomm.
    WHEN '&IC1'.
    Check field clicked on within ALVgrid report
    IF rs_selfield-fieldname = 'EBELN'.
    Read data table, using index of row user clicked on
    READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    Set parameter ID for transaction screen field
    SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    Sxecute transaction ME23N, and skip initial data entry screen
    CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    ENDIF.
    WHEN '&IC1'. "'&DATA_SAVE'. "user presses SAVE
    loop at it_flight into wa_flight.
    if wa_flight-Sel EQ 'X'.
    collecting records in table it_flight_sel to process further
    append wa_flight to it_flight_sel.
    clear wa_flight.
    Please follow the code.

Maybe you are looking for

  • Download links in iWeb?

    I want to have a download link to a music file in iWeb- but when I say download link, I mean a link that will open a browser's "download" window and let the person download the file without having to right/control-click on the file and select Save Fi

  • Can't read a DVD anymore that I was using to create an image

    I was trying to create a copy of a DVD, but creating the image failed since I was accidentally was creating a dmg rather than a cdr. I was able to eject the DVD but now it can't be read anywhere, it shows as a blank DVD-R. This is my log, I would app

  • Update SNMP to v3 on WLCs. Update also required on WCS?

    Hi all, I need to update the SNMP version on our WLCs to v3, using MD5 and aes128.  This looks easy enough to do: Management > SNMP > SNMP v3 users > new From here i can add a new user (ie SNMPV3) and set MD5 and aes128 passwords. I will update our m

  • How can I know if a Exception is a runtime exception?

    Here have one example: public void writeList() throws IOException, ArrayIndexOutofBoundsException{ Here I know ArrayIndexOutOfBoundsException is a runtime exception, How can I know any other exceptions, for a unfamiliar exceptions?

  • Can't set up an IMAP account on a Cyrus server

    I have a Cyrus IMAP server running in my office. I had no problem setting up an account on my XP/Outlook 2007 computer. I cannot get Mail to set up this same account. I'm running Leopard. I can telnet to the Cyrus server from Terminal, so the network