Forums Register Login
Adding a row in a table
hi all,,,i need a help ....I hav a table and it fills the values from the database.but the table is editable. I use a table model. and in my code i need to add a new row at the end of the table after one row is filled by the user so tht the user can enter another value in a new row . so please let me know about adding a row automatically when the user fills the last row in the table.I include the code with this, thanks in advance...

public SetCustomAttributesPanel() {
new FormLayout(
"5dlu, Right ref:grow, 3dlu, Right ref, 5dlu",
"5dlu, pref, 0dlu, pref, 3dlu, pref, 3dlu, pref, 5dlu"));
CellConstraints cc = new CellConstraints();
JPanel tablePanel = new JPanel(
new FormLayout(
"pref:grow, 3dlu, pref",

tblCustomAttributes = new JTable();

//tmCustomAttributes = new CustomAttributesTableModel(null);

//tblCustomAttributes = new JTable(tmCustomAttributes);
JScrollPane scrollPane = new JScrollPane(tblCustomAttributes);
scrollPane.setPreferredSize(new Dimension(200, 300));
add(scrollPane, cc.xyw(2, 2, 3));
tablePanel.add(scrollPane, cc.xy(1, 1));

JPanel buttonPanel = new JPanel(new FormLayout("pref", "pref, 5dlu, pref"));
ButtonGroup bgAddDeleteType = new ButtonGroup();
btnDelete = new JButton(new AbstractAction(I18n.getString("set.customattributepanel.delete")){
public void actionPerformed(ActionEvent e) {
int[] selectedRows = tblCustomAttributes.getSelectedRows();
for (int i = selectedRows.length-1; i >= 0; i--) {

buttonPanel.add(btnDelete, cc.xy(1, 3));
tablePanel.add(buttonPanel, cc.xy(3, 1, "center, center"));
add(tablePanel, cc.xyw(2, 8, 3, "fill, fill"));

public void fillInPanel(OVOObjectInterface ovoObject) {
Rule rule = (Rule) ovoObject;
CustomRuleAttributes customRuleAttributes = rule.getSetAttributes().getCustomRuleAttributes();
tblCustomAttributes.setModel(new CustomAttributesTableModel(customRuleAttributes));
[ August 25, 2006: Message edited by: vijayaraghavan ganesan ]

This thread has been viewed 783 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 19, 2018 00:26:38.