Problem removing certain rows in a JTable

My program displays a JTable consisting of several rows of data. I also have JButtons rendered into a column in the JTable to delete rows. Basically when a JButton is clicked, the respective row will be removed.
This works pretty well until I realised a logical problem.
Assume I have 3 rows of data - A,B and C.
When a row is removed, the remaining rows at the bottom will move up. If I remove row B, row C moves up. There are 2 rows remaining.
The problem is, when I click on the JButton for row C, it somehow tries to remove the third row which doesn't exists anymore. I can still remove row A though, because the JButton for row A corresponds for the top row. Row C remains 'stuck'. I suppose a row is removed like Vector elements do.
Is there a way to update the table or reconstruct the table after removal of rows?
I've tried
((DefaultTableModel)table.getModel()).removeRow(row);
((DefaultTableModel)table.getModel()).fireTableRowsDeleted(row, row);but it doesn't work.
I don't want to go into getDataVector(). I prefer to work directly on the TableModel.
Thanks in advance.

I don't understand your problem. If your "Delete" button is
rendered into a column in the JTablethen how can you have a delete button in a
row which doesn't exists anymore.?
To get better help sooner, post a [SSCCE (Short, Self Contained, Compilable and Executable, Example Program)|http://mindprod.com/jgloss/sscce.html] that demonstrates the incorrect behaviour.
db

Similar Messages

  • How to remove a row from a jtable with DefaultTableModel

    Hi to all,]
    I want to remove a row from jtable. I am using DefaultTableModel.
    I have got some example but every example is given with AbstractTableModel
    Please help me...
    Thanks and Regards

    I want to remove a row from jtable. I am using DefaultTableModel.How do you program without reading the API.
    The name of the method you use is "removeRow". How hard is that to find by reading the API?
    Not only do you not bother to read the API, you don't even bother to read and respond to your old postings when you get help:
    http://forum.java.sun.com/thread.jspa?threadID=5137773
    http://forum.java.sun.com/thread.jspa?threadID=5134667
    http://forum.java.sun.com/thread.jspa?threadID=5131162
    Your on your own in the future.

  • I want to make certain rows of a JTable unclicktable

    I am woring with a JTable that I have placed on a JPanel. The JPanel that the table is in is big enought to display a table with 8 rows. The tables are dynamic and fill up according to the users actions when they click on another table.
    The problem is, is that sometimes the table will only be someway full (e.g. only 3 rows of the table will have content.) In order to make my GUI appear more professional I set it so that the table will always have 8 rows (sometimes the bottom few will be blank). What I want to do is to set it so that the blank rows are either unclickable by the user or else that clicking on the blank rows will not cause an event.
    Any ideas?
    Thanks in advance,
    Wallace

    When I try to find out how many real rows there are in the JTable I keep on getting the wrong answer back.
    For example:
    In my custom Table model I have set it so that there will always be at least 8 rows in the table. Therefore when there are 3 rows of real content, I want rows 3 - 7 to be unclickable.
    So to try and do this I have written this piece of code in my custom Table class that extends JTable:
    public void changeSelection( int row, int column, boolean toggle, boolean extend)
    {  if (row >= ((PerfTableModel)getModel()).getDataVector().size())
    {  return;
    else
    {  super.changeSelection( row, column, toggle, extend );
    However this does not work. When I replace the right-hand side of the if statement with getRowCount() this again returns 8 and the method is not effective.
    Any ideas as to what I can do?
    Thanks again
    Wallace

  • Remove all rows from a JTable.

    I carnt seem to work out how to do it, surely there is a way.
    Thank you

    for those people who search for a thread like this and find it i solved it by doing this.
    DefaultTableModel d =(DefaultTableModel)<Your Table Name>.getModel();
    int rowCount = d.getRowCount();
    for(int i=0; i < rowCount; i++){
    d.removeRow(0);
    The reason for the "0" in remove row is because it will automatically resize the rows down one and effectively you want to remove all the rows until there isnt any in the last row. :)

  • Removing rows from a JTable

    How can i remove a row from a JTable??

    You need to extends AbstractTableModel rather than use DefaultTableModel as I think from memory this just uses an array to store data.
    If you use a vector in your subclass to store your rows, then you can do something like this:
        public boolean delete(int rowIndex)
            if (rowIndex < 0 || rowIndex >= rowVector.size())
                return false;
            else
                int day = 0;
                MyRowClass row = rowVector.get(rowIndex);
                rowVector.remove(rowIndex);
                rowCount--;
                fireTableRowsDeleted(rowIndex, rowIndex);
                return true;
        }HTH
    Paul C.

  • How can i add rows to a JTable at run time ??????

    hi there
    how can i add a row to a JTable at run time? and display the table after the change? thank you.

    For adding or removing the rows from the JTable, you have to use the methods on the table model. I would show you a simple implementation of table model.
    public class MyTableModel extends AbstractTableModel {
    private ArrayList rowsList = null;
    private String [] columns = { "Column 1" , "Column 2", "Column 3"};
    public MyTableModel() {
    rowsList = new ArrayList();
    public int getRowCount() {
    return rowsList.size();
    public int getColumnCount() {
    return columns.length;
    public void addRow(MyRow myRow) {
    //MyRow is any of your object.
    rowsList.add(myRow);
    fireTableDataChanged();
    public void removeRow(int rowIndex) {
    rowsList.remove(rowIndex);
    fireTableRowsDeleted(rowIndex, rowIndex);
    public Object getValueAt(int row, in col) {
    MyRow currentRow = (MyRow)rowsList.get(row);
    switch (col) {
    case 0:
    //return the value of first cell
    break;
    case 1 :
    //return the value of second cell
    break;
    case 2 :
    //return the value of third cell
    break;
    }Then create the table using the TableModel using the constructor new JTable(TableModel) and then when you want to add/remove a row from the table, call myTableModel.addRow(MyRow) or myTableModel.removeRow(rowIndex)....I hope that this solves your problem.

  • Problem removing rows from JTable

    Hello,
    I'm having an issue with a JTable that I'm using. At one point in my application, I want to remove all the rows from the table and regenerate them (from a database). When I try to remove the rows and do nothing else, they remain in the table. The rows are being removed from the model, as I have verified this in code, but the display does not refresh at all.
    I am using custom renderers to change the background color of a cell based on its value, and I disabled them to see if that was the problem, but alas, it is not.
    Any suggestions or ideas why this may be occurring?

    I am using model.setRowCount(0); to clear the model, however the display never refreshes. Then you are doing something wrong because its that simple. Only a single line of code is required.
    Perhaps I should have included this in my original post.Actually, you should have included demo code in your original post. That way we don't have to guess what you are doing.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • How to remove a row from JTable

    Hi!
    I'm used to remove rows from JTables getting the model and doing a removeRow(num) like this:
    ((DefaultTableModel)jTable1.getModel()).removeRow(0);
    But with ADF and JDeveloper the model says it's a JUTableBinding.JUTableModel but its not accessible.
    How to remove a row in Jdeveloper 10.1.3.4.0?

    Or maybe is just better to refresh data in the jTable but I do not know either like doing it.

  • How to Remove Checked Rows from JTable

    Hello All,
    I am currently working on a JTable, in which I have also include a JCheckbox. What i have to do is to remove all the Rows which are Checked in the JTable, when the 'Delete' button is clicked.
    Please tell me how i can this can be done, it will be of great help.
    Thanks,
    Shikha

    Loop through the TableModel, Use the getValueAt(...) method to find rows with a selected checkBox. Then use the removeRow(...) method of the DefaultTableModel to remove the row.
    Note: make sure your loop starts at the last row of the table and counts down to 0, to simplify the delete logic.

  • Deleting a row from a JTable using a custom TableModel

    Before I waste any of your time I would like to go ahead and just say that I have searched through the forum using "delete row from Jtable" as the search keywords and while I have found very closely related issues, they have not solved my problem. I have found code postings by carmickr and his arguments as to why we should use DefaultTableModel instead of having created our own custom TableModel, and while I do agree, I just am not quite confident enough in applying it to my scenario. See I am reading from a file a bunch of Contractor objects and I am stuffing it into an arraylist which I am using in the following code posting to populate my TableModel which the JTable object in the gui then uses.
    My problem is that everything works except when I delete and when I delete I understand that the index is changing because I just removed a row from the arraylist object. Suppose I have 33 rows displaying in the GUI. Now after I delete say row #23, the delete function works and dutifuly the row disappears from the table, but if I try to delete a row say...the last row, it does not work and throws me an IndexOutOfBoundsException which totally makes sense. My question is how do I go about fixing it? Do I have to do something with the setRowCount method?
    Any help is appreciated.
    Cheers,
    Surya
    * ContractorTableModel.java
    * Created on January 12, 2006, 11:59 PM
    package code.suncertify.gui;
    import java.util.ArrayList;
    import java.util.logging.Logger;
    import javax.swing.table.AbstractTableModel;
    import code.suncertify.db.Contractor;
    * @author Surya De
    * @version 1.0
    public class ContractorTableModel extends AbstractTableModel {
         * The Logger instance. All log messages from this class are routed through
         * this member. The Logger namespace is <code>sampleproject.gui</code>.
        private Logger log = Logger.getLogger("code.gui");
         * An array of <code>String</code> objects representing the table headers.
        private String [] headerNames = {"Record Number", "Contractor Name",
        "Location", "Specialties","Size", "Rate",
        "Owner"};
         * Holds all Contractor instances displayed in the main table.
        private ArrayList <Object> contractorRecords = new ArrayList<Object>(5);
         * Returns the column count of the table.
         * @return An integer indicating the number or columns in the table.
        public int getColumnCount() {
            return this.headerNames.length;
         * Returns the number of rows in the table.
         * @return An integer indicating the number of rows in the table.
        public int getRowCount() {
            return this.contractorRecords.size();
         * Gets a value from a specified index in the table.
         * @param row An integer representing the row index.
         * @param column An integer representing the column index.
         * @return The object located at the specified row and column.
        public Object getValueAt(int row, int column) {
            Object [] temp = (Object[]) this.contractorRecords.get(row);
            return temp[column];
         * Sets the cell value at a specified index.
         * @param obj The object that is placed in the table cell.
         * @param row The row index.
         * @param column The column index.
        public void setValueAt(Object obj, int row, int column) {
            Object [] temp = (Object []) this.contractorRecords.get(row);
            temp [column] = obj;
         * Returns the name of a column at a given column index.
         * @param column The specified column index.
         * @return A String containing the column name.
        public String getColumnName(int column) {
            return headerNames[column];
         * Given a row and column index, indicates if a table cell can be edited.
         * @param row Specified row index.
         * @param column Specified column index.
         * @return A boolean indicating if a cell is editable.
        public boolean isCellEditable(int row, int column) {
            return false;
         * Adds a row of Contractor data to the table.
         * @param specialty
         * @param recNo The record number of the row in question.
         * @param name The name of the contractor.
         * @param location Where the contractor is located
         * @param size Number of workers for the contractor
         * @param rate The contractor specific charge rate
         * @param owner Name of owner
        public void addContractorRecord(int recNo, String name,
                String location, String specialty,
                int size, float rate, String owner) {
            Object [] temp = {new Integer(recNo), name,
            location, specialty, new Integer(size),
            new Float(rate), owner};
            this.contractorRecords.add(temp);
            fireTableDataChanged();
         * Adds a Contractor object to the table.
         * @param contractor The Contractor object to add to the table.
        public void addContractorRecord(Contractor contractor) {
            Object [] temp = {new Integer(contractor.getRecordNumber()),
            contractor.getName(), contractor.getLocation(),
            contractor.getSpecialties(), new Integer(contractor.getSize()),
            new Float(contractor.getRate()), contractor.getCustomerID()};
            this.contractorRecords.add(temp);
            fireTableDataChanged();
         * Deletes a row of Contractor data to the table.
         * @FIXME Now that I deleted a row then I will have to reset the internal structure so that I can delete again
         * @param recNo The record number of the row in question.
        public void deleteContractorRecord(int recNo) {
            contractorRecords.remove(recNo - 1);
            fireTableRowsDeleted(recNo -1, recNo - 1);
    }

    Wow that was a very quick response. Thanks camickr. I am only trying to delete a single row. I do not know how to go about posting a test program for the code I have posted above because honestly the gui itself is 800 lines of code, and then the file reading class is quite funky in itself. I can maybe email you the entire Netbeans project including code so if you are using Netbeans 5 RC2 you can run the code and see for yourself, but that would not be considerate of me.
    See I am trying to delete any row at any time...but only one at a time not multiple rows...so if a user decides to delete row 23 and then tries to delete the last row which happens to be row 33 in my case, my setup should be smart enough to still allow to delete the row.

  • JTable help - trying to copy/paste a row in a JTable

    Hello,
    Geez, JTable is such a pain..... I am trying copy a range of rows within a JTable using an Abstract Table Model). I need to use this Abstract model as I have a custom String Tokenizing routine which accesses a flat text file which is my "table" so-to-speak.....
    The sequence of events are:
    1. Highlight the selected rows via the Mouse
    2. Select "Copy" from a menu pull down which then runs
    my copy method which resides in my abstract table model,which properly figures out which cells I need to copy (see below code), and opens up new rows at the bottom
    of the JTable.
    I am trying to automatically take those selected cells and then paste them into the opened up rows at the end of the table when choosing "Paste" from the menu.
    Here is the copy method, and the code that calls it from my main application. I am having a bit of trouble trying to figure out the Paste routine which is where I need help.
    Sorry if this is a bit redundant, but I've been struggling with it...... I know that the System Clipboard is available, but I just cant get that to work for me...
    Does 1.4.1 have an "easy" way to do this so I don't have to re-invent the wheel ????
    Thanks in advance
    From my main app:
    private void updateTheFiles(String updateType)
    // Determine which model we are working with //
    currmodel = (DataFileTableModel)vec.elementAt(tabnum) ;
    System.out.println("File = " + fileNameArray[tabnum] );
    if (updateType == "Save") {     
    System.out.println("updateType = " + updateType );
    Object tfs = new TextFileSaver(currmodel,fileNameArray[tabnum],"Pipe",true) ;}
    if (updateType == "Insert") {
    System.out.println("updateType = " + updateType );
    int a = currmodel.getColumnCount() ;
    Object [] aRow = new Object [a];
    currmodel.addRow(aRow); }
    if (updateType == "Delete") {
    System.out.println("updateType = " + updateType );
    currmodel.deleteRows(startRowToBeDeleted, endRowToBeDeleted); }
    if (updateType == "Copy") {
    System.out.println("updateType = " + updateType );
    ----> currmodel.copyRows(startRowToBeDeleted, endRowToBeDeleted);
    // if (updateType == "Paste") {
    // System.out.println("updateType = " + updateType );
    // TablePaste tp = new TablePaste(userTable) ;
    // if (updateType == "Find") {
    // System.out.println("updateType = " + updateType );
    // Object fnd = new FindReplace() ; }
    // currmodel.copyRows(startRowToBeDeleted, endRowToBeDeleted); }
    Table Model:
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.io.* ;
    import java.util.* ;
    import java.lang.* ;
    public class DataFileTableModel extends AbstractTableModel {
    //public class DataFileTableModel extends DefaultTableModel {
    protected Vector data;
    protected Vector columnNames ;
    protected Vector copyVec ;
    protected String datafile;
    public DataFileTableModel(String f){
    datafile = f;
    initVectors();
    public void initVectors() {
    String aLine ;
    data = new Vector();
    columnNames = new Vector();
    try {
    FileInputStream fin = new FileInputStream(datafile);
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));
    // extract column names
    StringTokenizer st1 =
    new StringTokenizer(br.readLine(), "|");
    while(st1.hasMoreTokens())
    columnNames.addElement(st1.nextToken());
    // extract data
    while ((aLine = br.readLine()) != null) {
    StringTokenizer st2 =
    new StringTokenizer(aLine, "|");
    while(st2.hasMoreTokens())
    data.addElement(st2.nextToken());
    br.close();
    catch (Exception e) {
    e.printStackTrace();
    public int getRowCount() {
    return data.size() / getColumnCount();
    public int getColumnCount(){
    return columnNames.size();
    public String getColumnName(int columnIndex) {
    String colName = "";
    if (columnIndex <= getColumnCount())
    colName = (String)columnNames.elementAt(columnIndex);
    return colName;
    public Class getColumnClass(int columnIndex){
    return String.class;
    public boolean isCellEditable(int rowIndex, int columnIndex) {
    return true;
    public Object getValueAt(int rowIndex, int columnIndex) {
    return (String)data.elementAt( (rowIndex * getColumnCount()) + columnIndex);
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    data.setElementAt(aValue, (rowIndex * getColumnCount())+columnIndex) ;
    fireTableCellUpdated(rowIndex, columnIndex);
    public void addRow(Object[] aRow) {
    for (int i=0; i < aRow.length; i++)
    data.add(aRow);
    int size = getRowCount();
    fireTableRowsInserted(size-1,size-1);
    public void deleteRows(int startRow, int endRow)
    int tempRow = 0;
    int actualRows = 0;
    if (endRow < startRow)
    tempRow = endRow ;
    endRow = startRow ;
    startRow = tempRow ; }
         if (startRow < 0 || endRow > getRowCount())
         return;
         actualRows = (endRow - startRow) + 1 ;
         // determine the starting point (cell) to start deleting at //
         int colCount = getColumnCount() ;
         int cell = startRow * colCount ;
         // determine the total number of cells to delete //
         int totColCount = (getColumnCount() * actualRows) ;
         for (int d = 0; d < totColCount; d++)
         data.remove(cell) ;
    fireTableRowsDeleted(startRow,endRow) ;
    public void copyRows(int cStartRow, int cEndRow)
    System.out.println("Startrow = " + cStartRow) ;
    System.out.println("Endrow = " + cEndRow) ;
    int cTempRow = 0;
    int cActualRows = 0;
    if (cEndRow < cStartRow)
    cTempRow = cEndRow ;
    cEndRow = cStartRow ;
    cStartRow = cTempRow ; }
         if (cStartRow < 0 || cEndRow > getRowCount())
         return;
         cActualRows = (cEndRow - cStartRow) + 1 ;
         // determine the starting (cell) to start copying from //
         int cStartCell = cStartRow * getColumnCount() ;
         // determine the total number of cells to copy //
         int cTotCells = (getColumnCount() * cActualRows) ;
         // determine the ending cell //
         int cEndCell = (cStartCell + cTotCells) - 1 ;
         System.out.println("Start Cell = " + cStartCell) ;
         System.out.println("End Cell = " + cEndCell) ;
         System.out.println("Total Cells = " + cTotCells) ;     
         // Now we have to load the empty rows with the copied data //
         System.out.println("getrowcount = " + getRowCount()) ;
         // Open up empty rows where the copied data will reside //
         for (int ci = 0 ; ci < cActualRows ; ci++ )
         Object [] cRow = new Object [getColumnCount()] ;
         addRow(cRow) ;
         int newRowStart = (getRowCount() - cActualRows) ;
         int newRowEnd = getRowCount() - 1 ;
         System.out.println("new row start = " + newRowStart) ;
         System.out.println("new row end = " + newRowEnd ) ;

    Hi Veeru,
    I like to copy and paste in Excel too, so just do it!
    This forum is intended to help on specific problems. As you only told us what you like we can offer no help.
    But you may search the forum for all those other Excel related threads to find hints/examples/thoughts on this...
    Message Edited by GerdW on 01-12-2010 01:06 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Remove active rows from a filter context

    Hey,
    I have a problem that nags me for a couple of days …
    My problem is about people (dimSomeOne) who try something (dimThing) on a certain day (dimDate). Each try is finished with a status (dimStatus). It is possible that a distinct person has 1 or more trys for the same thing on the same day. This can be seen (if
    you watch at the worksheet fact, available on dropbox :-) ) for the 19th of march, here someone 1 has tried 2times the thing A, and finished with the status 1. What I'm looking for is the number of distinct SOMEONES on a specific day for a specific
    status. If SOMEONE has more than one status on the same day, this SOMEONE will just be counted for his MAX status. SOMEONE 1 has the status 2 and 3 on the 20th of March and therefor SOMEONE 1 will just be counted for STATUS 3 and not for STATUS 2 
    For the context dimTraining:A / dimStatus:2 / dimDate:20.03.2015 there are 5 active rows: theRowNumber 3,4,5,8,11. I want to remove the rows 3,4,5 due to the fact that they "belong" to someone 1 and the fact that someone 1 has the max stauts of 3
    on that date.
    I'm able to produce a DAX query that returns the a result that has the correct number of someone's for the the date and the status
    evaluate(
    summarize(
    filter(
    addcolumns(
    summarize(
    'fact',[aDate],[someone],[aStatus]
    --,[theRowNumber]
    ,"maxstatus"
    ,calculate(max(fact[aStatus]),all(fact[aStatus]))
    ,fact[aStatus] = [maxstatus]
    ,[aDate],[someone],[aStatus],[maxStatus]
    --,[therownumber]
    order by
    [aDate],[someone],[aStatus]
    , but I'm not able to use this in calculated measure.
    Showing the value 2 for the context: TRAINING:A / STATUS:2 / DATE:2015-03-20
    As always any help is appreciated
    By the way here is a xlsx file that contains my sample data and there are also two measures that unfortunately do not solve my problem:
    https://www.dropbox.com/s/anxn0vmrjzpiewx/TheDistinctSomeOneThing.xlsx?dl=0

    Hey Imke,
    thanks for bringing up the calculated column thing, I have to admit that most of the time I'm trying to avoid adding additional in-memory footprint by using calculated columns. But in comparison to the amount of fact rows (a couple of millions) the amount
    of distinct status values (blank(), 1,2,3, 4) does not count that much.
    But your suggested solution for the simple calculated measure has a little flaw due to the things distinctcount counts (even a NULL is counted), this can be seen if you add another "someone" to the dimSomeOne table and another fact row for the 20th
    of March / thing:A / astatus:2
    test2:=distinctcount([validStatus]) still shows the value 2, but now it should show 3
    I tweaked your suggestion for the measure a little using distinctcout for fact[someone]
    testFinal:=calculate(distinctcount(fact[someone]);not(isblank(fact[ValidStatus])))
    and I also changed the false part from 0 --> blank() for the calculated column.
    So, thanks again for bringing up the calculated column stuff, that I personally consider most of the time as an evil thing ;-) and sorry that my example was a way to simple, neglecting the distinct values fact of distinctcount

  • Highlighting different rows within a JTable

    I have a JTable that has 20 rows. I also have a Jlist next to the JTable. When someone selects something within the Jlist I want to highlight certain rows depending on what was selected within that list. For instance if a user selects Item1 within the list I want to highlight the 3rd, 8th and 11th row within a JTable. The problem is the JTable API will let you highlight a number of rows but not allow you to specify single rows to highlight at one time. When I run my code to do this I get the last row highlighted. The reason is because the 3rd and 8th row do get highlighted but when I call the setRowSelectionInterval(i, i); where i is the row to highlight it has already passed and will end up highlighting the 11th row only. Is there any work around for this?

    First, make sure you table supports multi-select. Turn it on in this case, otherwise you can't select multiple items.
    To color different rows, you'll have to set a cell renderer and use it to color those rows. It's possible to collor each and every cell a different color, set fonts, images, etc..you just need a good cell renderer.

  • How to refresh an existing row of a JTable

    Hi all,
    I have to refresh the data of an existing row of a JTable after some time in thread. The code snippet is
    DefaultTableModel model=new DefaultTableModel(data,columnNames);
    table = new JTable(model)
                   public boolean isCellEditable(int row, int col)
                   return false;
    Now I also add rows to this table within the run() of the thread as
    model.addRow(new Object []{sub1,sub6,sub12,sub3,sub18});
    My problem is that I want to refresh the data of this added row within the thread.
    Any help is highly appreciable. Thanks in advance.
    Regards,
    Har Krishan

    Hmmm. His qhestion does not seem to be with how to change the value of a field, but how to get the table to recognize the change. I thought such things were automatic. The model fires a value changed event and the JTable picks up the event and refreshes. I'm not sure why your table is not refreshing under these circumstances. Perhaps a more complete code snippet. Please use the open and close code tags to format your code if you include it.

  • To get the unique id of the selected row in a JTable as in Database

    Hi,
    After fetching the recodrs from the Database, I have displayed them in a JTable. Though I fetched all the columns from db, I am displying only only 2 columns, say Name and Number neither of which is unique, however I have a unique ID for each record in the db. Now when I select some row in the JTable, I need to know its unique ID (the one which is in the db) which i have not displayed in the JTable.
    Is there any API method that can store the unique ids of a table? Or how can this be done?
    Thanks in Advance.

    Although, if you don't want the Id visible in the table, then you need to remove its TableColumn from the TableColumnModel.
    Then when you want to reference the id you need to use:
    table.getModel.getValueAt(...);

Maybe you are looking for

  • Firefox 3.6 not compatible with RealPlayerSP?

    Recently upgraded to Firefox 3.6.6 (told of vulnerabilities in previous versions). RealPlayer SP was previously installed but seemed not recognized by FF after FF upgrade. Noticed the download bar was gone from videos as well as any ability to downlo

  • Some problem WRT-54gs

    Hello! I have a router LinkSys wrt 54 gs. (ver. 5.1 firmware 1.50.5). Ther is a problem with it. Computers of the work's group can't see each other's Netbios names connecting to the router.  How to resolve this problem ?

  • Datastream package format (document needed)

    Hi, I'm implementing a java component which generates a installable Solaris package out of target directory. I'm able to generate a filesystem format package just fine but when searching for documents about datastream package format I'm lost. The com

  • What does the log C4K_HWACLMAN-4-WARNINGSTRING mean ?

    Hi, Our customer has seen the following logs on a Catalyst: Jan 5 08:18:05.239: %C4K_PKTPROCESSING-4-ERRORPACKET: Warning - Unexpected packet hitting output acl pdd = 0x9844C208, 0x80000040 64 bytes: 00 04 27 84 38 FF 00 D0 BC F1 89 A8 08 00 45 00 00

  • Add in mass purchase organization to vendors

    Hi Gurus, Is it possible to add a new Purchase organization, in mass (say to 1000 vendors), in XK99 or in another t-code? Thanks in advance, Pedro Mariano