Help on refreshing a table every second ? using table model

hi there
i have created a table using defaultTableModel. now i need to refresh the table every two seconds. to implement the refreshing, do i need to revalidate the container pane of the table every two second? i am just wondering since i use the tablemodel, maybe it can revalidate or repack automatically. please help me and thank you.

hi there
thank you for your help
here is what my table does, the program connects to the database, retreive data and populate the table every two seconds to reflect the changes in the database. here is the run method that does the connecting and ...
public void run()
boolean okay = true;
boolean updated = false;
String strSQL = "sql statment"
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(".....")
PreparedStatement ps = con.prepareStatement(strSQL);
while (okay)
rs = ps.executeQuery();
//code to query the database.....
tablemodel = (DefaultTableModel)jTable.getModel();
//code to repaint the table......
Thread.sleep(1000);
}catch (ClassNotFoundException cnfe){
}catch (SQLException sqle) {
}catch (InterruptedException e){
okay = false;
}catch (Exception ee){
System.out.println("Exception:" + ee.getMessage());
what can tablemodel do for this kind of task?

Similar Messages

  • Firefox keep refreshing some webpages every second.

    Firefox refreshes a webpage every second (if not faster ). This happens with certain websites and wont't let me stop it. Amazon.com's home page is one of them. Please advice.

    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • IPod needs to be reformated every "second use"

    Hey
    I am German so pleas excuse my spelling and gramma ;-(
    I just reinstaled my Computer a cupple of days ago, so it´s clean, before i reinstaled it everything was working just fine.
    So here is what happens, i plug in my USB conection in iPod and USB slot, it takes some time untill i get toled that my iPod needs to get reformated for use with this computer, i do reformate it, it works, i put the ~1600 i have on it, disconect it properly - and the next time i conect it we are back to waiting a while and having to reformate it...
    I can´t imagin that is is healthy for the iPod to hammer it with 1600 songs every second day wen i want to put a cupple of songs or a playlist on it (aside from it being anyoing no matter how bad it is for the hardware...)
    It would be great if someone could help me fix this.
    I am not a profesional so it might be issues with wrong instalation of the USB ports (software wise, i did not change any hardware) but i think i got al the drivers on the computer properly.

    It is telling me that i need to reformate it for use on this computer so i am pritty darn shure i can´t just put the files on it like i would wen it would work like it suposed to work (and did work sinc i bought it in september)
    Again. brok down so everyone hopfully gets what i am fighting with
    1. I conect the iPod
    2. the i pod tells me it needs to be reformated for use on this computer.
    3. i reformate it.
    4. it works just fine, i can put all the songs on it like i should be able to.
    5. the next time i conect my iPod to the VERY SAME computer there is minutes of it only being the USB harddrive, than i get a mesage that i need to reformate it for use on this computer (wich, yes, like formating usualy dos, deletes all files)
    help would be awsome becaus after 3 days of this i feel like having a creative jukebox would be better, and that should be telling you something sigh

  • Refresh every second

    Hi guys!
    I would like to refresh a label every second, and keep doing this.
    What can I use?
    Should be better to do the refresh in a different Thread?
    thank you!

    The DigitalClock class in this sample is an example of a Label which refreshes once per second:
    https://gist.github.com/3388637 "     Refactored sample of an animated clock in JavaFX"
    It uses the Timeline animation method suggested by David Grieve and the Calendar.getInstance method suggested by fabsav.

  • Updating JTable every second, want to ignore these events in my listener

    I have a JTable that I update every second using
    table.getModel().setValueAt(data, row, col);I'm also reacting to when the user clicks on a row in a the table, using a ListSelectionListener:
    public class MyTableListener implements ListSelectionListener {
              public void valueChanged(ListSelectionEvent e) {
                   if (e.getValueIsAdjusting()) return;
                   //do stuff
    }And of course I've done this:
    table.getSelectionModel.addListSelectionListener(new MyTableListener());Problem is, every time I update the table data it generates an event handled by valueChanged() above. I need to prevent this.
    Do I need a customized table model for this?
    Thanks!

    Found the problem: I forgot I was using JXTable, not JTable. Here's my example:
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import org.jdesktop.swingx.*;
    public class Test {
         JXTable table = null;//change this to JTable to fix
         public class MyTableListener implements ListSelectionListener {
              public void valueChanged(ListSelectionEvent e) {
                   System.out.println("event="+e.toString());
         public Test()
              JFrame frame  = new JFrame();
              String columns[] = {"one", "two"};
              Object data[][] = {{0, 0}, {0, 0}, {0, 0}};
              table = new JXTable(data, columns);//change this to JTable to fix
              table.getSelectionModel().addListSelectionListener(new MyTableListener());
              frame.add(new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
                          BorderLayout.CENTER);
              startThread();
              frame.setVisible(true);
         public static void main (String args[]) {
              Test test = new Test();
         public void startThread()
              class RefreshThread extends Thread {
                   public void run() { try {
                             while(true) { SwingUtilities.invokeLater(new Runnable() {public void run() {
                                       updateTable();
                                  sleep(1*1000);
                        } catch (Exception e) {e.printStackTrace();}
              RefreshThread rt = new RefreshThread();
              rt.start();
         public void updateTable()
              TableModel model = table.getModel();
              try {
                   for(int row = 0; row < model.getRowCount(); row++)
                        model.setValueAt(System.currentTimeMillis(), row, 0);
                        model.setValueAt(System.currentTimeMillis(), row, 1);
              } catch (Exception e) {
                   e.printStackTrace();
    }When I change it to a JTable, valueChanged() is not called every time I programmatically update the table.
    If it's a JXTable, valueChanged() is called with every update. Annoying!
    To compile/run the JXTable version you'll need something like
    java -cp swingx-1.0.jar:. TestAs for the events themselves, I added print statements with e.toString() and the events are not distinguishable from user interaction. I wonder if this is a JXTable bug or feature.
    Thanks!

  • Refresh only a region in a Page automatically every second

    Dear All
    I have a page in my application which would display the remaining seconds like 20,19 etc and when it reaches 0 the webpage should redirect to the calling page. I have set a counter for the same and is calling meta refresh tag in the page header every second for resetting the counter. Everything works fine.
    My question is whether there is any other way instead of using the meta tag as this will refresh the full screen. I just need the region containing the counter only to be refreshed and displayed on the screen.
    Thanks

    Hi,
    HTML regions do not support native region refresh like e.g. classic reports.
    You need write own JavaScript to fetch data using AJAX.
    Regards,
    Jari

  • How do I refresh a table with a bind variable using a return listener?

    JDev 11.1.2.1.0.
    I am trying to refresh a table with a bind variable after a record is added.
    The main page has a button which, on click, calls a task flow as an inline document. This popup task flow allows the user to insert a record. It has its own transaction and does not share data controls.
    Upon task flow return, the calling button's return dialog listener is invoked which should allow the user to see the newly created item in the table. The returnListener code:
        // retrieve the bind variable and clear it of any values used to filter the table results
        BindingContainer bindings = ADFUtils.getBindings();
        AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("pBpKey");
        attr.setInputValue("");
        // execute the table so it returns all rows
        OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");
        operationBinding.execute();
        // set the table's iterator to the newly created row
        DCIteratorBinding iter = (DCIteratorBinding) bindings.get("AllCustomersIterator");
        Object customerId = AdfFacesContext.getCurrentInstance().getPageFlowScope().get("newCustomerId");
        iter.setCurrentRowWithKeyValue((String)customerId);
        // refresh the page
        AdfFacesContext.getCurrentInstance().addPartialTarget(this.getFilterText());
        AdfFacesContext.getCurrentInstance().addPartialTarget(this.getCustomerTable());But the table does not refresh ... The bind variable's inputText component is empty. The table flickers as if it updates. But no new values are displayed, just the ones that were previously filtered or shown.
    I can do the EXACT SAME code in a button's actionListener that I click manually and the table will refresh fine. I'm really confused and have spent almost all day on this problem.
    Will

    Both options invoke the create new record task flow. The first method runs the "reset" code shown above through the calling button's returnListener once the task flow is complete. The second method is simply a button which, after the new record is added and the task flow returns, runs the "reset" code by my clicking it manually.
    I'm thinking that the returnListener code runs before some kind of automatic ppr happens on the table. I think this because the table contents flicker to show all customers (like I intend) but then goes back to displaying the restricted contents a split second later.
    Yes, the table is in the page that invokes the taskflow.
    Here are some pictures:
    http://williverstravels.com/JDev/Forums/Threads/2337410/Step1.jpg
    http://williverstravels.com/JDev/Forums/Threads/2337410/Step2.jpg
    http://williverstravels.com/JDev/Forums/Threads/2337410/Step3.jpg
    Step1 - invoke new record task flow
    Step2 - enter data and click Finish
    Step3 - bind parameter / table filter cleared. Table flickers with all values. Table reverts to previously filterd values.

  • How to make Mavericks Activity monitor refresh every second

    I noticed that the Mavericks version of Activity Monitor now refreshes only every 5 seconds.  It used to be every second.  I am guessing they intend to make Activity Monitor more energy efficient this way, but is it possible to make it refresh every second like it used to ?
    Thank you !

    All right,I have set up my Philips LCD vertical display content with normal built in screen... need playing with xrandr & xorg.conf more then....
    one question, intel driver in linux support vertical screen?
    Last edited by andywxy (2008-11-19 15:23:01)

  • I am getting a pop up on my iPhone 4S asking password of my iCloud even though I feed the password but still keep on asking the same thing every second so I am not able to use my iPhone.

    I am getting a pop up on my iPhone 4S asking password of my iCloud even though I feed the password but still keep on asking the same thing every second so I am not able to use my iPhone.at various times it asks different passwords.

    Curretly, there is an iCloud blackout.  It started this morning around 2AM California time (Pacific), 5AM New York (Eastern).  A lot of people have been having issues all day, including me.  No iCloud services are online.  Even Find My iPhone is down.

  • "Last devices used" menu every second over Ovi map...

    Hello all,
    I installed Ovi Maps on my phone, and have a huge problem with it: Every second the"Last devices used" pops up and goes away again.
    Since a few years I own (and use) a Nokia N95, and I just used 'Setup Nokia Maps Update 1.0.8.exe' to get Ovi maps on my phone. Apparently I had to use 'Nokia Software Updater' to make sure I got the latest version. Done that too.Next step is to use the Nokia Map Loader to get the maps on there. Done that too.
    Here is the version info of the installed map:
    I have Bluetooth enabled. Now, when I use the maps, every second the"Last devices used" pops up and goes away again. Mildly irritating would be a severe understatement here. Switching Bluetooth off and starting the map again gives the question "Bluetooth is currently switched off. Switch on?". Every second. It seems impossible to answer the popup-question or do something with the popup-menu.
    Is this a known prob by anyone, and can you please tell me a fix or workaround (preferably a fix of course)?
    Thank you,
    wlamee
    Solved!
    Go to Solution.

    And I got a nippy reply from the Benelux Nokia Care.
    The trick is I had to go to Tools -> Settings -> General -> Positioning -> Positioning Methods, and switch off 'Bluetooth GPS'. I think I always ahd this switched on and it never complained with the standard Nokia maps, but I'm not sure - I think I saw that menu only once, when I was palying with my GPS and the original maps.
    But hey, it's fixed. Cool!
    wlamee

  • Hello, I have a problem on my iPhone every second turn on and off I mean it shows the apple and off and again shows the apple icon and off and tried to Restore and it hangs on my iPhone and then waits Error 3004 Please I need help please!

    Hello, I have a problem on my iPhone every second turn on and off I mean it shows the apple and off and again shows the apple icon and off and tried to Restore and it hangs on my iPhone and then waits Error 3004 Please I need help please!

    Resolve communication issues
    Related errors: 17, 1004, 1013, 1638, 3014, 3194, 3000, 3002, 3004, 3013, 3014, 3015, 3194, or 3200.
    These alerts refer to gs.apple.com, say "There was a problem downloading the software," or say the "device isn't eligible for the requested build."
    I would guess your iphone has been hacked ( jailbroken ) ring any bells ?

  • Getting Image for every 2 second using AVI stream

    Hello,
    Could I save image for every 1 or 2 second from AVI stream (not file). It is because I have a piece of software which could capture image on live and could save the image as AVI format. However, I need the file format as JPEG format for every 1 or 2 second.Am I do it like this?
    Thanks
    fkli

    Why don't you get a simple jpeg obtained by ftp from your program? For example I've downloaded a ftp server named webcam32 (http://www.surveyorcorp.com/webcam32) that replaces a jpeg image by ftp every second. After that, it was rather easy to write an applet that displays the updated image. Most probably your program can do that for you.
    Hope yu'll find this useful.

  • Ipad cant be used - keeps flashing 'enter apple id password' every second

    Hi,
    I turned on my iPad 3 today and it is unusable.
    Every second it flashes up with the following - Sign in to iCloud.
    It wants me to enter an old apple ID that has been disabled.
    I cant sign in to make the flashing stop, and I can't do anything else as the flashing is continual every second.
    I have tried turning the iPad off, resetting by holding home and off button.
    I thought I would reset to factory settings and just lose my data but that isn't working either!
    Any suggestions would be appreciated.
    Thanks!

    Hi SmithyfromBT,
    To be sure an old Apple ID does not keep popping up like that, use the steps in this previous thread to remove it -
    How do I change my Apple ID on my iPad? | Apple Support Communities
    https://discussions.apple.com/thread/4431720
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Help please. How do I reverse every second word in a sentence?

    How do I reverse every second word in a sentence?
    For example, I have a sentence" I am a noob programmer. "
    It should be " I ma a boon programmer. " after I use the method.

    public String ReverseEverySecondWord(String sentence) {
              String[] arr = sentence.split(" ");
              StringBuilder sb = new StringBuilder();
              StringBuilder tempSb;
              char[] cArr;
              sb.append(arr[0] + " ");
              for (int i = 1; i < arr.length; i++) {
                   if (i % 2 == 1) {
                        tempSb = new StringBuilder();
                        cArr = arr.toCharArray();
                        for (int pos = cArr.length - 1; pos > -1; pos--) {
                             tempSb.append(cArr[pos]);
                        sb.append(tempSb.toString() + " ");
                   } else
                        sb.append(arr[i] + " ");
              return sb.substring(0, sb.length() - 1);

  • REFRESH OF TABLE CONTROL.

    HI GURUS,
    I AM USING TWO TABLE CONTROLS AND WANT TO SHOW THE SELECTED RECORDS IN THE SECOND TABLE CONTROL,
    ACTUALLY FOR THE FIRST TIME IF I SELECT RECORDS IT IS SHOWING CORRECTLY IN THE SECOND TABLE CONTROL BUT
    WHEN I AM BACK TO FIRST TABLE CONTROL AND AGAIN SELECT THE RECORDS,AFTER CLICK OK BUTTON THE SECOND
    TABLE CONTROL IS NOT SHOWING THE FRESH ONE,EVERY TIME IT REQUIRES TO EXIT FROM THE PROGRAM,THEN IT WORKS PROPERLY.
    I AM GIVING THE CODE FROM FLOW LOGIC OF TWO SCREENS AND INTERNAL TABLE USED FOR TABLE CONTROL.
    << Moderator message - please do not use ALL CAPS when posting - it makes your question harder to read. >>
    FLOW LOGIC OF FIRST SCREEN
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_2500.
    LOOP AT x_ekpo  WITH CONTROL tabcon CURSOR
    tabcon-current_line.
    ENDLOOP.
    PROCESS AFTER INPUT.
    MODULE select_material.
    loop at x_ekpo .
       MODULE UPDATE_TAB.
    endloop.
    MODULE USER_COMMAND_2500.
    IN SE38
    MODULE user_command_2500 INPUT.
    WHEN 'OKAY'.
          LOOP AT x_ekpo WHERE check = 'X'.
            APPEND x_ekpo TO x_ekpo3.
          ENDLOOP.
    ENDMODULE.
    MODULE update_tab INPUT.
    LOOP AT x_ekpo.
      IF x_ekpo-check = 'X'.
        MODIFY x_ekpo INDEX sy-stepl TRANSPORTING check.
      ENDIF.
    ENDLOOP.
    ENDMODULE.                 " UPDATE_TAB  INPUT
    FLOW LOGIC FOR SECOND SCREEN.
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_2501.
    LOOP AT x_ekpo3  WITH CONTROL tabcon2501 CURSOR
    tabcon2501-current_line.
    endloop.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_2501.
    LOOP.
    ENDLOOP.
    Edited by: Rob Burbank on Jan 2, 2010 5:08 PM

    Hi,
    As per my understanding, you need to display the 2nd Table Control with fresh data every time you click the OK Command Button. So, you need to REFRESH the Table Control in the 2nd screen every time the PBO is triggered based on the OK Command Button. You can use the following code to Refresh the Table Control.
    Syntax :
    REFRESH CONTROL contrl FROM SCREEN dynnr.
    Have a look at the following link from SAP HELP.
    http://help.sap.com/abapdocu_70/en/ABAPREFRESH_CONTROL.htm
    Hope this helps.
    Thanks,
    Samantak.

Maybe you are looking for

  • How do I get an external hard drive to mount?

    I have two Maxtor One Touch 4 Plus External Hard Drives. One works the other doesn't. The one that works is over a year old and has been a trusty loyal aid. The one that doesn't is only a couple of weeks old. It worked fine initially. Now no icon app

  • YTD vendor payments

    I am trying to print a report using S_ALR_87013127. I only want to include accounts that deal specificly with overhead.  I entered our telephone g/l under the Line Item Reconcilation Account and the program brought up all of the vendors even the ones

  • -208 ERROR preventing me from listening to purchases!

    ITunes 6 now asks me to authorise each song (purchases made over the last 12 months) and then I re-enter username and password and then I am told I have a new authorisation. (1/5) Then I get a -208 error, unknown error occurred. Please try again late

  • Dock.app icon appears in dock!?

    Well, I tried customizing my dock with a 3rd party app, but after applying the changes, I noticed that a new icon appeared in my dock - the icon for Dock.app. When I try quitting the app, it has a similar effect to the terminal command "killall Dock"

  • Booklet printing with Mac

    After purchasing an Officejet Pro 8620, with the promise of this feature advertised, I am disaapointed to find that booklet printing appears impossible from the Mac printer driver downloaded. The menu shows "Booklet" greyed out under the "two-sided"