Results 1 to 4 of 4
- 01-03-2011, 04:19 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 20
- Rep Power
- 0
Problem in adding arrayList elements
Hi,
I have some check boxes to add selected days of a month to an arrayList,
when i select the element it gets added, but when next time i add other elements, it shows arrayList empty and add only the selected element.
// this is my class to implement actionListener
public void actionPerformed(ActionEvent e)
{
JCheckBox obj = (JCheckBox) e.getSource();
String name= e.getActionCommand(); // gives name of the checkbox
if(obj.isSelected()== true)
{
mycon.addMonthItem(name);
}
}
// This function is my class
public void addMonthItem(String item)
{
System.out.println("list is "+monthList);
monthList.add(item); // monthList is my arrayList
System.out.println("added item, "+item+" new list is "+monthList);
}
when i select checkbox having value 1,2,3
// initially list is empty
i get output as
***********
list is []
added item 1, new list is [1]
list is []
added item 2, new list is [2]
list is []
added item 3, new list is [3]
can somebody help????
- 01-03-2011, 10:48 AM #2
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
Does any other part of the code use the list, except for using the method get(int)?
Ex animo! Hibernate
Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.
- 01-03-2011, 11:32 AM #3
- 01-03-2011, 12:27 PM #4
Member
- Join Date
- Nov 2010
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
Adding the Elements of a 2D Array
By RMcLuckie45 in forum New To JavaReplies: 0Last Post: 11-07-2010, 11:04 PM -
Cannot swap elements in ArrayList
By glchau in forum New To JavaReplies: 4Last Post: 05-30-2010, 08:03 AM -
Accessing elements of an ArrayList which contains 2D arrays
By Willi in forum New To JavaReplies: 5Last Post: 01-18-2010, 07:00 AM -
Help printing specific ArrayList elements
By CirKuT in forum New To JavaReplies: 5Last Post: 02-03-2009, 12:24 AM -
Adding elements to an Object Array
By aneesahamedaa in forum New To JavaReplies: 4Last Post: 09-07-2008, 03:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks