[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What would be the best way to add a comment to a table entry

Posted on 2011-10-26
10
Medium Priority
?
256 Views
Last Modified: 2012-05-12
On my dialog form I have a jtable, the table is populated by user selections.  I need to give the user to add a comment about a selection on the table.  So i am thinking what if I create a array of strings and then I get the selected Row from the table - pop a comments dialog and save the typed string to the String Array at the index of the selected Row.  That way when I need to recall the information I can just run through the table list and the string array to get both information.  Does that sound OK?  Also I am wondering how I would show that a comment as been added.
0
Comment
Question by:jkteater
  • 5
  • 5
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 37032904
Do you happen to have a custom TableModel?
0
 

Author Comment

by:jkteater
ID: 37033102
abstractTableModel
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 37033196
In that case you could add the comment to a hidden column, then make that column visible later if you want
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jkteater
ID: 37033224
I am using a class to format my arraylist.  

public class RevDataset {
	
	TCComponentItemRevision rev;
	TCComponentDataset componentdataset;
	
		
   //////////////////////////////////////////////////////////////////////////
   //                                                                      //
   //                              Constructor                             //
   //                                                                      //
   //////////////////////////////////////////////////////////////////////////
   public RevDataset(TCComponentItemRevision tcRevision, TCComponentDataset selectedDataset) {
      rev = tcRevision;
      componentdataset = selectedDataset;
   }// end Constructor
	
   //////////////////////////////////////////////////////////////////////////
   //                                                                      //
   //                              getDataset()                            //
   //                                                                      //
   //////////////////////////////////////////////////////////////////////////
   public TCComponent getDataset() {
      return componentdataset;
   }// end getDataset()

   //////////////////////////////////////////////////////////////////////////
   //                                                                      //
   //                              getRev()                                //
   //                                                                      //
   //////////////////////////////////////////////////////////////////////////
   public TCComponent getRev() {
      return rev;
   }//end getRev()
   
   
   //////////////////////////////////////////////////////////////////////////
   //                                                                      //
   //                              equals()                                //
   //                                                                      //
   //////////////////////////////////////////////////////////////////////////
   public boolean equals(Object o){
	     RevDataset p = (RevDataset) o;
	     if(rev.equals(p.getRev()) && componentdataset.equals(p.getDataset())) {
	        return true;
	     }
	     else { 
	        return false;
	     }	 
	}// end equals()
}

Open in new window


Then I am using a add method in a seperate class to build my List

 
 //////////////////////////////////////////////////////////////////////////
   //                                                                      //
   //                            add()                                     //
   //                                                                      //
   //////////////////////////////////////////////////////////////////////////
   public void add(TCComponentItemRevision tcRevision, TCComponentDataset selectedDataset){
     	   RevDataset pp = new RevDataset(tcRevision,selectedDataset);
	   if(!rds.contains(pp))rds.add(pp); 
	   fireTableDataChanged();
	  
   }// end add

Open in new window



If there a way to add a String value  to the RevDataset class so when the string is being built with the add method it would also be adding a null string to each one entry

the list would look something like
tcRevision, selectedDataset, comment

instead of

tcRevision, selectedDataset

That way the comment would be also available in the table
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37033538
It wouldn't necessarily be a good thing to add it to the RevDataset class. Why don't you just add it when you build the TableModel?
0
 

Author Comment

by:jkteater
ID: 37033643
Can you show me a example of to do that?
0
 

Author Comment

by:jkteater
ID: 37033654
but also the user will be adding a comment to a specfic entry on the table.  If we add it to the table will we still be able to pull the information out?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37033961
The table IS the TableModel effectively. The only sense in which they differ is if/when you decide to hide columns from view. A JTable is just a view of a TableModel
0
 

Author Comment

by:jkteater
ID: 37044874
You did answer the question and for that I thank you.  After learning more about what I was wanting, I understand that the question was not correctly asked.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37044993
:)

OK
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

831 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