0

I am coding a program that is a bit of a to do list, where the user creates tasks that he has to do, and adds them to a category, such as "Work" for example.

i can´t post an image of my program, but it is basically a jtabbedpane, where each tab has a "create new task" button, and a jlist.

Every tab represents a category, and i created an object named :"CategoryVisual", that consists of the "Nueva Tarea(New Task)" button, and a scrollpane with a JList. Behind this, there is the Object "Category", that is in itself an ArrayList of Tasks

NOW, what i want to do is know what tab (or category) is selected, and, when the user creates a task, that task is shown in the corresponding selected tab, i don´t know if i am being clear.

I tried this, this method is in the CreateNewTaskAction:

public void addTaskToList(){

    JTabbedPane tabbedPane = MainWindow.getTabbedPane();
    int selectedTab = tabbedPane.getSelectedIndex();

    CategoryVisual categoryVisual = NewCategoryAction.createdCategoryVisuals.get(selectedTab);

    category = NewCategoryAction.createdCategories.get(selectedTab);
    category.addTask(newTask);

    list = categoryVisual.getList();

    list.setListData(category.getTaskList().toArray());

createdCategories and createdCategoryVisuals are arraylist that are created when the user creates a new category.

The problem is that when i have for example three categories created, the tasks are added to the Arraylist of the Category object, but i am failing in adding those arraylists to the corresponding list or tab. The arraylists are shown in the lasT CategoryVisual that i created, and depending which tab i select, is the arraylist shown in the list.

Cœur
  • 37,241
  • 25
  • 195
  • 267
manuFloyd
  • 3
  • 1
  • for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, just about a.m. described issue – mKorbel Feb 19 '13 at 18:19
  • There's a related example [here](http://stackoverflow.com/a/11949899/230513). – trashgod Feb 19 '13 at 20:33

0 Answers0