Results 1 to 5 of 5
  1. #1
    santhosh_el is offline Member
    Join Date
    Feb 2009
    Posts
    50
    Rep Power
    0

    Default Problem in combobox

    dear sir,

    i have develped GUI,once enter the ipaddress in textfield and press the button the value in textfield is stored in combobox item,suppose, i am recompiled my code the added value is missing,this is my code,any body help me please

    private void pressActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:


    if (!iptext1.getText().equals("")){
    int a = 0;
    for(int i = 0; i <ipcombo.getItemCount(); i++){

    if(ipcombo.getItemAt(i).equals(iptext1.getText())) {
    a = 1;
    break;
    }
    }
    if (a == 1)
    System.out.println("combo box has this value");
    else
    ipcombo.addItem(iptext1.getText());


    }
    else{
    System.out.println("please enter ipaddress");
    }

    }

    private void ipcomboItemStateChanged(java.awt.event.ItemEvent evt) {
    // TODO add your handling code here:
    String iptext="";
    iptext=(String)ipcombo.getSelectedItem();
    if(iptext.equals("Add"))
    {

    }
    else
    {
    iptext1.setText(iptext);
    }
    }


    thank u
    santhosh

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    There is no anything to do with recompiling, depends on the way you've work out. Once you compile an application data is lost. If you want to keep previous data, have to record them in a file and reload it into your application.

  3. #3
    santhosh_el is offline Member
    Join Date
    Feb 2009
    Posts
    50
    Rep Power
    0

    Default problem in combobox

    thanks for reply

    my problem is once i am entering a value in textfield and then press button to store in combobox item,once recompiled the code the stored value in combobox item is deleted or missing. there is any problem in my code.please give me any idea to slove this problem.

    thanks

  4. #4
    trax is offline Member
    Join Date
    Mar 2009
    Posts
    42
    Rep Power
    0

    Default

    If u want that your data does not get deleted than u must save it in a file or database n retrieve that data at from the file or db n put it in combobox.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by santhosh_el View Post
    thanks for reply

    my problem is once i am entering a value in textfield and then press button to store in combobox item,once recompiled the code the stored value in combobox item is deleted or missing. there is any problem in my code.please give me any idea to slove this problem.

    thanks
    That's what I'm explain to you in my last post. Once you recompile the application/code all the data is lost. If you want to keep the data as it is you must store them, may be on a database, a text file or anything else. Recompile loos all your data on all components, not only on combobox, unless you are not refereeing from a data saved location.

Similar Threads

  1. ComboBox with CheckBoxes
    By heba.farouk in forum AWT / Swing
    Replies: 14
    Last Post: 06-09-2010, 11:03 AM
  2. Need Help combobox
    By kwink in forum AWT / Swing
    Replies: 3
    Last Post: 03-21-2009, 10:05 AM
  3. problem with combobox as a TableCellEditor
    By sandeepsai39 in forum New To Java
    Replies: 0
    Last Post: 03-20-2009, 11:39 AM
  4. combobox
    By chandu.v in forum New To Java
    Replies: 2
    Last Post: 07-02-2008, 08:36 PM
  5. ComboBox Fix Width
    By Azndaddy in forum New To Java
    Replies: 2
    Last Post: 05-29-2008, 04:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •