• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding a row in a table

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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() {
super(
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",
"pref:grow"));

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));
bgAddDeleteType.add(btnDelete);
tablePanel.add(buttonPanel, cc.xy(3, 1, "center, center"));
add(tablePanel, cc.xyw(2, 8, 3, "fill, fill"));
}

@Override
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic