Updating a JTable with an array of values

Ther is a constructor that allows for the cretion of the table with an iniital array of values. However subsequent updates of blocks of data- say you received an array of updated data form a database- reuiqre you to update ince cell at a time. Is ther any way fo updating a whole block at once. I should point out that I am asking this because I am using JTables in the Matlab programming environment where arrays are the basic unit and looping through is a comparatively slow process

Yes, you can extend the AbstractTableModel and write a method for updating a whole block.
lets say you've got a Vector with Float[] arrays as elements to hold a 2D array of Float. The you could write:
      TableModel dataModel = new AbstractTableModel() {
            public int getColumnCount() { return col_names.size(); }
            public int getRowCount() { return data.size();}
            public Object getValueAt(int row, int col) {
               return ((Float)((Float[])data.elementAt(row))[col]).toString();
            public String getColumnName(int col) {
             return ((String)col_names.elementAt(col));
            public Class getColumnClass(int col) {
             return String.class;
            public boolean isCellEditable(int row, int col) {
              return true;
            public void setValueAt(Object aValue, int row, int col) {
               try {
                 Float fv = Float.valueOf((String)aValue);
                ((Float[])data.elementAt(row))[col] = fv;
               } catch (Exception ex) {
            public void setBlock(Float block[][], int row, int col) {
               // copy the Arrays with System.arrayCopy into data
      };PS: I don't know, if the above is correct written, havn't test this. But I hope you can recognize the idea behind it.
wami

Similar Messages

  • Filling a jtable with an array of Portfolio objects

    I have created a class Portfolio and want to put an array of portfolio objects in a Jtable.
    I created a tablePortfolioClass based on the AbstratTableModel and
    changed the classical 2 dimensional data array into a one dimensional arry of portfolio objects.
    The databaselayer correctly fills the Portfolio but does not display it inthe table...
    what am I doing wrong ?
    package DBpackage;
    import java.lang.String;
    public class Portfolio
    public Portfolio()
    public Portfolio(String sE)
    sEcode=sE;
    //here are normally set and getmethods that I left out
    private String sEcode;
    private double dQuantity;
    private double dAvgPrice;
    private double dPrice;
    private double dExchRate;
    private double dReturn;
    private String sDescr;
    private double dPerc;
    private double dTotal;
    =============================================================
    package DBpackage;
    import javax.swing.table.AbstractTableModel;
    class tablePortfolioClass extends AbstractTableModel
    Portfolio[]data=new Portfolio[50];
    final String[] columnNames={"Ecode","Description","Quantity","Price", "Avg","%","Total","Return"};
    public void tablePortfolioClass (int nrofRows)
    iRows=nrofRows;
    public void tablePortfolioClass(Portfolio[] pp)
    data=pp;
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row];
    public void setValueAt(Portfolio value, int row, int col) {
    data[row] = value;
    fireTableCellUpdated(row, col);
    private int iRows;
    private int iCols=4;
    =============================================================
    this is what is done in the frame
    Portfolio [] pf=new Portfolio[50];
    tablePortfolioClass pp=new tablePortfolioClass();
    //tablePortfolioClass pp=new tablePortfolioClass(pf); this one does not compile
    JTable grdPP=new JTable(pp);
    grdPP.setPreferredScrollableViewportSize(new Dimension(200,200));
    JScrollPane jscrollPanePP=new JScrollPane(grdPP);
    all more traditional implementations of the jtable work without any problem...
    anyone ?

    Your getValueAt() method should return the actual value you want to display in the table at the given row and column. Right now, it returns the whole Portfolio object. How is the table supposed to render a Portfolio object?
    Something more like this would make more sensepublic Object getValueAt(int row, int col)
      switch (col) {
      case 0:
        return data[row].getEcode();
      case 1:
        return data[row].getDescr();
      case 7:
        return new Double(data[row].getReturn());
    }The same can be said for your setValueAt() method. It should set the individual attributes of the Portfolio object at the given row rather than changing the whole object.

  • JTable with row header plus value extraction from headers

    Hi, I am trying to do the following:
    Short Version-
    1. Create a table that has both row and column headers
    2. Allow the user to mouse over any of these headers such that doing so will display an image I have produced on a panel. (I already know how to create the image and how to display it, I'm just not sure how to associate it with a particular row or column header)
    3. Make the row headers look as much as possible like the column headers.
    Slightly Longer Version-
    Column headers will be labled A-H (maximum) while row headers will be labled 1-12 (maximum). Either can be less, however, depending on user input. After the table has been realized, the user will move the mouse over say, header 'H' and when they do, a JPEG image will appear on another panel and a tooltip will appear above the cell showing a formula. This happens when either row or column headers are moused over.
    Currently, I am using the following code from the O'reilly Swing book as a baseline for experimentation but any help you can offer will be appreciated. I'm fairly new to the JTable world... :-(
    TableModel tm = new AbstractTableModel(){
                   String data[] = {"", "a", "b", "c", "d", "e"};
                   String headers [] = {"Row #", "Column1", "Column2", "Column3", "Column4", "Column5"};
                   public int getColumnCount(){ return data.length;}
                   public int getRowCount() { return 1000;}
                   public String getColumnName(int col){ return headers[col];}
                   public Object getValueAt(int row, int col){
                        return data[col] + row;
              //creates a column model for the main table. This model ignores the first
              //column added and sets a minimum width of 150 pixels for all others
              TableColumnModel cm = new DefaultTableColumnModel(){
                   boolean first = true;
                   public void addColumn(TableColumn tc){
                        if(first) {first = false; return;}
                        tc.setMinWidth(150);
                        super.addColumn(tc);
              //Creates a column model that will serve as the row header table. This model
              //picks a maxium width and stores only the first column
              TableColumnModel rowHeaderModel = new DefaultTableColumnModel(){
                   boolean first = true;
                   public void addColumn(TableColumn tc){
                        if(first) {
                             tc.setMaxWidth(tc.getPreferredWidth());
                             super.addColumn(tc);
                             first = false;
              JTable grid = new JTable(tm, cm);
              //set up the header column and hook it up to everything
              JTable headerColumn = new JTable(tm, rowHeaderModel);
              grid.createDefaultColumnsFromModel();
              headerColumn.createDefaultColumnsFromModel();
              //make sure the selection between the main table and the header stay in sync
              grid.setSelectionModel(headerColumn.getSelectionModel());
              headerColumn.setBorder(BorderFactory.createEtchedBorder());
              headerColumn.setBackground(Color.lightGray);
              headerColumn.setColumnSelectionAllowed(false);
              headerColumn.setCellSelectionEnabled(false);
              JViewport jv = new JViewport();
              jv.setView(headerColumn);
              jv.setPreferredSize(headerColumn.getMaximumSize());
              //to make the table scroll properly
              grid.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
              //have to manually attach row headers but after that, the scroll pane
              //keeps them in sync
              JScrollPane jsp = new JScrollPane(grid);
              jsp.setRowHeader(jv);
              jsp.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, headerColumn.getTableHeader());
              gridPanel.add(jsp, BorderLayout.NORTH);

    There a number of nice examples on JTable: http://www.senun.com/Left/Programming/Java_old/Examples_swing/SwingExamples.html
    Hope you could find something suitable ...
    Regards,
    Anton.

  • Sortable jtable with jcombo having different values

    Hi,
    I have a contacts list with name, addrerss etc., and telephone numbers where each contact can have several telephone numbers.
    The data is stored in a Derby DB in two tables with a PK and FK relationship. I need to load all the Contact fields in to a JTable where one of the columns will be the JCombos with telephone number(s) for that paticular contact.
    I have studied two neat sample code segments posted by a senior mrmber "camickr" at;
    [http://forum.java.sun.com/thread.jspa?forumID=57&threadID=637581 |http://forum.java.sun.com/thread.jspa?forumID=57&threadID=637581 ]
    Also another by " skdaga " at;
    [http://forums.sun.com/thread.jspa?threadID=749031&messageID=4284078|http://forums.sun.com/thread.jspa?threadID=749031&messageID=4284078]
    both are solid working examples.
    My problem is that I need to let the user to sort the table by columns and also filter by a text box entry. Meaning, the Combo boxes cannot have a fixed row index.
    Could someone advice if this is possible or I should use some other approach.
    Thanking you in advance,

    Hi camickr;
    Many thanks for your kind reply. I have managed to slightly modify your code to load the combos of individual telephone numbers dynamically.
    I have done so by returning a TableCellEditor from the public TableCellEditor getCellEditor(int row, int column) method, in place of storing the
    DefaultCellEditor dce1 = new DefaultCellEditor( comboBox1 ); etc., in an ArrayList.
    It goes as this. Following method is called by the return statement.
    private TableCellEditor createCellEditorWithCombo(int contactId) {
            JComboBox cmbNumbers = new JComboBox( <passed a Vector here thro' a PreparedStatement from the DB>);
            DefaultCellEditor editor = new DefaultCellEditor(cmbNumbers);
            return (TableCellEditor)editor;
        }The contactId of course could be easily desiphered from the "row" parameter then and there.
    I will follow your advice on the sorting part (on which I am yet to read the API fully) and get back with the result. Btw, I use the JDK 1.6u7 with Netbeans 6.1
    Thanking you once again for your great contributions,
    ViKARLL
    NB: By the way;
    camickr wrote:
    Well, if you look at my example you will note it uses the convertColumnIndexToModel(...). So you need to do the same thing for the row.It looks like you are referring to a diffrent post by you, since your example I worked on does not contain this method ??
    Edited by: ViKARLL on Sep 13, 2008 4:19 AM

  • Update table column with same auto-increment value, via T-SQL stored procedure

    Good Evening to every one,
    I have a table 'Contracts' as we can see in the picture below (I exported my data on An Excel Spreadsheet). Table's primary key is 'ID' column.
    I am trying to create a stored procedure (i.e. updContractNum), through which I am going to update the 'Contract_Num' column, in every row where the values on Property_Code, Customer, Cust_Category and Amnt ARE EQUAL, as we can see in the schema above.
    The value of Contract_Num is a combination of varchar and auto_increment (integer). For example, the next value on 'Contract number' column will be 'CN0005' for the combination of 11032-14503-02-1450,00
    I' m trying to use CURSORS for this update but I am new in using cursors and I am stuck in whole process. I atttach my code below:
    CREATE PROCEDURE updContractNum
    AS
    --declare the variables
    DECLARE @CONTRACT_NUM VARCHAR(10); -- Contract Number. The value that will be updated on the table.
    DECLARE @CONTRACT INTEGER; -- Contract number, the auto increment section on contract number
    DECLARE @CONTR_ROW VARCHAR(200); -- Contract row. The row elements that will be using on cursor
    DECLARE CONTRACT_CURSOR CURSOR FOR -- Get the necessary fields from table
    SELECT PROPERTY_CODE, CUSTOMER, CUST_CATEGORY, AMNT
    FROM CONTRACTS;
    OPEN CONTRACT_CURSOR -- open a cursor
    FETCH NEXT FROM CONTRACT_CURSOR INTO @CONTR_ROW
    WHILE @@FETCH_STATUS = 0 -- execute the update, for every row of the tabl
    BEGIN
    --update Contract_Num, using the format coding : contract_number = 'CN' + 0001
    UPDATE CONTRACTS
    SET CONTRACT_NUM = 'CN'+@CONTRACT_NUM+1
    END
    CLOSE CONTRACT_CURSOR
    Thank you in advance!

    You dont need cursor
    You can simply use an update statement like this
    UPDATE t
    SET Contract_Num = 'CN' + RIGHT('00000' + CAST(Rnk AS varchar(5)),5)
    FROM
    SELECT Contract_Num,
    DENSE_RANK() OVER (ORDER BY Property_Code,Customer,Cust_category,Amnt) AS Rnk
    FROM table
    )t
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How do i update a JTable with new data?

    Hey
    I have a JTable where the data of some football players are shown. Name, club, matches and goals. What i want is to change the data in
    the JTable when i click a button. For example each team in a league has its own button, so when i click the teams button, JTable has
    data of that teams players.
    Here is the code i have atm, there isnt anything on how to change the data, because i dont know where to start, plz point me in somekind of direction:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package test;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.ImageIcon;
    import javax.swing.JTable;
    import javax.swing.JButton;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    * @author Jesper
    public class Main extends JFrame implements ActionListener {
        private Players players;
        private JTextArea output;
        private JScrollPane scrollPane2;
        private JButton button1, button2;
        private String newline = "\n";
        private int club = 1;
        public Main(){
            players = new Players();
        public JMenuBar createMenuBar(){
            JMenuBar menuBar = new JMenuBar();
            JMenu menu = new JMenu("File");
            menu.setMnemonic(KeyEvent.VK_A);
            menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
            menuBar.add(menu);
            // add menuitems/buttons
            JMenuItem menuItemNew   = new JMenuItem("new");
            menuItemNew.setActionCommand("1");
            menuItemNew.addActionListener(this);       
            JMenuItem menuItemOpen   = new JMenuItem("Open");
            JMenuItem menuItemQuit   = new JMenuItem("Quit");
            menuItemQuit.setActionCommand("2");
            menuItemQuit.addActionListener(this);
            // add to menu
            menu.add(menuItemNew);
            menu.add(menuItemOpen);
            menu.add(menuItemQuit);
            return menuBar;
        public void actionPerformed(ActionEvent e){
            String s;
            if ("Silkeborg IF".equals(e.getActionCommand())){
                club = 1;
                s = e.getActionCommand();
                output.append(s + newline);
                button1.setEnabled(false);
                button2.setEnabled(true);
            } else{
                club = 2;
                s = e.getActionCommand();
                output.append(s + newline);
                button1.setEnabled(true);
                button2.setEnabled(false);
        //Quit the application.
        protected void quit() {
            System.exit(0);
        public Container createContent(){
            JPanel contentPane = new JPanel(new GridLayout(3,1));
            ImageIcon icon = createImageIcon("middle.gif", "a pretty but meaningless splat");
            JTable table = new JTable(players.showPlayers(club));
            //Create the first label.
            button1 = new JButton("Silkeborg IF");
            button1.setToolTipText("Klik her for at se Silkeborg IF");
            button1.addActionListener(this);
            button1.setActionCommand("Silkeborg IF");
            //Create the second label.
            button2 = new JButton("FC Midtjylland");
            button2.setToolTipText("Klik her for at se FC Midtjylland");
            button2.addActionListener(this);
            button2.setActionCommand("FC Midtjylland");
            //Create a scrolled text area.
            output = new JTextArea(5, 30);
            output.setEditable(false);
            scrollPane2 = new JScrollPane(output);
            //Add stuff to contentPane.
            contentPane.add(button1);
            contentPane.add(button2);
            contentPane.add(table);
            contentPane.add(scrollPane2, BorderLayout.CENTER);
            return contentPane;
        protected static ImageIcon createImageIcon(String path,
                                                   String description) {
            java.net.URL imgURL = Main.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL, description);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
        public static void createGUI(){
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Main main = new Main();
            frame.setJMenuBar(main.createMenuBar());
            frame.setContentPane(main.createContent());
            frame.setSize(500, 500);
            frame.setVisible(true);
         * @param args the command line arguments
        public static void main(String[] args) {
            createGUI();
    }

    ooohh sorry... i posted the wrong code :S
    Here is the correct code:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package test;
    import java.util.HashMap;
    import java.util.Set;
    import javax.swing.table.*;
    * @author Jesper
    public class Players {
        HashMap<Player, Stats> players;
        public Players(){
            players = new HashMap<Player, Stats>();
            addPlayer();
        public void addPlayer(){
            //Silkeborg IF
            players.put(new Player("Martin ?rnskov", 1), new Stats(19, 3, 1));
            players.put(new Player("Thomas Raun", 1), new Stats(23, 6, 0));
            players.put(new Player("Jimmy Mayasi", 1), new Stats(26, 26, 3));
            players.put(new Player("Lasse J?rgensen", 1), new Stats(33, 0, 0));
            //FC Midtjylland
            players.put(new Player("Frank Kristensen", 2), new Stats(19, 3, 1));
            players.put(new Player("Thomas R?ll", 2), new Stats(23, 6, 0));
            players.put(new Player("Simon Poulsen", 2), new Stats(26, 26, 3));
            players.put(new Player("Magnus Troels", 2), new Stats(33, 0, 0));
        public DefaultTableModel showPlayers(int club){
            String[] columNames = {"Spiller", "Klub", "Kampe", "M?l", "R?de kort"};
            //Object[][] data = {{"Martin ?rnskov", 19, 3, 1}, {"Thomas Raun", 23, 6, 0}};
            Set<Player> keys = players.keySet();
            Object[][] data = new Object[keys.size()][columNames.length];
            int i = 0;
            for(Player player : keys){
               if(player.getClub() == club){
                   data[0] = player.getName();
    data[i][1] = player.getClub();
    data[i][2] = players.get(player).getMatches();
    data[i][3] = players.get(player).getGoals();
    data[i][4] = players.get(player).getRedCards();
    i++;
    DefaultTableModel table = new DefaultTableModel(data, columNames);
    return table;

  • JTable: how to "synchronize" (and update) with an array ?

    Hello.
    I am new to the Swing and I have been googling to find a solution for my problem, but I've spent too much time and found nothing. Please give me some advice.
    So: I have an array of data and a JTable. The array is constantly being changed and I would like to update the JTable with every change in the array.
    Thank you so much for yr help.

    So here I am with an as-simple-as-possible example of my problem.
    Just run it, everything is in this class.
    And you'll have a table with 10 rows with 0 in every row. Every 2 seconds one line should change, but it doesn't, only if you resize the frame, or click in a cell the numbers in the cells will change.
    Q: how to change it without resizing or clicking into the table ?
    package MainFrame;
    import java.awt.BorderLayout;
    import javax.swing.JTable;
    import javax.swing.WindowConstants;
    import javax.swing.SwingUtilities;
    import javax.swing.table.AbstractTableModel;
    class NewJFrame extends javax.swing.JFrame {
         private static JTable jTable;
         public static void main(String[] args) throws Exception {
              SwingUtilities.invokeAndWait(new Runnable() {
                   public void run() {
                        NewJFrame inst = new NewJFrame();
                        inst.setLocationRelativeTo(null);
                        inst.setVisible(true);
              Generator gen = new Generator(jTable);
         public NewJFrame() {
              super();
              initGUI();
         private void initGUI() {
              try {
                   setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                   jTable = new JTable(new MyTableModel());
                   getContentPane().add(jTable, BorderLayout.CENTER);
                   pack();
                   this.setSize(399, 263);
              } catch (Exception e) {
                   e.printStackTrace();
    class Generator extends Thread {
         private int[] array = new int[10];
         JTable table;
         public Generator(JTable table) {
              array = new int[10];
              this.table = table;
              this.start();
         public void run() {
              super.run();
              for (int i = 0; i < 10; i++) {
                   array[i] = i + 200;
                   table.getModel().setValueAt(i, i, 0);
                   try {
                        Thread.sleep(2000);
                   } catch (InterruptedException e) {
    class MyTableModel extends AbstractTableModel {
         private int[] array = new int[10];
         public int getColumnCount() {
              return 1;
         public int getRowCount() {
              return array.length;
         public Object getValueAt(int arg0, int arg1) {
              return array[arg0];
         public void setValueAt(Object value, int rowIndex, int columnIndex) {
              array[rowIndex] = ((Integer) value).intValue();
    }Thank you so so much my man.

  • How can I update JTable with new Object[][]

    Hallo, I have got a problem. I want to update my Jtable with new Values,
    with
    setValueAt(Object aValue, int row, int column)
    i can only update one Object.
    Is it possible to update All Objects "Object[][]"??? in a whole Table
    after I clicked a Button???

    Hi,
    AbstractTableModel's method setValueAt(Object aValue, int row, int column)
    is not the way to fill values into a table. It is the way the table returns the changed values to you after the user has entered something. This is a very common misconception, probably because the method names are so confusing.
    The table model uses getValueAt (int row , int column)
    to fill in its rows and columns.
    If you extend AbstractTableModel to make this method fill in the correct values from you data array. then, when you wish to update the whole table, you can
    1) Put new values in the data array
    2) fireTableValuesChanged
    this will cause the table model to call getValueAt for every row and column.
    good luck.

  • Updating a JTable when using an AbstractTableModel

    Hi,
    I have tried to create a JTable with an AbstractTableModel but I am obviously missing something in all the tutorials and examples as I cannot get the table to update when using my model.
    My application reads data in from a CSV file that is selectable at run time, but I have written a small app that demonstrates the problem I am having.
    If you uncomment the DefaultTableModel lines of code all is OK, but I need to use my Abstract Class as I intend to colour certain rows and add a Boolean column, that I would like to display as a CheckBox and not just the String representation.
    Any help would be great as I am tearing my hair out here!!
    My Test Class
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.util.*;
    public class TestTable extends JFrame implements ActionListener
    private JPanel jpTestTable = new JPanel();          
    private Vector vColumnNames = new Vector();
    private Vector vCellValues = new Vector();
    private DefaultTableModel dtmTestTable;
    private CustomTableModel ctmTestTable;
    private JTable jtTestTable;
    private JScrollPane jspTestTable;
    private JButton jbGo = new JButton();
         public TestTable()
         dtmTestTable = new DefaultTableModel();
         ctmTestTable = new CustomTableModel();
         //jtTestTable = new JTable( dtmTestTable );  //using this instead of my CustomModel works fine
         jtTestTable = new JTable( ctmTestTable );
         jtTestTable.setAutoCreateRowSorter(true);
         jtTestTable.setFillsViewportHeight( true );
         jspTestTable = new JScrollPane( jtTestTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
         jspTestTable.setBounds( 10, 10, 350, 400 );
         jspTestTable.setBorder( BorderFactory.createLoweredBevelBorder() );
         jbGo.setText( "Go" );
         jbGo.setBorder( BorderFactory.createRaisedBevelBorder() );
         jbGo.setBounds( 125, 430, 100, 25 );
         jbGo.addActionListener(this);
         jpTestTable.setLayout( null );
         jpTestTable.setBounds( 0, 0, 375, 500 );     
         jpTestTable.add( jspTestTable );
         jpTestTable.add( jbGo );
         this.setTitle( "Test Table" );
         this.getContentPane().setLayout( null );
         this.setBounds( 200, 50, 375, 500 );
         this.getContentPane().add( jpTestTable );
         this.setResizable( false );
         public void actionPerformed( ActionEvent e )
         updateTable();
         public void updateTable()
         vColumnNames.add( "Please" );
         vColumnNames.add( "work" );
         vColumnNames.add( "you" );
         vColumnNames.add( "git!" );
         vColumnNames.trimToSize();
         Vector vRow = new Vector();
              for( int i = 0; i < 10; i++ )
                   for( int x = 0; x < vColumnNames.size(); x++ )
                        vRow.add( "" + i + "" + x );
              vCellValues.add( vRow );
         //dtmTestTable.setDataVector( vCellValues, vColumnNames );  //using this instead of my CustomModel works fine
         ctmTestTable.setDataVector( vCellValues, vColumnNames );
         public void processWindowEvent(WindowEvent e)
         super.processWindowEvent(e);
              if(e.getID() == WindowEvent.WINDOW_CLOSING)
              exit();
         public void exit()
         System.exit( 0 );     
         public static void main(String args[])
         TestTable tt = new TestTable();
         tt.setVisible( true );
    }And my CustomTableModel Class
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.util.*;
    public class CustomTableModel extends AbstractTableModel
    protected Vector columnIdentifiers  = new Vector();
    protected Vector dataVector = new Vector();
         public CustomTableModel()
         public CustomTableModel( Vector data, Vector columnNames )
         setDataVector( data, columnNames );
         public int getColumnCount()
         return columnIdentifiers.size();
         public int getRowCount()
         return dataVector.size();
         public String getColumnName( int col )
         return "" + columnIdentifiers.get( col );
         public Object getValueAt( int row, int col )
         Vector vRow = new Vector();
         vRow = (Vector) dataVector.get( row );
         return (Object) vRow.get( col );
         public Class getColumnClass(int c)
         return getValueAt(0, c).getClass();
         public boolean isCellEditable(int row, int col)
              if (col < 2)
                   return false;
              else
                   return true;
         public void setValueAt( Object value, int row, int col )
         Vector vTemp = (Vector) dataVector.get( row );
         Vector<Object> vRow = new Vector<Object>();
              for( int i = 0; i < vTemp.size(); i++ )
                   vRow.add( (Object) vTemp.get( i ) );
         vRow.remove( col );
         vRow.add( col, value );
         vRow.trimToSize();     
         dataVector.remove( row );
         dataVector.add( row, vRow );
         dataVector.trimToSize();
         fireTableCellUpdated(row, col);
         public void setDataVector( Vector data, Vector columnNames )
         columnIdentifiers  = (Vector) columnNames.clone();
         dataVector = (Vector) data.clone();
         fireTableDataChanged();
    }I have just tried adding the following code after reading another example, but same result - arrrrrrrgggggggghhhhhhhhh!!!!
    ctmTestTable = (CustomTableModel) jtTestTable.getModel();
    ctmTestTable.fireTableDataChanged();Edited by: Mr_Bump180 on Jul 28, 2008 2:51 PM

    Hi camickr,
    Well that is good news as my Abstact class is about as much good as an ashtray on a motorbike. I think I must have misread or misunderstood the Table Tutorials as I thought I had to use an Abstrat class to get colurs based on conditions and to get Check Boxes to represent Boolean variables.
    I am clearly struggling with this concept - which I have never used before - do you know of any tutorials, that explain how to update a JTable with file data at runtime, as all the ones I have looked at set it as part of the java code - which is no good to me.
    Also am I overriding the DefaultTableModel Class correctly - I have written a seperate Model class but wounder if I need to include it in with my JTable class. I was trying to make it generic so I didn't have to write one for each JTable - but as I can't get it to work I should perhaps try to walk before I run.
    I'm not asking for the code, but just a guide to how close I am to where I want to be, and some links to tutorials that are closer to what I want to achieve. I will reread the Java Table Tutorial tonight - and you never know the penny may drop all on it's own this time!!!
    Thanks

  • Contract Release Value is not updated with Confirmation or Invoice value

    The release value for a contract in SRM EBP shows the value of purchase orders created using that contract.  It does not take into account confirmation and/or invoice values.
    For example I create a PO for 10 items at £100/each using Contract ABC.  The total value of the PO is £1000 and the release value contract ABC would be £1000.  If I then only confirm and invoice 5 items (£500) for the PO, the release value of contract ABC stays at £1000 even though I would expect it to update to £500
    Therefore the release value of the contract could be incorrectly overstated if purchase orders are created against the contract but not actually invoiced/confirmed for their total value.
    Please could you confirm the correct functionality and how I could find out the the true invoice value of purchases made using a contract?

    Hi
    <u>Which SRM and R/3 versions are you using ?</u>
    <b>Meanwhile, please go through the following SAP OSS Notes, which will help in this case -></b>
    Note 622045 Net value in release overview of contract is incorrect
    Note 493519 Release quantities are not updated
    Note 1108322 BBP_CONTRACT_CHECK wrong calculation of values
    Note 1102886 Contracts: Lesser Field length for Target Value
    Note 1082548 Check of Released quantity and released value in contract
    Note 656181 Release synchronization of releases on services
    Note 874920 Currency not allowed to be changed for a 'Released' Contract
    Note 703771 Resetting release values during purchase order item deletion
    Note 643823 BLAREL: Incorrect values in service segment
    Note 519879 BBP_CTR_MAIN: No message when values in Contract are reset
    Note 520734 Target value not converted if currency is changed
    Note 528897 Documents not displayed in contract release order overview
    Note 430373 BBP_CON_MNT: No releases available
    Note 491993 Entry of contracts with target values
    Note 437491 Purchase contract: Incorrect update of the call-off values
    Note 406799 BBP_CON_MNT: Fields after contract release ready for input
    Note 398168 Purchase contract: Target value is not changed
    <b>Do let me know.</b>
    Regards
    - Atul

  • Unable to update this object because the following attributes associated with this object have values that may already be associated with another object in your local directory services

    Getting this error from DirSync
    Unable to update this object because the following attributes associated with this object have values that may already be associated with another object in your local directory services: [UserPrincipalName
    [email protected];].  Correct or remove the duplicate values in your local directory.  Please refer to
    http://support.microsoft.com/kb/2647098 for more information on identifying objects with duplicate attribute values.
    Quick eyeball and couldn't see the cause in the user account so used the script here:
    http://gallery.technet.microsoft.com/office/Fix-Duplicate-User-d92215ef
    And got these outputs:
    PS C:\Windows\System32\WindowsPowerShell\v1.0> Export-OSCADUserPrincipalName -UserPrincipalName "[email protected]" -Path .\outputs.csv
    WARNING: Cannot find objects with specified duplicate user principal name
    [email protected]
    Found 0 user(s) with duplicate user principal name.
    Where to from here?
    Richard P

    Hi,
    Did you talk about the Microsoft Azure Active Directory Sync tool ?
    If yes, this issue occurs if one or more of the following conditions are true:
    An object in the on-premises Active Directory has an SMTP address that's the same as the SMTP address of the object that's reporting the problem.
    An object in the on-premises Active Directory has a mail attribute that's identical to the object that's reporting the problem.
    An object already exists in your organizational account and has the same SMTP address or mail attribute as the object in the on-premises Active Directory
    More detail information, please refer to:
    http://support.microsoft.com/kb/2520976/en-us
    [Troubleshooting] Unable to update this object because the following attributes associated with this object
    http://blogs.technet.com/b/aadsyncsupport/archive/2014/05/20/troubleshooting-unable-to-update-this-object-because-the-following-attributes-associated-with-this-object.aspx
    Regards.
    Vivian Wang

  • How to create an array of ring with a different items/values for each

    Hi All,
    i want an array of text ring with different items and values for each text ring. Do you have other solution if it does not work?
    thanks by advance

    0utlaw wrote:
    Hello Mnemo15,
    The properties of elements in an array are shared across all controls or indicators in an array, so there is no way to specify unique selectable values for different text rings in an array.  It sounds like what you are looking for is a cluster of ring controls, where each control can be modified independently.  
    Could you provide a more descriptive overview of the sort of behavior you are looking for?  Are these ring elements populated at run time?  Will the values be changed dynamically? Will the user interact with them directly?
    Regards,
    But the selection is not a property, it is a value... I just tried it and you can have different selections.  Just not different items.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Best way to update a table with disinct values

    Hi, i would really appreciate some advise:
    I need to reguarly perform a task where i update 1 table with all the new data that has been entered from another table. I cant perform a complete insert as this will create duplicate data every time it runs so the only way i can think of is using cursors as per the script below:
    CREATE OR REPLACE PROCEDURE update_new_mem IS
    tmpVar NUMBER;
    CURSOR c_mem IS
    SELECT member_name,member_id
    FROM gym.members;
    crec c_mem%ROWTYPE;
    BEGIN
    OPEN c_mem;
    LOOP
    FETCH c_mem INTO crec;
    EXIT WHEN c_mem%NOTFOUND;
    BEGIN
    UPDATE gym.lifts
    SET name = crec.member_name
    WHERE member_id = crec.member_id;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN NULL;
    END;
    IF SQL%NOTFOUND THEN
    BEGIN
    INSERT INTO gym.lifts
    (name,member_id)
    VALUES (crec.member_name,crec.member_id);
    END;
    END IF;
    END LOOP;
    CLOSE c_mem;
    END update_new_mem;
    This method works but is there an easier (faster) way to update another table with new data only?
    Many thanks

    >
    This method works but is there an easier (faster) way to update another table with new data only?
    >
    Almost anything would be better than that slow-by-slow loop processing.
    You don't need a procedure you should just use MERGE for that. See the examples in the MERGE section of the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm
    MERGE INTO bonuses D
       USING (SELECT employee_id, salary, department_id FROM employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
         DELETE WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
         VALUES (S.employee_id, S.salary*.01)
         WHERE (S.salary <= 8000);

  • REUSE_ALV_GRID_DISPLAY - updating the database with new values

    Hi,
    I am using the function module 'REUSE_ALV_GRID_DISPLAY' to display records. I have managed to open a field for input/edit mode. Once this data has been changed , where will this data be? I have checked the internal table - no joy. I need to use this new/changed data to update the database with the new values.
    Thanks,
    Leanne

    Hi,
    The data is stored in table tab. After the changes the data does not reflect in table tab. Where can I get the data so that I can update my database?
    I have coded the process as follows:
        when '&SUSPEND'.
          loop at tab
            where box = 'X'.
              update zzzz
                set status       = 'SP'
          endloop.
    Regards,
    Leanne

  • Updating Items with DTW : error valid value

    hello,
    When I try to update one item with DTW I got one valid format error like this :
    "" is not a valid value for field "SellItem" the valid value are 'Y' 'Yes' 'N' 'No' application-defined or object-defined error65171.
    and this is my CSV file :
    RecordKey     ItemCode     ItemName     ItemsGroupCode     BarCode     SalesVATGroup     PurchaseItem     SalesItem     InventoryItem
        1;               AB1072;     IDE_CISL_HOBBY_1033;                  101     ;        5010356990356     ;  C4     ;Y     ;Y     ;Y
    So the same error came for the Last Three fields.
    Did someone have a solution ?
    JPL

    Hi Jean Pierre,
    Try entering the following values:
    yes: tYES
    no: tNO
    Case sensitive!
    Hope it helps,
    Adele

Maybe you are looking for