Solved

adding to list from checkboxs

Posted on 2004-04-15
3
214 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countHi2 challenge 7 44
wordcount challenge 11 76
Python Assistance 7 35
Non-recursive backtracking, using a stack 1 49
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

757 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now