Problem in adding/deleting rows in JTable

I am trying to add /remove rows from JTable whose first column is JButton and others are JComboBox's.If no rows are selected,new row is added at the end.If user selects some row & then presses insert button,new row is added below it.Rows can only be deleted if user has made some selection.Kindly help me,where i am making mistake.If any function is to be used.My code is as follows....
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.border.*;
public class JButtonTableExample extends JFrame implements ActionListener{
JComboBox mComboLHSType = new JComboBox();
JComboBox mComboRHSType = new JComboBox();
JLabel mLabelLHSType = new JLabel("LHS Type");
JLabel mLabelRHSType = new JLabel("RHS Type");
JButton mButtonDelete = new JButton("Delete");
JButton mButtonInsert = new JButton("Insert");
JPanel mPanelButton = new JPanel();
JPanel mPanelScroll = new JPanel();
JPanel mPanelCombo = new JPanel();
DefaultTableModel dm ;
JTable table;
int currentRow = -1;
static int mSelectedRow = -1;
public JButtonTableExample()
super( "JButtonTable Example" );
makeForm();
setSize( 410, 222 );
setVisible(true);
private void makeForm()
this.getContentPane().setLayout(null);
mPanelCombo.setLayout(null);
mPanelCombo.setBorder(new LineBorder(Color.red));
mPanelCombo.setBounds(new Rectangle(1,1,400,30));
mLabelLHSType.setBounds(new Rectangle(26,5,71,22));
mComboLHSType.setBounds(new Rectangle(83,5,100,22));
mLabelRHSType.setBounds(new Rectangle(232,5,71,22));
mComboRHSType.setBounds(new Rectangle(292,5,100,22));
mPanelCombo.add(mLabelLHSType,null);
mPanelCombo.add(mComboLHSType,null);
mPanelCombo.add(mLabelRHSType,null);
mPanelCombo.add(mComboRHSType,null);
mPanelScroll.setLayout(null);
mPanelScroll.setBorder(new LineBorder(Color.blue));
mPanelScroll.setBounds(new Rectangle(1,28,400,135));
mPanelButton.setLayout(null);
mPanelButton.setBorder(new LineBorder(Color.green));
mPanelButton.setBounds(new Rectangle(1,165,400,30));
mButtonInsert.setBounds(new Rectangle(120,5,71,22));
mButtonDelete.setBounds(new Rectangle(202,5,71,22));
mButtonDelete.addActionListener(this);
mButtonInsert.addActionListener(this);
mPanelButton.add(mButtonDelete,null);
mPanelButton.add(mButtonInsert,null);
dm = new DefaultTableModel();
//dm.setDataVector(null,
//new Object[]{"Button","Join","LHS","Operator","RHS"});
dm.setDataVector(new Object[][]{{"","","","",""}},
new Object[]{"","Join","LHS","Operator","RHS"});
table = new JTable(dm);
table.getTableHeader().setReorderingAllowed(false);
table.setRowHeight(25);
int columnWidth[] = {20,45,95,95,95};
TableColumnModel modelCol = table.getColumnModel();
for (int i=0;i<5;i++)
modelCol.getColumn(i).setPreferredWidth(columnWidth);
//modelCol.getColumn(0).setCellRenderer(new ButtonRenderer());
//modelCol.getColumn(0).setCellEditor(new ButtonEditor(new JCheckBox()));
modelCol.getColumn(0).setCellRenderer(new ButtonCR());
modelCol.getColumn(0).setCellEditor(new ButtonCE(new JCheckBox()));
modelCol.getColumn(0).setResizable(false);
setUpJoinColumn(modelCol.getColumn(1));
setUpLHSColumn(modelCol.getColumn(2));
setUpOperColumn(modelCol.getColumn(3));
setUpRHSColumn(modelCol.getColumn(4));
JScrollPane scroll = new JScrollPane(table);
scroll.setBounds(new Rectangle(1,1,400,133));
mPanelScroll.add(scroll,null);
this.getContentPane().add(mPanelCombo,null);
this.getContentPane().add(mPanelScroll,null);
this.getContentPane().add(mPanelButton,null);
}//end of makeForm()
public void actionPerformed(ActionEvent ae)
if (ae.getSource() == mButtonInsert)
//int currentRow = table.getSelectedRow();
currentRow = ButtonCE.selectedRow;
System.out.println("Before Insert CURRENT ROW"+currentRow);
if(currentRow == -1)
int rowCount = dm.getRowCount();
//mSelectedRow = rowCount-1;
//table.clearSelection();
dm.insertRow(rowCount,new Object[]{"","","","",""});
currentRow = -1;
ButtonCE.selectedRow = -1;
else
table.clearSelection();
dm.insertRow(currentRow+1,new Object[]{"","","","",""});
currentRow = -1;
ButtonCE.selectedRow = -1;
//System.out.println("After INSERT CURRENT ROW"+currentRow);
if(ae.getSource() == mButtonDelete)
//int currentRow = table.getSelectedRow();
currentRow = ButtonCE.selectedRow;
System.out.println("Before DELETE CURRENT ROW"+currentRow);
if(currentRow != -1)
dm.removeRow(currentRow);
table.clearSelection();
currentRow = -1;
ButtonCE.selectedRow = -1;
//System.out.println("Selected Row"+mSelectedRow);
else
JOptionPane.showMessageDialog(null, "Select row first", "alert", JOptionPane.ERROR_MESSAGE);
//System.out.println("DELETE CURRENT ROW"+currentRow);
public void setUpJoinColumn(TableColumn joinColumn)
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("AND");
comboBox.addItem("OR");
comboBox.addItem("NOT");
joinColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
joinColumn.setCellRenderer(renderer);
//Set up tool tip for the sport column header.
TableCellRenderer headerRenderer = joinColumn.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the sport to see a list of choices");
public void setUpLHSColumn(TableColumn LHSColumn)
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Participant1");
comboBox.addItem("Participant2");
comboBox.addItem("Variable1");
LHSColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
LHSColumn.setCellRenderer(renderer);
//Set up tool tip for the sport column header.
TableCellRenderer headerRenderer = LHSColumn.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the sport to see a list of choices");
public void setUpOperColumn(TableColumn operColumn)
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("=");
comboBox.addItem("!=");
comboBox.addItem("Contains");
operColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
operColumn.setCellRenderer(renderer);
//Set up tool tip for the sport column header.
TableCellRenderer headerRenderer = operColumn.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the sport to see a list of choices");
public void setUpRHSColumn(TableColumn rhsColumn)
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Variable1");
comboBox.addItem("Constant1");
comboBox.addItem("Constant2");
rhsColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
rhsColumn.setCellRenderer(renderer);
//Set up tool tip for the sport column header.
TableCellRenderer headerRenderer = rhsColumn.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the sport to see a list of choices");
public static void main(String[] args) {
JButtonTableExample frame = new JButtonTableExample();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
//Button as a renderer for the table cells
class ButtonCR implements TableCellRenderer
JButton btnSelect;
public ButtonCR()
btnSelect = new JButton();
btnSelect.setMargin(new Insets(0,0,0,0));
public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column)
if (column != 0) return null; //meany !!!
//System.out.println("Inside renderer########################Selected row");
//btnSelect.setText(value.toString());
//btnSelect.setIcon(new ImageIcon("capsigma.gif"));
return btnSelect;
}//end fo ButtonCR
//Default Editor for table
class ButtonCE extends DefaultCellEditor implements ActionListener
JButton btnSelect;
JTable table;
//Object val;
static int selectedRow = -1;
public ButtonCE(JCheckBox whoCares)
super(whoCares);
//this.row = row;
btnSelect = new JButton();
btnSelect.setMargin(new Insets(0,0,0,0));
btnSelect.addActionListener(this);
setClickCountToStart(1);
public Component getTableCellEditorComponent(JTable table,Object value,boolean isSelected,int row,int column)
if (column != 0) return null; //meany !!!
this.selectedRow = row;
this.table = table;
table.clearSelection();
System.out.println("Inside getTableCellEditorComponent");
return btnSelect;
//public Object getCellEditorValue()
//return val;
public void actionPerformed(ActionEvent e)
// Your Code Here...
System.out.println("Inside actionPerformed");
System.out.println("Action performed Row selected "+selectedRow);
btnSelect.setIcon(new ImageIcon("capsigma.gif"));
}//end of ButtonCE

Hi,
All the thing you have to do is to return a boolean for the column. JTable will use a checkbox (as default) to show boolean values.

Similar Messages

  • Disable users from adding-deleting row/columns

    we are running sharepoint 2010 and I would like to setup some type of persmission that will disable certain users from adding-deleting  rows/columns.
    any suggestions will be appreciated
    thank you

    Each list in sharepoint can be assigned certain roles.YOu can break the inheritance for that list and assign a group as a new role to the list.The users belonging to that group will only have access to that list depending to what permissions you give that
    group.The code goes something like this:
    SPWeb web = (SPWeb)properties.Feature.Parent;
    string ListName = "C";
    SPList list = web.Lists[ListName];           
                list.BreakRoleInheritance(true);           
    string GroupName = "Owners";
    SPGroup group = web.SiteGroups[GroupName];
    SPGroupCollection removeGroups = web.SiteGroups;
    foreach (SPGroup removeGroup
    in removeGroups)
    if(removeGroup.Name != GroupName)
    SPPrincipal principal = (SPPrincipal)removeGroup;               
                        list.RoleAssignments.Remove(principal);
    SPRoleDefinition rDefination = web.RoleDefinitions.GetByType(SPRoleType.Administrator);
    SPRoleAssignment rAssignment =
    new SPRoleAssignment(group);
                rAssignment.RoleDefinitionBindings.Add(rDefination);
                list.RoleAssignments.Add(rAssignment);
                list.Update();

  • Delete row in JTable

    Hello I am new To JAVA SWING
    I have 2 questions related to JTable
    1) How do i remove selected row in JTable ...for instance, I click on the row to delete (It is selected) , later I press the delete button, and then row is removed .... any hints ?
    2) If I would like to save the rows in a JTable into a database , .... How can iterate through the rows in the JTable..each row .... the rows are saved in a List object...and a List Object is what I pass as a parameter in a class method in order to be saved into Database.
    Thanks,
    deibys

    1) use the removeRow(...) method of the DefaultTableModel
    20 use table.getModel().getValueAt(...) to get the data from the model and create your list Object.

  • Adding/Deleting rows in a Table

    I am trying to get a couple of buttons to work in a table to add/delete rows. I have followed the directions in the LiveCycle designer help and it isn't working.
    In a test setup the only difference I can see from the help file is my Table is called Table1 and the subform containing the 2 buttons is called Subform1
    I have therefore amended the script for the click event for the AddRow to
    "Table1.Row1.instanceManager.addInstance(1);"
    Any ideas where I am going wrong?
    TIA
    Antony

    Hi,
    My usecase is that user enters a url with parameters for example in the text box--> http://host:port/employee/all?department=abc&location=india. Now i want to parse this url , get the parameters out and put it in the table so that it is convenient for users to modify these parameters. User has a option to add and delete the parameter in the table. So once all this is done and user clicks on say save i don't need to send this table to server. i just have to make sure that the values added/deleted from the table are in sync with the url. So in the server i get all the parameters from the url and continue.
    Since this is only needed on the client side i wanted to know if we can create a table with no values and then say on tabbing out of the url text box call a javascript that takes value from it and adds new rows to the table.
    I am using JDEVADF_MAIN_GENERIC_140109.0434.S

  • Adding/deleting rows from a treeTable with a read-only view object

    Hello --
    I'm getting a JBO-25016 error when I go to delete a row from a treeTable. I want to create the hierarchy from a stored procedure, have the user add and remove nodes without calling back to the database. I will iterate through the tree and see what has changed and made the necessary updates on the database manually.
    What is the correct method for adding/removing rows form the UI component?
    Thanks!
    Tom

    Thank you, Amit! That did the trick.
    Edited by: Tom on Apr 28, 2011 11:51 AM

  • Add/delete row in JTable

    I went through the tutorial of JDK about how to programming JTable, i can NOT find a way to add/delete row into/from JTable.
    I immagine it would be a difficult task because the data set it takes 'Object data[][]' is NOT dynamically grow/shrinkble.
    Can we make it take ArrayList[] as input dataset so that the dataset can dynamically grow/shrink?
    Any other way around to add/delete row?
    THANKS for your consideration.

    You have to write your own TableModel like extending AbstractTableModel. In that class add custom methods to add and remove rows. From those methods call fireTableRowsDeleted(..) and fireTableRowsInserted(..) to update UI.

  • Adding delete row icon to report

    We have a custom report that I would like to add the delete row icon to. Is this possible? Thanks in advance.
    Eric

    I am looking to add a sequential row number to some reports.Standard or interactive reports?
    >
    I can't use an ID number because they may not be in a specific order and for asthetics, I would like them to be numbered sequentially. I have a report that we run for different meetings and based on the meeting group is what we base the report on. For example, we have a meeting to review cases with our security team and we have a meeting to review incidents with our server admin team so I have a report based on the different teams we are meeting with and would just like to have a reference to go by. There could be 40 returned rows and if I use an ID they may not be in sequential numerical order so asking someone to look at a row could still be time consuming for them to find and view, if that makes sense.
    >
    That appears to require that the order must be fixed in the query like this:
    select owner, incidentname, incidentaction
    from mytable
    where resolvingteam = 'teamnamehere'
    order by ownerin order for people looking at different instances of the report to be seeing the rows in the same sequence? (The only way to guarantee the sort order in SQL is to <tt>ORDER BY...</tt>) It doesn't appear that there is any room for ambiguity here: you don't want someone instructed to deal with case #4 as a matter of priority when their #4 is numbered according to a different order...
    Do the reports use pagination or should all rows appear on one page? The "+...asking someone to look at a row could still be time consuming for them to find and view...+" comment argues against pagination as it may require one or more page changes to find a given row, but retrieving everything on one page may impact performance and lead to issues with scrolling.
    What version of APEX are you using?
    What theme and template (if it's standard reports) are used?
    What browser(s) and version(s) are used?
    (FWIW, permanent, immutable IDs do appear to be a better idea to eliminate any possible ambiguity.)

  • Problem in deleting Rows of JTable after sorting it

    Hi all,
    I'm getting problems in Removing Row(s) after sorting a JTable.
    Please find the code snippets at this URL. Thanks for your time...
    http://forum.java.sun.com/thread.jsp?forum=31&thread=459736&start=15&range=15&hilite=false&q=

    Hi Abhijeet,
    I tried it the way you said using
         wdContext.nodeBirhtday_List().nodeItab().moveFirst();
         //     loop backwards to avoid index troubles
         for (int i = n - 1; i >= 0; --i)
              current_date  = wdContext.nodeBirhtday_List().nodeItab().currentItabElement().getGbdat().getDate();
              current_month = wdContext.nodeBirhtday_List().nodeItab().currentItabElement().getGbdat().getMonth();
              if (( current_date != date_today ) && ( current_month != month_today ))
                   wdContext.nodeBirhtday_List().nodeItab().removeElement(wdContext.nodeBirhtday_List().nodeItab().
                                  getElementAt(i));                
              wdContext.nodeBirhtday_List().nodeItab().moveNext();     
    It adds records...
    According to Valerys Solution, the IPrivate<CustomController> doesnt show me the required nodes. and gives me 'Unable to resolve' error.
    Can you please suggest where I am going wrong
    Regards
    Abdullah

  • Delete rows from JTable

    Hello
    I use a JTable with a custom table model that extends javax.swing.table.DefaultTableModel.
    I haven't overwrote the method
    public void removeRow(int row)Now when i use this method the rows always get removed from the end. It doesn't matter which value the parameter row has.
    Even when i call
    myTableModel.removeRow( 0 );it removes the rows at the end of the table.
    It would be nice if someone could help me with this.
    Regards, Michelle

    It's not so easy to do this because it's a big project, but here is the code of the table model.
    import javax.swing.table.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import java.util.*;
    public class AssignmentsTableModel2 extends DefaultTableModel implements TableModelListener
         static final long serialVersionUID = 41L;
         public AssignmentsTableModel2(String[][] arg1, String[] arg2)
              super(arg1, arg2);
         public Vector getColumnIdentifiers()
              return columnIdentifiers;
         @Override
         public int getColumnCount()
              return this.columnIdentifiers.size();
         @Override
         public int getRowCount()
              return this.dataVector.size();
         @Override
         public String getColumnName(int col)
            return (String)this.columnIdentifiers.elementAt( col );
         @Override
         public Object getValueAt(int rowIndex, int columnIndex)
              return ((Vector)this.dataVector.elementAt( rowIndex )).elementAt( columnIndex );
         @Override
         public void setValueAt( Object val, int rowIndex, int columnIndex )
              ((Vector)this.dataVector.elementAt( rowIndex )).set( columnIndex, val);
              fireTableCellUpdated( rowIndex, columnIndex );
         @Override
         public void tableChanged(TableModelEvent e)
         @Override
         public void setColumnIdentifiers(Vector columnIdentifiers)
              super.setColumnIdentifiers(columnIdentifiers);
         @Override
         public void removeRow(int row)
              this.dataVector.remove(row);
              System.out.println(row + " to remove");
              this.fireTableStructureChanged();
              //super.removeRow(row);
    }I need the model to change the background color of the cells at runtime and I now overwrote the removeRow() method, but it's still the same problem.
    Also I have a custom JTable class that colours the TableHeader of the selected column.
    class PaintedTable extends JTable {
        private static final long serialVersionUID = 1L;
        PaintedTable(AssignmentsTableModel2 atm)
            super(atm);
            setOpaque(false);
            ((JComponent) getDefaultRenderer(Object.class)).setOpaque(false);
        @Override
        public void paintComponent(Graphics g)
             //System.out.println("paint table");
            Color background = new Color(168, 210, 241);
            Color controlColor = new Color(230, 240, 230);
            int width = getWidth();
            int height = getHeight();
            Graphics2D g2 = (Graphics2D) g;
            Paint oldPaint = g2.getPaint();
            g2.setPaint(new GradientPaint(0, 0, background, width, 0, controlColor));
            g2.fillRect(0, 0, width, height);
            g2.setPaint(oldPaint);
            for (int row : getSelectedRows())
                Rectangle start = getCellRect(row, 0, true);
                Rectangle end = getCellRect(row, getColumnCount() - 1, true);
                g2.setPaint(new GradientPaint(start.x, 0, Color.orange, (int) ((end.x + end.width - start.x) * 1.25), 0, controlColor));
                g2.fillRect(start.x, start.y, end.x + end.width - start.x, start.height);
                //System.out.println("rect: (" + start.x + ", " + start.y + ") + (" + (end.x + end.width - start.x) + ", " + start.height +")");
            super.paintComponent(g);
        public boolean isCellEditable(int rowIndex, int colIndex)
            return false;  
    AssignmentsTableModel2 atm = new AssignmentsTableModel2(this.columnValues, this.columnHeaders);     
    PaintedTable table = new PaintedTable( this.atm );

  • Various problems with adding/deleting music on pho...

    I have a Lumia 620 and I think it's a wonderful phone, but putting music on it and removing it cleanly is such a hassle! I've never known a phone like it!
    I removed my SD card and put music on it when I first got it, everything was fine. But when I took it back out to delete everything and put new music on it, I found that the old music (even though it wasn't on the card) was still visible in the music library as well as the new.
    I searched the web and decided to format my card, I did that and everything was fine. But I also decided to try transfer my music via Nokia Music Player (beats having to remove my phone from the clip on case and removing the back to get to the card every time).
    So I started adding my music when I get a message saying my storage space is low... it's added it to my phone storage and not my card storage, even though in the settings I put add new music to SD card. So I deleted the music from Nokia Music Player hoping to remove it from my phone storage but no such luck.
    Not only have I got music listed in my library that isn't actually there, but it made duplicates too!
    What can I do to remove these empty files from my phone? Preferrably without having to go back to it's factory state. And is there program that works well with transferring music to my phone and onto the SD card?
    Any help will be appreciated SO much! This whole situation is really starting to annoy me now.

    Hi,
    Welcome to the forum!
    You don't need to take out the memory card on your phone just to transfer your preferred songs. You just need to connect your phone to your computer and do the steps from this link. This is the proper way of syncing or transferring music to your phone:
    http://www.windowsphone.com/en-US/how-to/wp8/music/sync-music-ringtones-and-podcasts-using-my-comput...
    Whenever you're going to save a music to your phone, make sure to check the phone storage settings. To do this, go to Settings > Phone storage > Store new music+videos on > select SD Card.
    If the phone prompted that the storage is very low, you can clean up Internet Explorer's temporary files, unnecessary Maps data and satellite images as well as Office documents from under each application's entry under Settings > Applications (swipe sideways to get the applications menu).
    Internet Explorer > delete history
    Maps  > download Maps > long-press an individual map to get an option to remove it, or delete all maps.
    Office  > reset Office to remove all downloaded content.
    Hope this helps. 

  • Problem in Adding JCheckBox Object to JTable

    I want to add a JCheckBox Object to A JTbale Coloumn but it shows the following message in JTable Coloumn-
    javax.swing.JCheckBox[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@f9f9d8,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=2,bottom=2,right=2],paintBorder=false,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=].
    Help Me in solving this problem

    Hi,
    All the thing you have to do is to return a boolean for the column. JTable will use a checkbox (as default) to show boolean values.

  • Re:Adding a row in a matrix using Lost_Focus event & deleting a row

    Dear All,
    Iam facing a problem in adding a row in a matrix using last focus event.its like if i keep the cusor in the last coloumn in a matrix n if i press tab it should add a row .the row is getting added the problem here is the cursor is gng to first row but it should come to the second row.
    the second problem is while deleting a row the row is getting deleted but the row count is showing the deleted row no.
    pls suggest a solution for these problems.
    Thanks & Regards
    Anand

    Hi,
    If pVal.BeforeAction = False Then
                Select Case pVal.EventType
                    Case SAPbouiCOM.BoEventTypes.et_KEY_DOWN
                        If pVal.ItemUID = "matlab" And pVal.ColUID = "mtimeout" And pVal.CharPressed = 9 Then
                            oMatrix = oForm.Items.Item("matlab").Specific
                            Dim rc As Integer = oMatrix.VisualRowCount
                            If rc = pVal.Row Then
                                addrow()    'funtion for adding row
                                oMatrix.Columns.Item("labc").Cells.Item(oMatrix.RowCount).Click()
                                'SBO_Application.MessageBox(oMatrix.RowCount)
                            End If
                        End If
    This is the function i hav used
    Private Sub addrow()
            Try
                If (oForm.UniqueID = "updt") Then
                    oForm = SBO_Application.Forms.ActiveForm
                    oForm = SBO_Application.Forms.Item("updt")
                    omatrix = oForm.Items.Item("matlab").Specific
                    omatrix.AddRow(1, omatrix.VisualRowCount)
                    Dim rc As Integer = omatrix.VisualRowCount
                    'SBO_Application.MessageBox(rc)
                    otext1 = omatrix.Columns.Item("mdatein").Cells.Item(rc).Specific
                    otext1.String = "s" 'RecSet.Fields.Item("date1").Value
                    otext1 = omatrix.Columns.Item("mdateout").Cells.Item(rc).Specific
                    otext1.String = "s" 'RecSet.Fields.Item("date1").Value
                    End If
            Catch ex As Exception
                SBO_Application.MessageBox(ex.Message)
            End Try
        End Sub
    this is the code which m using
    Regards,
    Anand

  • Delete Multiple Rows of JTable by selecting JCheckboxes

    Hi,
    I want delete rows of JTable that i select through JCheckbox on clicking on JButton. The code that i am using is deleting one row at a time. I want to delete multiple rows at a time on clicking on Button.
    This is the code i m using
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableTest extends JFrame implements ActionListener
         JButton btnAdd;
         BorderLayout layout;
         DefaultTableModel model;
         JTable table;JButton btexcluir;
         public static void main(String[] args)
              TableTest app = new TableTest();
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TableTest()
              super("Table Example");
              btnAdd = new JButton("Add");
              btnAdd.addActionListener(this);
              model = new DefaultTableModel()
                   public Class getColumnClass(int col)
                        switch (col)
                             case 1 :
                                  return Boolean.class;
                             default :
                                  return Object.class;
              table = new JTable(model);
              table.setPreferredSize(new Dimension(250,200));
              // Create a couple of columns
              model.addColumn("Col1");
              model.addColumn("Col2");
              JCheckBox cbox = new JCheckBox();
              // Append a row
              JPanel painel = new JPanel();
              model.addRow(new Object[] { "v1",new Boolean(false)});
              model.addRow(new Object[] { "v3", new Boolean(false)});
              JScrollPane scrollPane = new JScrollPane(table);
              scrollPane.createVerticalScrollBar();
              btexcluir= new JButton("Excluir");
              btexcluir.addActionListener(this);
              painel.add(btexcluir);
              painel.add(btnAdd);
              getContentPane().add(scrollPane, BorderLayout.NORTH);
              getContentPane().add(painel, BorderLayout.SOUTH);
              setSize(600, 600);
              setVisible(true);
         public void actionPerformed(ActionEvent e)     {
           if (e.getSource() == btnAdd)     
              model.addRow(new Object[] { "Karl", new Boolean(false)});
           if (e.getSource()==btexcluir){
                for (int i=0; i <=model.getRowCount(); i++){
                     if (model.getValueAt(i,1)==Boolean.FALSE)
                          JOptionPane.showMessageDialog(null, "No lines to remove!!");
                     else if(model.getValueAt(i,1)==Boolean.TRUE)
                          model.removeRow(i);
    }Please reply me with code help.
    Thanks
    Nitin

    Hi,
    Thanks for ur support. My that problem is solved now. One more problem now . Initially i want that delete button disabled. When i select any checkbox that button should get enabled. how can i do that ?
    Thanks
    Nitin

  • Problem in adding rows in a table

    Hello All ,
    I am having a strange problem in adding table rows here . All things seems to be in place . But when i click the button nothing happens . I have worked on much more complex tables and added rows safely but i cant understand what's happening here . I have saved the form as Dynamic XML form , interactive form , I have set the pagination of the repeating rows . But Heck !!! It's not working at all . I am totally confused . More over while i drag the table from the object palette an error appears and LC closes down .But when i click on the table at the toolbar and inserted table over there then it shows no error . What's happening ?? Any help is greatly appreciated .
    Script : form1.Page1.Subform1.Button1::click - (JavaScript, client)
    form1.Page1.Subform1.Table1.Row4.instanceManager.addInstance(1);
    Thanks .
    Bibhu.

    Hi,
    The way you described reminded me of another thread, where the index was not straightforward: Saving finished Form duplicates some subForms
    You can post your form to Acrobat.com, hit the Share and Publish buttons when prompted and then copy / paste the link here.
    Niall

  • BPM Object Presentation - array items - (add / delete rows dynamically)

    Hi,
    We have a BPM Object presentation which uses a 'group' inner object to display ROWS of data. The presentation has an 'array0' created by default to handle the 'group' of rows. It also has the '+' and '-' buttons by default.
    There is a field at the upper level which shows the 'sum' of values in individual rows. It needs to 'REFRESH' when an add (+) or deletetion (-) or rows happen.
    But we see that all the controls (text boxes etc which are wired to the 'inner' bpm object of the group and the +/- buttons are one unit 'array0'. And the only method if at all, is an 'Event Listner' which is not showing any methods related to BPM Object.
    Can anyone help us with a clue as to how to handle the '+' and '-' events or wire the 'array/group' events to code - any clue with 'events'?
    This is a little urgent as it is an issue and we need to fix the same. Appreciate any quick responses/clues.
    Thanks in advance,
    -user8702013.

    The SUM field needs refresh() method to be called to reflect the new value whenever we are adding/deleting rows.
    To call this method for to show the reflection we have to declare a method on BPM object level which receives a argument of type ‘Fuego.Util.GroupEvent’, then in this method you can have your logic(here refresh() method is required to show new value on deletion/addition, hence this method is being called). This method can then be wired (it shows up) to the 'Event Listener' of the group/array.
    The newly created method will be called whenever a new row is added/deleted (Event will be fired hence method call).

Maybe you are looking for

  • Customer Mat Nr missing in delivery

    Hi, I am trying to figure out why the field Customer Material Number is empty on a delivery. The delivery is created from a Scheduling Agreement, Agreement type LU (Vendor field empty). Can you give me a suggestion please? Thanks

  • How to close Acrobat reader with a button inside the document ?

    Hi, Is there any way to close acrobat reader using script ? Doing this : app.execMenuItem("Close"); will close my document, but not the reader ... Any idea ?

  • Attachments sent via mail not received as attachments

    Frequently when I send an email with an attached gif or jpeg, the receiver writes back to ask if I can send it as an attachment, not embedded in the email. I find this confusing since I don't know of any other way to send something than as an attachm

  • About cache group

    一个程序向TimesTen的数据表中插入数据能正常运行.但这个表和ORACLE做Cache Group时就不行. I have a wired problem: a program can insers data into a table of TimesTen when there is no Cache Group with oracle. However, it can not do this while it is connected to oracle using cache grou

  • Does Business Catalyst also host/provide email addresses?

    I am a Creative Cloud member seeking to create my own company's website and have it hosted by Business Catalyst via Muse. May I also host/provide email addresses? I've a domain name already registered but need to host a website (via Muse/Business Cat