Posted on 2000-04-13
Last Modified: 2008-03-03
I am using vector for populating the JTable. How will i give the option to the user to modify the a particular row and save it back to the vector.

Question by:SaketM
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3

Accepted Solution

ovidiucraciun earned 100 total points
ID: 2712476
Set your table model as DefaultTableModel and take advantage of the
"protected Vector dataVector"
data member. A reference to this member you can obtain with member function public Vector getDataVector().


Author Comment

ID: 2712507
I need more descriptive answer. I am new to JTable so please send some code if possible

Author Comment

ID: 2712514
Which event of JTable i have to implement to get the row clicked and retreive the data.
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.


Expert Comment

ID: 2712617
public boolean isCellEditable(int row,
                              int column)from DefaultTableModel
tells if the cell from row and column is editable. You have to do overwrite
this function in your TableModel and
to tell explicitly what cell is editable and what cell is not.

concerning the other issue:
public void setValueAt(Object aValue,
                       int row,
                       int column)
from the DefaultTableModel is called avery time the user enter a new value for a cell. If you overwrite this function also you'll be able to know every time when the user tries to change
a cell value


Author Comment

ID: 2714593
But how will i get the row which the user clicked. For that i need to some which listener.

Expert Comment

ID: 2715354
      new java.awt.event.MouseAdapter( )
            public void mouseClicked( java.awt.event.MouseEvent evt )
                  jTableMouseClicked( evt );
private void jTableMouseClicked( java.awt.event.MouseEvent me )
      // find the cell
      int       row = jTable.getSelectedRow( );
      int       col = jTable.getSelectedColumn( );
      if ( me.getModifiers( ) == me.BUTTON1_MASK )
            // add code for first mouse button
      if ( me.getModifiers( ) == me.BUTTON3_MASK )
            // add code for second mouse button

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
runtime exception 2 67
JAVA API design with micro service cloud in mind 1 111
glassfish admin console 1 51
Netbeans and org.apache.commons.lang3 issue 3 53
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.
Suggested Courses

738 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