Link to home
Start Free TrialLog in
Avatar of jkteater
jkteaterFlag for United States of America

asked on

Changing a value in my Arraylist

now I have a dialog box getting the users comment.  I need to figure out how change the value in my arraylist.

I am thinking it would be something like

 public void commentSelectedRow(int row, String comment) {
         boolean b = (rds.set) != null);
        
        
   }
I know that set is looking for what value you want to change and the new value

rds.set(value, comment);

row is the index in the arraylist I want to add the value to

I need to know how to change the value in the last spot - example

row would be equal to tcRevision, tcSelected, tcComment

how do I only change tcComment??

rds.set(row.getTcComment(), comment);  ??

SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jkteater

ASKER

Basically what I have and this could be exactly what you are talking about above.

In my table, which is a display of what the user selects and adds to the ArrayList.  Well now at the end of the table there is column named comments and by default it is a null field.  I have added a button to the dialog that will take the selected row in the table and pop up a dialog

public void commentTableRow() {
	   int row = selectTable.getSelectedRow();
   	   comment = JOptionPane.showInputDialog(null, "Please Enter Your Comment");
	   myModel.commentSelectedRow(row, comment);
   } 

Open in new window


I am basically wanting to get the value of the comment the user typed in and the row (index of the arraylist )
I want to update the null comment with the value to the user typed in.  So in the commentSelectedRow(row, comment); method I am trying to pass in the row (index) and the comment.  Then in the Arraylist change the vlaue from NULL to what the user typed in then update the table to show the comment.
You need to update the value at its *source* (which is in the RevDataset instance)
The popup dialog is in class 3 do I need to make a instance of class 3 in the RevDataset class, so I can get the comment value?  I am trying to figure out how to update the value
Can you please step me though how you think the value should be getting updated.  I am have tried many things and I am only getting more confused as I go.  Heck I am not even sure I can change the value any more.

This is what I tried last

I have a method in RevDataset called

   public String getRevComment() {
       return rComment;
   }// end RevComment()

Open in new window


I call that function when creating the table atValue

 case COMMENT_COL: { o = rds.get(row).getRevComment(); break; }

so I thought if I get the comment value and somehow assign it where rComment is equal to the user comment then call a firetable, it would show the updated value.  But that does not work, for one reason it wants to add the value to all the selections and not just the one.

I will increase the points, I really need help with this one.
btw, i think you might like to consider taking a step back to go forward better. Instead of just adding a String comment member to RevDataset, it would be stronger and more reusable to add a Map instead. That way, you could add any number of extra bits of data to RevDataset at any time and have them reflected in your table. What do you think?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please, remind, what are the objects which make up elements in your ArrayList ?
Perhaps, post the class to which the elements of your ArrayList belong.
I did get this working over the weekend.  I basically was able to find the field by using the selected row index and assigning the user comment to the null value.  

I will split the points and I do appreciate your time and effort in helping me.
>>I will split the points and I do appreciate your time and effort in helping me.

I don't understand why that's the 'accepted solution' but thanks anyway