Results 1 to 3 of 3
  1. #1
    mainy is offline Member
    Join Date
    Feb 2009
    Posts
    38
    Rep Power
    0

    Default Now stuck with inserting data into a list.

    Hi again!

    I'm hoping one day that I won't actually need to keep asking for help on this forum but unfortunatly, I am stuck once again ><

    I have two classes, which include two Jpanels. One of the Jpanels has a list in it, the other has a button. What I want to do, is when the person presses the button in one window, it adds some information to a list in the second window.

    Rather than posting all the code I am just going to post all the relevent information. Here is the actionListener that detects the button has been pressed:
    Java Code:
     
    private void buttonActionPerformed(java.awt.event.ActionEvent evt) {                                         
            if (button.getActionCommand().equals("Yes")){
                chosenList cl = new chosenList();
    
                cl.addList("Yes");
     
                }
        }
    This sends the string "Yes" to this method in the other class which contains the List.:
    Java Code:
    public void addList(String name) {
            list.add(name);
            System.out.println(name);
        }
    I know that addList is recieving "Yes" as using the sout command it prints it out in the runtime window everytime I press the button. The problem is, for some reason it is not adding the String to the list. I have even tried going direct by putting inside the actionListener cl.list("Yes"); but with no luck.

  2. #2
    mainy is offline Member
    Join Date
    Feb 2009
    Posts
    38
    Rep Power
    0

    Default

    If it helps, I think it has something to do with the list not being currently in Focus. I have tried such code as list.requestFocusInWindow(); without much luck either.

  3. #3
    webbusiness23 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default

    I think you should try to put this line
    chosenList cl = new chosenList();
    before the if statement. The cl object's scope is inside the if statement. Outside the if statement you have no cl object.

    Give it a try!

Similar Threads

  1. Replies: 0
    Last Post: 03-31-2009, 04:52 PM
  2. Inserting data to database from the form
    By Ms.Ranjan in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-17-2008, 01:06 AM
  3. Doubly-linked list with data structure
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 10:30 PM
  4. Inserting data containing quotes into DB
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-06-2008, 09:28 AM
  5. Replies: 0
    Last Post: 12-24-2007, 09:47 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
  •