Solved

adding to list from checkboxs

Posted on 2004-04-15
3
236 Views
Last Modified: 2010-03-31
In this section of the code [ addToList(bList, ???); ] an audiofile is added, this file will come from a checkbox being checked. How would this code add the audiofile to the blist in the following piece of code (addToList(bList, ???);) if I named the checkboxs 2sec-12sec.   I got this code from objects.

addToList(bList, ???);


public class MyListener implements ActionListener {

    private List aList = new ArrayList();
    private List bList = new ArrayList();

    public MyListener() {
    }

    public void addButton(JButton theButtonToAdd) {
       theButtonToAdd.addActionListener(this);  // Listen for the button to be pressed
    }

    public void actionPerformed(ActionEvent e) {
       JButton button = (JButton)e.getSource();
       String command = button.getActionCommand();
       addToList(aList, command);
       addToList(bList, ???);
    }

    private static List list, String file) {
       if (list.contains(file))
       {
          list.remove(file);
       }
       else
       {
          list.add(file);
       }
    }

    public List getAList() { return aList; }
    public List getBList() { return bList; }

}
0
Comment
Question by:Drop_of_Rain
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10839021
it already is adding the file to the blist, I just wasn't sure where the filename was coming from.
0
 

Author Comment

by:Drop_of_Rain
ID: 10839060
No, I know it was adding it I'm just looking to ad it from a checkbox know that I have figured out what I need to do next in the custom section of the program.
0
 
LVL 92

Accepted Solution

by:
objects earned 350 total points
ID: 10839070
the following will allow you to use the class with both JButton's and JCheckBox's.

public class MyListener implements ActionListener {

    private List aList = new ArrayList();
    private List bList = new ArrayList();

    public MyListener() {
    }

    public void addButton(AbstractButton theButtonToAdd) {
       theButtonToAdd.addActionListener(this);  // Listen for the button to be pressed
    }

    public void actionPerformed(ActionEvent e) {
       AbstractButton button = (AbstractButton)e.getSource();
       String command = button.getActionCommand();
       addToList(aList, command);
       addToList(bList, ???);
    }
...
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 49
Groovy problem when using SOAPUI : DispatchException occurred 7 46
spring jars download 1 28
Tomcat: Unable to run tomcat service. 2 20
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question