Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding a row in a table  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • 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() {
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 ]
What are you doing? You are supposed to be reading this tiny ad!
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!