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

  • Home
  • SEARCH
  • 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 9163783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:31:37+00:00 2026-06-17T14:31:37+00:00

Is it possible to update the JTable Entire row at once , rather than

  • 0

Is it possible to update the JTable Entire row at once , rather than column wise ??
This is my program below
Currently i could able to modify column wise only
using

model.setValueAt("1111", 0, 0)

Could i use

model.setValueAt(new Object[]{"1111","Pavan","Developer"}, 0, 0);


import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;
public class Preethi {
    protected void initUI() {
        final DefaultTableModel model = new DefaultTableModel(new String[] {
                "Id", "Name", "Desg" }, 0);
        final JTable table = new JTable(model);
        // table.setFillsViewportHeight(true);
        JFrame frame = new JFrame(Preethi.class.getSimpleName());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JScrollPane scrollpane = new JScrollPane(table);
        frame.add(scrollpane, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
        Vector vec = new Vector();
        vec.add("1122");
        vec.add("Iraneee");
        vec.add("Dev");
        model.insertRow(0, vec);
        model.setValueAt("1111", 0, 0);
        //model.setValueAt(new Object[]{"1111","Pavan","Developer"}, 0, 0);

    }

    public static void main(String[] args) throws ClassNotFoundException,
            InstantiationException, IllegalAccessException,
            UnsupportedLookAndFeelException {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Preethi().initUI();
            }
        });
    }

}
  • 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-17T14:31:38+00:00Added an answer on June 17, 2026 at 2:31 pm

    As the docs indicate, setValueAt sets a single cell value.

    Sets the object value for the cell at column and row. aValue is the new value.

    However, you could overload the method to handle an Object array:

    class MyTableModel extends DefaultTableModel {
    
       public MyTableModel(Object[] columnNames, int rowCount) {
          super(columnNames, rowCount);
       }
    
       public void setValueAt(Object[] valueArray, int row) {
          int column = 0;
          for (Object cellValue: valueArray) {
             setValueAt(cellValue, row, column);
             column++;
          }
       }
    }
    

    Using this model you would then be able to set the values for a given row:

    model.setValueAt(new Object[] { "1111", "Pavan", "Developer" }, 0);
    

    Slightly Shorter Version:

    class MyTableModel extends DefaultTableModel {
    
       public MyTableModel(Object[] columnNames, int rowCount) {
          super(columnNames, rowCount);
       }
    
       public void setValueAt(Object[] valueArray, int row) {
    
          getDataVector().setElementAt(new Vector(Arrays.asList(valueArray)), row);     
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to update more than 1 column of a data.table in the
Is it possible to update first row and with WHERE clause. I Tried: UPDATE
Is is possible to update the text 'changethis' in below div using jquery ?
If I try to implement this simple-as-possible example: Update Content with AJAXRefreshRequest it does
Is it possible to update from an action/method other than the update action/method? For
Is it possible to update from an action/method other than the update action/method? For
Possible Duplicate: Set Jtable/Column Renderer for booleans Right now I have in my Jtable:
Is it possible to update a column of a table from two optional tables,
Possible Duplicate: Update row with data from another row in the same table I
Is it possible to update some column before every flush to database? I have

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.