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.

Similar Messages

  • How to Synchronize Test Instance with Production database on regular basis.

    Hello
    How to Synchronize Test Instance with Production database on regular basis.
    I want to update my Test Instance with Production ERP on daily basis without downTime.?

    Hi,
    I recomend to configure physical standby database for your production and when ever you requir open standby Using a Physical Standby DB in Read Write Mode and Flashback DB, so that you can revert all the changes back and put the db in sync. Please follow below metalink notes.
    Business Continuity for Oracle E-Business Release 12 Using Oracle 11g Physical Standby Database (Doc ID 1070033.1)
    Business Continuity for Oracle E-Business Release 11i Using Oracle 11g Physical Standby Database - Single Instance and Oracle RAC (Doc ID 1068913.1)
    Business Continuity for Oracle Applications Release 11i, Database Releases 9i and 10g (Doc ID 216212.1)
    update my Test Instance with Production ERP on daily basis without downTime.?With zero down time is not possible I think.

  • How to synchronize Outlook 2010 with SAP Calendar

    Hello colleagues,
    How to synchronize Outlook 2010 with SAP Calendar??
    Thanks

    Install MfE (Mail for Exchange), then follow this: http://www.google.com/support/mobile/bin/answer.py?hl=en&answer=147951
    You can sync your mail, contacts and calendar with Google Sync. Tasks and notes are not supported. (Notes syncing is not possible with MfE anyway.)

  • HT3281 How to download and update iso 6

    I would like to learn how to download and update iso 6 in my iPad

    If you have an iPad 1, the max iOS is 5.1.1. For newer iPads, the current iOS is 6.1.3. The Settings>General>Software Update only appears if you have iOS 5.0 or higher currently installed.
    iOS 5: Updating your device to iOS 5 or Later
    http://support.apple.com/kb/HT4972
    How to install iOS 6
    http://www.macworld.com/article/2010061/hands-on-with-ios-6-installation.html
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    If you are currently running an iOS lower than 5.0, connect the iPad to the computer, open iTunes. Then select the iPad under the Devices heading on the left, click on the Summary tab and then click on Check for Update.
    Tip - If connected to your computer, you may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. Be sure and backup your iPad before the iOS update. After you update an iPad (except iPad 1) to iOS 6.x, the next update can be installed via wifi (i.e., not connected to your computer).
    Tip 2 - If you're updating via wifi, place your iPad close to your router to preclude getting a corrupted download.
     Cheers, Tom

  • How to accomplish these Updates with the Tool?

    How to accomplish these Updates with the Tool?
    UPDATE aimp.TIME_ZONE_BY_STATE_TYPE
    SET TIME_ZONE = 'X'
    WHERE STATE_CODE IN ('AE', 'AP', 'AA', 'MP', 'GU', 'PW', 'FM', 'MH');
    commit;
    UPDATE aimp.TIME_ZONE_BY_STATE_TYPE
    SET TIME_ZONE = 'E'
    WHERE STATE_CODE IN ('CT', 'DC', 'DE', 'GA', 'MA', 'MD', 'ME', 'MI', 'NC', 'NH', 'NJ', 'NY', 'OH', 'PA', 'PR', 'SC', 'VA', 'VI', 'VT', 'WV');
    commit;
    UPDATE aimp.TIME_ZONE_BY_STATE_TYPE
    SET TIME_ZONE = 'M'
    WHERE STATE_CODE IN ('AZ', 'CO', 'MT', 'NM', 'UT', 'WY');
    commit;
    UPDATE aimp.TIME_ZONE_BY_STATE_TYPE
    SET TIME_ZONE = 'P'
    WHERE STATE_CODE IN ('CA', 'NV', 'WA');
    commit;
    UPDATE aimp.TIME_ZONE_BY_STATE_TYPE
    SET TIME_ZONE = 'H'
    WHERE STATE_CODE IN ('HI');
    commit;
    UPDATE aimp.TIME_ZONE_BY_STATE_TYPE
    SET TIME_ZONE = 'A'
    WHERE STATE_CODE IN ('AK');
    commit;
    Thanks,
    Carol-Ann

    Good morning Carol-Ann,
    * Pick table operator for table TIME_ZONE_BY_STATE_TYPE twice, once as source and once as target.
    * Pick an expression operator.
    * Drag STATE_CODE as input to expression
    * Create output column TIME_ZONE in outgroup
    * With the attribute properties of this output, choose Expression
    * Enter here a case statement 'translating' all state_codes to time_zones, e.g. CASE
    WHEN INGRP1.STATE_CODE  IN ('AE', 'AP', 'AA', 'MP', 'GU', 'PW', 'FM', 'MH')
    THEN 'X'
    WHEN INGRP1.IN ('CT', 'DC', 'DE', 'GA', 'MA', 'MD', 'ME', 'MI', 'NC', 'NH', 'NJ', 'NY', 'OH', 'PA', 'PR', 'SC', 'VA', 'VI', 'VT', 'WV')
    THEN 'E'
    etc.
    END* Map this output column to TIME_ZONE column of target
    * Set Loading Type of target to Update, choose No Constraints.
    Hope this helps.
    Regards, Patrick

  • How to read and update the value of property file

    Hi,
    I am not able read the values from property file.
    Please tell me how to read and update the values from property file using Properties class
    This is my property file : - Config.properties its located in D:\newfolder
    Values
    SMTP = localhost
    Now i need to change the value of the SMTP
    New value :
    SMTP =10.60.1.9
    Pls Help me
    Thanks
    Merlin Rosina,

    Post a small (<1 page) example program that forum members can copy and run that demonstrates your problem.

  • I just downloaded and installed the new iTunes on a Toshiba Satelite of some age. It was just completely reformated and updated with XP. iTunes will not open. The terms page comes up and when I agree it disappears. I have uninstalled and reinstalled.

    I just downloaded and installed the new iTunes on a Toshiba Satelite of some age. It was just completely reformated and updated with XP. iTunes will not open. The terms page comes up and when I agree it disappears. I have uninstalled and reinstalled.

    Perhaps something here will help:
    http://support.apple.com/kb/TS1421
    Regards.

  • How to declare and work with select-option in screen painter?

    hello there,
    can anybody plz suggest me ,how to declare and work with select-option in screen painter?
    neon

    Hi Blue,
    Please check these threads which will help you a lot..
    module pool programming " to add selection-option on screen"
    Re: Select option in Dialog program screen
    Re: SELECT-OPTIONS in Screen
    Good luck
    Narin

  • Typically, How many back and forths with Creative Support before they acknowledge your questi

    Typically, how many times does one have to go back and forth with Creative Support before they acknowledge an issue or question?
    This is ridiculous.
    I'm on the forth reply now.
    All I want to know is if there is a?64-bit ASIO driver for the X-Fi Titanium on 64-bit Vista?
    They will not answer me.
    All of my testing indicates that there is not a 64-bit ASIO driver for Vista, but they will not confirm or deny.
    :angry:

    dRe: Typically, How many back and forths with Creative Support before they acknowledge your question?U I don't know what Creative would have written if you asked SUpport these days?
    I assume, they lied when they wrote this. There are several walkarounds for XFI cards
    with beta drivers. In releas drivers they exclude the ASIOx64, but in beta it's included!
    Creative has a very awkward marketing strategy. This was with Vista not having EAX on Audigy as
    the said it is impossible. The newer X-FI was able to?do it and after a few weeks the Audigy also could-
    after paying for it. The same with DolbyDigital Li've... and now with x64 ASIO. They reduce features
    in cases the cheaper card had same possibilities as the more expensi've EMUs...
    Shame on them. I?baught a creative Card for the 4th time (SB, SB AWE32,Audigy2, and now Titanium).
    I'm going to thinking about selling it...

  • How to zoom and pan with Edge animate?

    Hi,
    I have been trying to make a project with Edge Animate, it is all about an image, but I want to be able to zoom and pan the image. Can you please send me an example if there is any around? or Can you explain me how to zoom and pan with Edge Animate?
    Thanks,
    Guasch

    I am having this same issue! I am searching through forums on what tools to use to create a good zoom and pan on an image that contains hyperlinks an other things, developed in Adobe Edge Animate.
    So far, here are some solutions I have come across:
    http://craigfrancis.github.io/zoomify/
    http://zynga.github.io/scroller/demo/dom.html
    These two seem to be the closest solutions to what I'm looking for. Now I just have to integrate the javascript into my adobe ege animate composition. Hopefully that won't be too hard. Are there any suggestions from the adobe community on how to do this?

  • My iphone 3gs is charging on the wall charger but wont charge on the pc, have cleaned it, yet it can sync and update with itunes easily, but it still wont charge, have tried several cables as well same effect.

    my iphone 3gs is charging on the wall charger but wont charge on the pc, have cleaned it, yet it can sync and update with itunes easily, but it still wont charge, have tried several cables as well same effect.

    1) authorize iTunes on your wife's user account for her iTunes store account(s)
    2) connect the device and right-click or control-click it in the iTunes Source list, then choose transfer purchases from the shortcut menu that appears.
    3) sync the device
    iTunes will wipe the iPhone but, since you transferred her purchases in the previous step, your content will be in her library and you can re-populate the iPhone with it.

  • Updating with Host Arrays

    Hello,
    I would like to query the Oracle community about an item
    that is giving me some trouble.
    I am developping a real time data base for a utility and I
    have situation where I receive messages from the SCADA of which
    not all are included in the database (for example, the firmware
    of some SCADA components has not been programmed correctly and
    gives the wrong ID number); I have to update the data base and
    then resend to other process the messages I have received.
    Naturally I do not want to resend the messages that contain the
    wrong information, and as this is a real time data base, I try
    to use the fastest techniques available (to the best of my
    knowledge), in this case, host arrays.
    The trouble is, when updating with host arrays, if no data
    is found for a particular ID ( Error ORA-1403), oracle continues
    and follows on with the next item in the host array, which is
    great, but it does warn you (as far as I know), that that
    particulat member of the host array is not included in the data
    base.
    Is there any method with which I can find out which member
    (s) failed in the update? or which members succeded?
    Thanks!!!!
    null

    I found after testing that your response is correct.
    The database does not consider '0 rows updated' a true error condition, therefore sqlerrd[2] reports the number of rows that WERE updated,NOT the array offset of the row that did not get updated.
    Furthermore, through extensive testing, I have found that the behavior I was told to expect by Oracle is NOT how Oracle behaves. Specially, if I have 5 array items, and item 3 does not result in an update, sqlerrd[2] reports 4 - meaning 4 rows updated, not 2, meaning that the third array item failed to result in an update.
    If the first item does not result in an update, the second item results in an update, and the 3rd item results in an oracle error (field too large for instance),sqlerrd[2] does not return 2 as expected (indicating the error occured in array item 3) but instead returns a 1, indicating one row was updated before the error occurred.
    Test scenario as follows:
    for some table, col1 CHAR[10], col2 CHAR[3] with the following rows:
    200010, ABC
    200020, ABC
    200030, ABC
    200040, ABC
    200050, ABC
    The statement in the ProC code:
    UPDATE tablename SET col2 = :v1 where col1 = :v2;
    col1 array holds:
    200011
    200020
    200030
    200040
    200050
    col2 array holds:
    XYZ
    XYZ
    XYZZ <<< note field too long forcing Oracle error
    XYZ
    XYZ
    I would expect based on the documentation that sqlerrd[2] returns 2 (3rd array element results in Oracle error), but what happens instead is sqlerrd[2]
    returns 1 (indicating that one row was updated, col1=200020, before an error was encountered in 3rd element of array.
    If col2 array holds:
    XYZ
    XYZ
    XYZ
    XYZ
    XYZ
    I would expect based on the feedback in the TAR that sqlerrd[2] would return 0 indicating that the first array resulted in a 1403 - what I get is 4,
    indicating 4 rows were updated as a result of this array.

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • How to share and update one iTunes master library on an external HD between an iMac and iBook

    Hi.  I am in the process of consolidating and switching gears from storing my iTunes libraries (which have roughly the same files) on both my iMac and iBook (both OS 10.7.5) to creating one master library on an external hard drive (Canvio Connect 2TB) and sharing that between both computers, updating the laptop (which I use less frequently) when necessary. I wanted to know if this is possible and if so, how to go about doing this in a way where I don't lose any data and am able to maintain it efficiently.  Thanks!

    There is a library file on the external drive that contains a list of all the tracks you have put into iTunes.  The list points to media files iTunes plays are on the external drive too.  Using the instructions I provided you tell the iTunes application on each computer to start up using the library file on the external drive.  If you add a file to iTunes while using computer #1 the file will be copied to the media folder on the external drive and the library file on the external drive will be updated to show there is a new file.  When you plug the same drive into computer #2 and start iTunes it takes the file listing from the library file on the external drive.  You are using the one library with each computer and it exists only on the external drive which both computers use.  They are truly sharing the same single copy of the  library.
    I have a box with objects inside and a list inside with an updated inventory of the objects. I give the box to you. You take some objects out and put some in and make a note in the list of what you have done, then put the list back inside and hand the box to me.  How do I know what changes you have done?  Simple.  I open the box and look at the list.  It's the same list that was in your hands only moments before.  I add a few objects and update the list, put it back inside the box and hand the box to you.  How do you know what changes have been made? Simple.  Open the box and read the list which was the one I updated moments before.  The only copy of the list is in the box so neither of us is needing to keep our own copy of the list updated.
    Everything iTunes needs to generate your library listing is in the iTunes folder, but it doesn't have to be on the computer.  In your case it will all be on the external drive and each copy of the iTunes application on each computer will look and use the same identical library file on the external drive as you pass it from computer to computer.  Once you have set this up you can delete the entire iTunes folder in Music from your computer because the application will no longer be using it.  The only thing "iTunes" left on the computer will be the application itself, but each copy will have been told to use the library on the external drive.
    Okay, enough.  I've said the same thing about 4 ways now.

  • How to synchronize N95 8GB with Google calendar

    Hello,
    I'm using N95 8GB and I would like to synchronize all my information with Google Calendar. How can I do it?
    Thank you,
    Tom K.
    Solved!
    Go to Solution.

    Install MfE (Mail for Exchange), then follow this: http://www.google.com/support/mobile/bin/answer.py?hl=en&answer=147951
    You can sync your mail, contacts and calendar with Google Sync. Tasks and notes are not supported. (Notes syncing is not possible with MfE anyway.)

Maybe you are looking for