Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:38:43+00:00 2026-06-07T07:38:43+00:00

I am using a hashmap to populate a jtable. The user selects a row(s)

  • 0

I am using a hashmap to populate a jtable. The user selects a row(s) and clicks a edit button. I am taking the value from the hashmap and placing it in a textarea. The user can make changes and then clicks another button. I have the new value and the key, but I am not sure how to write the changed value back to the right key in the hashmap.

THis is where I am writing the data out to the textarea

private void outputSelection() {
  StringBuffer csb = new StringBuffer();
  String s = "";
  int[] row = selectTable.getSelectedRows();

  for(int i = row.length-1; i >= 0; i--){
     String check = (String) EdiMapTableModel.getMapInstance().getValueAt(i, EdiMapTableModel.getMapInstance().COMMENT_COL); 
     if (!isNullOrEmpty(check)) {
        if (csb.length() > 0) {
            csb.append("\n");
        }
        csb.append(check);
     }
  }

  s = csb.toString();
  csb.setLength(0);
  output.append(s);

}

This is where I am trying to put the value back

private void inputSelection() {
  String s = output.getText();
  int[] row = selectTable.getSelectedRows();
  for(int i = row.length-1; i >= 0; i--){
     TCComponentItemRevision check = (TCComponentItemRevision) EdiMapTableModel.getMapInstance().getValueAt(i, EdiMapTableModel.getMapInstance().ITEMID_COL); 
     EdiMapTableModel.getMapInstance().commentBackMap(check, s);
     repaint();
  }    

}

This is where I am trying to put it back in the map

public void commentBackMap(int row, TCComponentItemRevision id, String comment) {

   if(model.containsKey(id)) {
          model.put(id, comment);
   }           
   fireTableDataChanged();
}// end commentBackMap()

I know containsKey is not right above. id is the key value

Do I need to iterate through the hashmap looking for a match? Don’t know if it matters but it is a linkedhashmap instead of a hashmap

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:38:45+00:00Added an answer on June 7, 2026 at 7:38 am

    If you want to maintain the location of your map entry, you can’t put it again since that’s going to move it to the end of the LinkedHashMap. You’ll need a holder object, say an Object[1], where you’ll replace its member without putting the map entry again.

    Or maybe reevaluate your choice of LinkedHashMap.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the key of a HashMap using the value. hashmap =
I want to read data from a HashMap using EL in a JSP page,
while using hashmap for finding the most common value the code is doing well
Can you create an XML object resource with key-value pairs (basically a hashmap) using
I am using a hashmap to store objects with a key that evolves over
In java while using the HashMap, they are using the Iterator class. But I
I have built a custom hashmap using two arrays. One contains keys another values.
I'm building a thesaurus using a HashMap to store the synonyms. I'm trying to
I'm building a thesaurus using a HashMap <String,ArrayList<String>> to hold words and their synonyms
I am currently using scala 2.9.1. I create a mutable.HashMap using : > val

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.