列ごとではなく、JTable の行全体を一度に更新することは可能ですか?? これは以下の私のプログラムです。現在、列ごとにのみを使用して変更できます
model.setValueAt("1111", 0, 0)
使えますか
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();
}
});
}
}