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!

Similar Messages

  • When I connect my iPod touch to my computer, I have a list of Events on my iTunes/iPod/Photos. I want to erase these Events. However, the photos are NOT on my MacBook Air. When I check one of the Events and then hit Apply, the photos appear on my iPod.

    When I connect my iPod touch to my computer, I have a list of Events on my iTunes-iPod-Photos. I want to erase these Events. However, the photos are NOT on my MacBook Air-iPhoto. When I check one of the Events and then hit Apply, the photos appear on my iPod. And one last thing: When I connect the iPod and open iPhoto, iPhoto tries to load New Photos (I think), but nothing happens. Any ideas?

    Resolved.

  • IOS update image every second?

    Hello,
    I am very new to app development, so apologies for the simple questions.
    I have an image on a remote server of which updates every second, now I would like to put that image in a view in an app and have it effectively refresh every second.
    Currently its done using javascript and I just reference the image on the remote server with a time stamp on the end of the image like:
    image.jpg?Tue Jul 03 2012 10:57:08 GMT+0100 (GMT Daylight Time)
    Now I have this working with a local html file and a webview, I just wanted and think it should be possible using native iOS objects like the timer and image view.
    Just not sure how to achieve this.
    Any help is much appreciated.
    Thanks

    Any one?

  • Why the Flash Player updates almost every day?

    Why does the Flash Player update almost every day?

    You think these are the only/main cause of security issues?
    As a developer let me tell you it is far from the case. Most security issues are a direct result of user carelesness.
    Let me give you an example....
    I'm just a loley ole developer, no one special, but I do create many web apps/mobile apps, and many are free, and widely distributed.
    One example is a social networking web app based on html5 and google maps api - a gps enabled social web app.
    trufaces.com
    This is just one example of hundreds, I offer free hosting services truimagz.com/host and mush more.
    Anyway, the point is... do you have any idea how many people sign up using an email adress and their actuall email password as their login info?
    90%+
    I, just some schmuck, have access to over 50,000 email accounts and passwords at any given moment. Thank god I'm trustworthy eh?
    Just food for thought.

  • How to read two files (one is updating every second, the other is constant) simoltaneously

    Dear All,
    I will appreciate if somebody help me.
    I want to read two files, one is temperature wich is updating every second, and the other is hysteresis energy which has specific rows and is constant.
    I got a program in discussion forum which read a file as it is updating. I checked this program in my case and it works.
    Then I added reading hysteresis energy file to the existing file. But while i am running the program, the hysteresis energy file is read with all rows.
    But the aim is that everytime which temperature updates, I need to read just one row of the hysteresis energy file.
    so, in this way in every second i have a new temperature data and one row of the other file.
    I tried to used "for loop" inside the program, but it did not work, becuase reading temperature will be stopped untill for loop ends.
    I attached the program.
    Could somebody help me how to read just one row of hysteresis energy file everytime temperature updates?
    Solved!
    Go to Solution.
    Attachments:
    Readfiles.vi ‏23 KB

    I do not understand relationship between your two files.
    You have another VI or app that is writing data to both files and when new temperature data added you wish just to read the new data and then read one new line of the hysteresis file?????
    But is one is constant, why do you need to keep reading it?
    Anyway…
    The “Read From Spreadsheet File.vi” preformed an Open and a Close for each time it is called (if you will open the VI up and drill down and you will see). So that resets the file pointer back to the beginning and there for will read in the whole file from the first to the last each time if you do not set the start of read offset or number of rows.
    Now the Read from Binary File does not reset the file pointer and leaves the file pointer just past the last byte read so it will start with any new bytes automaicly only giving you the new data.
    I do not think you need to do the math with the Previous EOF=0 and the File size to get what I think you are trying to do.
    Plus use shift reg for the Data string instead of local var
    Set the mechinacl action of the stop botton to Latched
    So you do not need to init the two controls
    Also, I do not get the End of file encountered error (4) from the Read from Binary file if I attempt to read past. It just returns and empty string.
    Omar
    Attachments:
    Readfiles.vi ‏22 KB

  • Semi - Smart Albums - all I want is to update iPhoto every time I add a new

    after reading the iPhoto Help files descriptions of Standard and Smart - Im after Semi - Smart.
    Standard: You can also create an album by dragging a folder of photos from the Finder into an empty part of iPhoto's Source list. iPhoto creates an album with the folder's name and imports all photos contained in the folder.
    - but what iPhoto 6 wont do is automatically update itself every time I add a new pic into the source folder.
    Smart Folder: "You can make a Smart Album that contains only certain types of photos, photos with high ratings, or photos that match other criteria, including EXIF information, such as a specific shutter speed or camera model....
    iPhoto automatically modifies a Smart Album when any photo that matches the album's settings is added to or removed from your library."
    but what iPhoto 6 wont do is to simply capture the folder name as Ive named it in my source folder structure.
    So Im after:
    a. drag a folder ( for example, cars, gemstones, Klimit art) into the iPhoto source pane, it becomes a semi-smart folder in that it watches every new change I make to the source files on my computer. I add a file, iPhoto 6 adds it. I delete one, it deletes it. I mod it - you get the game here.
    Do I need to upgrade iPhoto to handle this rudimentary task ? Seems like this action would be built in - am I missing something here ?
    TIA

    will try that out, thanks for the tip.
    Who would want to have to use Automator or Applescript to make such a rudimentary function enabled within iPhoto ? I would guess 95% of Mac users never use those things. The whole point of Mac is to keep your life from having to descend into mundane technical details, thus freeing one for more time with life's higher level tasks. This should be basic from-day-one type behavior in any photo app.
    Will chime back in on how difficult it get iPhoto to auto-update itself with every new pic I add/subtract to these watched folders.

  • Cursor only updates every second row

    Hello Helpful Peoples
    I have a table with a set of delivery dates, and am wanting to add a date on which a reminder flag should be raised by the system. The delivery dates are already populated and I'm wanting to add functionality where the end user can set how many days prior they are reminded.
    I've opened a cursor to retrieve all the current due dates from my source table. When I loop through this cursor and update the reminder date and reminder text, my code is only updating every second row.
    I can't work out why this code seems to skip a row every time it updates a record. Is anyone able to assist?
    declare
    v_date rep_delivery.reminderdate%type;
    v_rownum number;
    CURSOR reminder_cur
    IS
    SELECT DEL.DUEDATE
    FROM REP_DELIVERY DEL
    WHERE DEL.REP_ID = :P212_REP_ID:
    FOR UPDATE OF DEL.REMINDERDATE;
    begin
    FOR x IN reminder_cur LOOP
    FETCH reminder_cur INTO v_date;
    EXIT WHEN reminder_cur%NOTFOUND;
    v_date := v_date - to_number(:P212_REMDAYS);
    UPDATE REP_DELIVERY DEL2
    SET DEL2.REMINDERDATE = v_date
    WHERE CURRENT OF reminder_cur;
    UPDATE REP_DELIVERY DEL3
    SET DEL3.REMINDERTEXT = :P212_DESCRIPTION
    WHERE CURRENT OF reminder_cur;
    END LOOP;
    commit;
    end;

    Oolite,
    Use this code:
    DECLARE
       v_date   rep_delivery.reminderdate%TYPE;
       CURSOR reminder_cur
       IS
          SELECT        ROWID, duedate
                   FROM rep_delivery
                  WHERE rep_id = :p212_rep_id
          FOR UPDATE OF reminderdate;
    BEGIN
       FOR x IN reminder_cur
       LOOP
          v_date := x.duedate;
          v_date := v_date - TO_NUMBER (:p212_remdays);
          UPDATE rep_delivery del2
             SET del2.reminderdate = v_date,
                 del2.remindertext = :p212_description
           WHERE ROWID = x.ROWID;
       END LOOP;
       COMMIT;
    END;and it will work for you.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • I have few PDf files on my computer and I want to add them to my ipod touch, please tell me the procedure on how should I do that? Secondly I want to run these Pdf files through the ibook app, as it also have the Pdf file sections

    I have few PDf files on my computer and I want to add them to my ipod touch, please tell me the procedure on how should I do that? Secondly I want to run these Pdf files through the ibook app, as it also have the Pdf file sections

    You should be able to just place them in your Books library in iTunes and check to ensure that your Book library is configured to sync to your iPod when you sync your iPod to iTunes.

  • With every second or third file I want to export I get the remark "Not enough memory"

    After I have edited an image in Lightroom CC I always export my files to an external hard drive. Lately I get the remark "Not enough memory with every second or third file. Sometimes even with the first file I want to export.
    My RAM memory is 4.00 GB and I stil have 3.25 GB available. I have cleaned my C-drive. When I look at the specifications of LR CC I see that there is a fysical memory available of 719 MB, but LR is using more than that, so it is probably using virtual memory. Could that be the problem and how do I solve the problem.
    I never have any of this problem with other software.

    I have LR 5.3 installed on 2 partitions on the same PC and same HD:
    Partition 1 has Win 7 32bit 4GB RAM
    Partition 2 has Win 7 64bit 8GB RAM
    On the 32bit partition, now that I am using larger raw files from a Nikon D610, I find LR  not fit for purpose. I get numerous problems while editing and also get "Not enough memory" when exporting.
    On the 64bit partition, everything works as should.
    AS I've said before: With image files getting increasingly larger, Adobe are way too optimistic, and dare I say - disingenuous, when stating in their System Requirements: "2GB of RAM (4GB recommended)". This can only lead to dissatisfied customers.
    So, as dj_paige says: "The best solution, almost guaranteed to work, is to have both a 64 bit operating system AND 8 GB or more of memory. Upgrading only one or the other probably won't work, you need both."
    Works for me!

  • Updating a JFrame's Background every second

    Hello all,
    What i want to achieve here is very simple, I have a class which extends JFrame. In my constructor, i create my GUI (background and buttons etc.), so here is my code :
    //other imports goes here
    public class TestBg extends JFrame implements ActionListener{
         //constructor
         public TestBg(){
              //.. other codes go in here
              //set the first background
              setContentPane(getImage());
              //create a timer which is invoked every second
              Timer timer = new Timer(1000,this);
              timer.start();
         //close constructor
         public void actionPerformed(ActionEvent e){
              //print a statement to see if method is invoked
              System.out.println("Method invoked");
              setContentPane(getImage());
    }//close classlets say the method getImage() returns a JLabel, which set it to the JFrame's background.
    The actionPerformed method is invoked every second, but the background isn't changing ( getImage() returns a different JLabel each time)
    what extra code do i have to add ? thanks.
    NOTE : I just discovered something, i think the JFrame needs to be repainted. Because whenever i resize the Frame, the background changes!, but i do not know how to 'referesh' the JFrame without resizing it.
    Message was edited by:
    TrAnScEnD3nT
    Message was edited by:
    TrAnScEnD3nT

    That's because You add them to container that is an original content pane. Then when You call setContentPane this container is thrown away with all it's content and new "empty" container is put in that place.
    I advise using a JPanel as a contentPane and don't change it on the run. Insted you can use the timer to repaint that panel with some image specified.

  • How do I get the 5.7 LR update?  Every time I click on the download button, the splash screen trying to sell me the cloud stuff pops up.  I don't want to buy anything, I just want to download the update.  Anyone know how?

    How do I get the 5.7 LR update?  Every time I click on the download button, the splash screen trying to sell me the cloud stuff pops up.  I don't want to buy anything, I just want to download the update.  Anyone know how?

    Hi Don. You can find it here:  Product updates

  • Page numbering every second page

    Hi guys,
    ok I have a 200 page booklet I'm doing, very simple - a notes page on the left hand side and then the contacts details on the right. But in the top right corner I need a page number that correlates with the contact. Problem is if I make page numbers it'll have them as 24, 26, 28 etc when that's not what I want.
    Is there a way to skip a page and just page number every second page?
    Thanks for any help,
    Dave

    It isn't entirely clear, but are we dealing with one person's contact info per page, or many? Sounds like 1.
    If it is, as I mentioned in your other thread, you could set this up as a Data Merge project. Create a two-page template spread, Add whatever you need for the notes page to the left page, and put all of your data fields on the right. You can include a number as one of the fields and palce it anywhere you want. This will only work with one record per page, though.
    If you'd rather number pages after the fact, it's probably scriptable to do something with starting a new section every second page and assign the numbers, or you could just add a master frame to the master page and place a number list, which is pretty simple.
    None of these techniques is truly automatic in the sense of updating if things are added or deleted, or if pages are rearranged. Any numbering outside the merge whould be done as the last step.

  • Outputting a data point every second

    I want to output a data point every second to an excel sheet. I got it so that it only outputs one accumlated data point. Each data point includes a timestamp, rate, and volume.
    Attached is my VI.
    Solved!
    Go to Solution.
    Attachments:
    PumpDriver Test 4.vi ‏82 KB

    Mike227 wrote:
    Hey Ravens,
    It never worked...the status isn't even updating which leads me to think that I am getting an error and not clearing it?
    If you post the code, we might be able to help you figure it out.  And errors happen for a reason.  Are you actually getting an error?  If so, what is the error?
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Why firefox freezes every second momentarily while loading webpages?

    Firefox freezes momentarily every second while loading pages and it is not smooth like other browsers out there..I'm facing this problem at home, office, etc with every stable/beta/developer versions!!! I've did all sort of troubleshooting procedures like reset, deinstall/reinstall, safe mode, etc. I'm facing this issue since the time i'm using this browser. Till now i'm with the hope that this issue will be cleared in the updated version!! But not!!
    To be brief, Firefox is not smooth like other browsers! Try to give me a solution to fix this issue! Else pls give me a statement that firefox is not capable of loading pages smoothly like chrome, opera, etc.. I'll happily uninstall this and use other browsers!!

    Hello,
    The Refresh feature (called "Reset" in older Firefox versions) can fix many issues by restoring Firefox to its factory default state while saving your bookmarks, history, passwords, cookies, and other essential information.
    '''''Note:''' When you use this feature, you will lose any extensions, toolbar customizations, and some preferences.'' See the [[Refresh Firefox - reset add-ons and settings]] article for more information.
    To Refresh Firefox:
    # Open the Troubleshooting Information page using one of these methods:
    #*Click the menu button [[Image:New Fx Menu]], click help [[Image:Help-29]] and select ''Troubleshooting Information''. A new tab containing your troubleshooting information should open.
    #*If you're unable to access the Help menu, type '''about:support''' in your address bar to bring up the Troubleshooting Information page.
    #At the top right corner of the page, you should see a button that says "Refresh Firefox" ("Reset Firefox" in older Firefox versions). Click on it.
    #Firefox will close. After the refresh process is completed, Firefox will show a window with the information that is imported.
    #Click Finish and Firefox will reopen.
    Did this fix the problem? Please report back to us!
    Thank you.

  • Every second G-note is missed by Logic Express

    Hi,
    I have really strange problem: logic express misses every second G-note (two octaves down from middle-C) that I press from MIDI-keyboard. It also misses all G-notes if I press something before the G-note.
    This is not a keyboard problem: I have found same issue with two different keyboards and three different USB-midi-inputs. Neither it's hardware problem, I can switch octave from keyboard and it still happends. When I try "test midi" from OS X, I hear every note coming in to my mac, but every second G-note is missed by Logic. It's clearly something inside Logic Express since OS X receives the notes from keyboards all the time.
    I have newest update for Logic Express and all OS X updates up to date.
    Any ideas?

    Hi there,
    Just to make sure, download this:
    http://www.snoize.com/MIDIMonitor/
    Then check on the keyboard to make sure that it's producing what you expect.
    Next, have you reassigned that key to a Logic Express key command? Or perhaps to another programme somewhere?
    You could always try reseting the key commands, assuming you haven't set up lots of custom ones.
    Open up the Environment (Command-8) and look at the the Clicks and Ports layer. There's a diagnostic tool in there that shows you what notes are coming in to Logic. That doesn't necessarily means what notes are going to the sequencer since you can filter notes out in the environment.
    I'd also have a look at the Transform Window to see whether there's something wrong in that.
    Sorry not to give you detailed instructions for all of these different actions - this post would be pages long so have a look in the manual and see if you can't figure out some of these advanced functions.
    Pete

Maybe you are looking for