Solved

adding to list from checkboxs

Posted on 2004-04-15
3
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jdbc error in jsp application 20 71
Java basic valueOf question 1 33
collection output issue 9 59
Eclipse for Java EE development 2 43
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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

761 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