Problem with TableModelListener - it's just not working

Hi all - I have a TableModelListener like the one bellow but when I edit data in the table and press enter nothing happens - I'm guessing I'm doing something wrong but I can't work out what - has anyone got any ideas?
teamManageTable.getModel().addTableModelListener( new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                int row = e.getFirstRow();
                int column = e.getColumn();
                TableModel model = (TableModel)e.getSource();
                String columnName = model.getColumnName(column);
                Object data = model.getValueAt(row, column);
                // Do something with the data...
                System.out.println("hi");
        });Thanks

Hi there - it took me a while to replicate the problem (I'm not going to post the whole program - too big) - basically it seems that it is only not working once I add data too the table, so I guess I am adding it incorrectly
If you run this and click the add button you will then see that it is not working
* Main.java
* Created on 17 November 2007, 10:55
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package tester;
* @author kilps
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.table.TableModel;
public class Main extends JFrame {
    JScrollPane teamManageScrollPane = new javax.swing.JScrollPane();
    JTable teamManageTable = new javax.swing.JTable();
    JLabel addTeamLabel = new javax.swing.JLabel("Add a new team: ");
    JLabel addTeamNameLabel = new javax.swing.JLabel("Name: ");
    JTextField addTeamName = new javax.swing.JTextField();
    JLabel addTeamContactNumberLabel = new javax.swing.JLabel("Contact Number: ");
    JTextField addTeamContactNumber = new javax.swing.JTextField();
    JLabel addTeamContactEmailLabel = new javax.swing.JLabel("Contact Email: ");
    JTextField addTeamContactEmail = new javax.swing.JTextField();
    JLabel addTeamOtherInfoLabel = new javax.swing.JLabel("Other Info: ");
    JScrollPane addTeamOtherInfo = new javax.swing.JScrollPane();
    JTextArea addTeamOtherInfoBox = new javax.swing.JTextArea(5,20);
    JButton addTeamSubmit = new javax.swing.JButton("Submit New Team");
    String [] tableHeader = new String[] {"Team Name", "Contact Number", "Contact Email","Other Info"};//table header
    /** Creates a new instance of Main */
    public Main() {
        method();
    public void method() {
        teamManageTable.setModel(new javax.swing.table.DefaultTableModel(new String[][] {{"some","data"},{"some","more"}},new String[] {"1","2"}));
        //object specific stuff
        teamManageScrollPane.setViewportView(teamManageTable);
        addTeamLabel.setFont(new java.awt.Font("Dialog", 1, 14));
        addTeamOtherInfo.setViewportView(addTeamOtherInfoBox);
        //setup window
        JFrame teamsWindow=new JFrame("Manage Teams");
        //fancy layout stuff courtesy netbeans gui builder
        GroupLayout layout = new javax.swing.GroupLayout(teamsWindow.getContentPane());
        teamsWindow.getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(addTeamLabel)
                .addGroup(layout.createSequentialGroup()
                .addComponent(addTeamNameLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addTeamName, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createSequentialGroup()
                .addComponent(addTeamContactNumberLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addTeamContactNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createSequentialGroup()
                .addComponent(addTeamContactEmailLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addTeamContactEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createSequentialGroup()
                .addComponent(addTeamOtherInfoLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addTeamOtherInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addComponent(teamManageScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(addTeamSubmit))
                .addContainerGap(20, Short.MAX_VALUE))
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(teamManageScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addTeamLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(addTeamNameLabel)
                .addComponent(addTeamName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(addTeamContactNumberLabel)
                .addComponent(addTeamContactNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(addTeamContactEmailLabel)
                .addComponent(addTeamContactEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(addTeamOtherInfoLabel)
                .addComponent(addTeamOtherInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addTeamSubmit)
                .addContainerGap(28, Short.MAX_VALUE))
        teamsWindow.pack();
        teamsWindow.setVisible(true);
        addTeamSubmit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //first do fancy check so we have a dynamic array type thing
                 teamManageTable.setModel(new javax.swing.table.DefaultTableModel(new String[][] {{"some","data"},{"some","more"},{"even","more"}},new String[] {"1","2"}));
        teamsWindow.addWindowListener(new WindowListener() {
            public void windowClosed(WindowEvent arg0) {}
            public void windowActivated(WindowEvent arg0) {}
            public void windowClosing(WindowEvent arg0) {
                //on close
            public void windowDeactivated(WindowEvent arg0) {}
            public void windowDeiconified(WindowEvent arg0) { }
            public void windowIconified(WindowEvent arg0) {}
            public void windowOpened(WindowEvent arg0) {}
        teamManageTable.getModel().addTableModelListener( new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                int row = e.getFirstRow();
                int column = e.getColumn();
                TableModel model = (TableModel)e.getSource();
                String columnName = model.getColumnName(column);
                Object data = model.getValueAt(row, column);
                // Do something with the data...
                System.out.println("hi");
     * @param args the command line arguments
    public static void main(String[] args) {
        // TODO code application logic here
        new Main();
}thanks

Similar Messages

  • HT1222 hello i have a problem with my fingerprint id its not working anymore like before his not recognised my finger anymore why ?

    hello i have a problem with my fingerprint id its not working anymore like before his not recognised my finger anymore why ?

    I have had to periodically delete and re-enter my fingerprint. The last update (7.1) may have improved that. You can delete by going to Settings > Touch ID & Passcode, enter your passcode and then tap "Turn Passcode Off" and then go back to the same area, put a passcode back on and then a fingerprint.

  • A problem with a timer event sometimes not working

    Guys...
    I have this problem:
    I have a child added to the stage eacg 5 seconds and if this child still on the stage after another 5 seconds, you go to the next frame...
    My problem is that sometimes it does not work, meaning that you can have this child on the stage for ever and nothing will happen... but sometimes it does work properlly...
    Is there any mistakes in my code or what should I do?
    var miC4:Loader = new Loader();
    miC4.load(new URLRequest("nivel1.jpg"));
    addChild(background1);
    background1.addChild(miC4);
    if (!lives){var lives:int = 3;}
    var enem1:Loader = new Loader();
    enem1.load(new URLRequest("1enemigo.png"));
    var enemy1Array:Array = new Array(enem1);
    var t1:Timer=new Timer(5000,1);
    var t2:Timer=new Timer(10500,1);
    recycleEnemy();
    function removeEnemy(){
               background1.removeChild(enem1);
               recycleEnemy();
    function touchListener(event:MouseEvent){
        enem1.removeEventListener(MouseEvent.CLICK, touchListener);
        removeEnemy();
    function recycleEnemy():void{
            enem1.x=(50 + Math.random() * (stage.stageWidth - 150));
            enem1.y=(50 + Math.random() * (stage.stageHeight + -100));
            t1.addEventListener(TimerEvent.TIMER, addEnemy);
            t1.start();
            t2.addEventListener(TimerEvent.TIMER, bang1);
            t2.start();
    function addEnemy(e:TimerEvent):void {
            background1.addChild(enem1);
            enem1.addEventListener(MouseEvent.CLICK, touchListener);
            enemy1Array.push(enem1);
    function bang1(e:TimerEvent):void {
        if(enem1.stage){
                    lives--;
                    if (lives >= 0) {
                        t1.stop();
                        t2.stop();
                        removeChild(background1);
                        gotoAndStop(5);
    Thanks a lot!!!!

    ok, so there are a number of issues.
    the first error is enemy1Array contains two duplicate objects ~5 seconds after entering that frame.  i'm not sure if that's a problem because i don't see where you're even using enemy1Array, but you should fix that error (if enemy1Array is used) or remove enemy1Array (if it's not used).
    the next problem is you can call recycleEnemy more than once and re-add those timers.  flash will probably protect yourself from the bad coding but you shouldn't count on it.  when you call removeEnemy you should stop those timers and remove those listeners before re-adding another pair of listeners.  or just reset the timers in removeEnemy and start them in recycleEnemy.  there's no need to re-add those listeners more than once.  they could be added in your if(!lives) conditional.
    the next (and probably most important) error is your removeChild(background1) statement which fails to remove enem1. so, when you re-enter that frame you have an enem1 on-stage that you can't kill and can't even reference.  remove it when you remove the background1.

  • My laptop macbook pro has a problem with usb port they are not working.

    hi there i have a late 2011 mac pro, its been 2 years of purhase however reary used, now it has a problem with usb port are drawing too much power and usb ports are dissabled from the system. now i can not use usb ports. do yo have solution for it??? cheers

    Reset SMC.     http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".
    Best.

  • I am having the same problem with my sound, it does not work with my games. I tried the info that was given below

    I tried the suggestion for the sound, but it is not working. the sound will not play for my games, but it does play for all other Apps

    As you don't say what suggestion it is that you've tried, I don't know whether you mean for having notifications muted, so you may already have tried the following.
    Depending on what you've got Settings > General > Use Side Switch To set to (mute or rotation lock), then you can mute notifications by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085

  • Problems with "find nearby missing photos", not working like it should in LR4

    After I imported photos into LR4 I decided to split the event within the same folder creating 2 subfolders and proceeded to move the files within the finder. Went to LR4 and synchronized the folder but it didn't fix the file location on the missing files. So I tried finding individual files and checked the "Find nearby missing photos" but this doesn't seem to work like it did in LR3, because it won't find any nearby missing files even though they are right there new to each other in the same folder.
    I don't want to dremove them and re-import because I have added ratings and I fear I would loose this info if I did that...

    Your assumption that you would loose your ratings and develop settings is correct, if you would re-import.
    Reimporting is never a good idea.
    For the rest you have two alternatives: either you reconnect one image after another, or you undo on OS level what you did in the first place, then execute the move inside LR.
    Depending on how many images you moved this could actually be the fastest route out.
    "Find nearby missing photos" did not work reliably for me either in LR3. I have never found out when it did and when not, so I have preferred to learn how to perform any such operation inside LR.
    Another valid question is why you do not use collections for your desired split , and leave the folders as they were.
    According to my prejudice MAC users would not be as conservative in sticking to folder structures as Windows users..;-))
    Once you master LR folders could be very unimportant storage buckets, as every angle for organizing your images would be covered by (smart) collections and keywords and other metadata.
    Good luck, Cornelia

  • Problem with Nokia N73 -- Camera is not working

    Recently i have purched Nokia N73.
    Some times my camera is not working ,means it's stuck.
    but after some time or after a day it's working fine.
    what is the reason ?
    is there any setting?
    Plz let me know the same.
    Wating for your positive reply ASAP.

    try to upgrade your software
    see this link-> http://europe.nokia.com/softwareupdate

  • Problem with defaultCommand - buttons, links, etc not working

    Hi,
    I've used the defaultCommand attribute on a number of pages in an application, and have noticed a serious problem :
    After hitting enter, if no navigation occurs (i.e. only PPR), nothing on the page works anymore - no buttons, links, etc.
    Is this a known issue? If so, is there a way to fix this?
    Also, if an inputTextField has a f:validateLongRange tag, and the user enters an invalid value (i.e. text, or something out of range), when enter is pressed the entire page disappears, and I'm left with only the validator's error message. I know I could work around this by performing my own validation, but that is less than ideal.
    Any help would be greatly appreciated. Thanks
    Message was edited by:
    lturner

    Hi,
    it does reproduce and I filed a bug. The work around is not to use the "defaultCommand" property as it works when e.g clicking onto the button
    Frank

  • Problem with multi take drum tracks not working with group selection editing

    HI All
    Ive recently tracked drums into using 7 mics and doing multiple takes layered on top of each other, the 7 takes belong to the same group and i have enabled group editing in the settings.
    I think i changed the comp options at the end of the track and as a result audio tracks 1 and 2 edit between takes together fine. I.e. when i choose say take 5 with track it does the same selection for track 2.
    Tracks 3-7 work in the same way fine, im just wondering if anyone knows how to get them as a complete group again so that when i choose take 5 for example on the one audio track, it will make the same selection for all of them!
    thanks

    Colin,
    I did a multi camera edit of Act 1 of a taped performance and all went well. Moved on to Act 2, which ran longer and each camera needed a tape change. So I matched the clips from each camera on each video track and tried to move on to the sync & then create a multi camera sequence stage of the project. That's when I hit a road block. I could not sync the four video tracks. So I consulted Adobe's on line help and this was all I could find about my predicament:
    Note: Adobe Premiere Pro uses an overlay edit when  synchronizing clips. Take care not to overwrite adjacent clips if you have  multiple clips on the same track.
    So what was I to do next? I found your post and now know exactly what to do. Thanks for a great explaination and saving me a lot of head scratching.
    Why couldn't Adobe explain it as well?
    Thanks,
    Angelo

  • Preloader problem with swf in different domains, not working online

    Hello
    I've an swf (loader.swf) hosted in dominioA.com, that justs loads a swf (movie.swf) hosted in dominioB.com.
    loader.swf has a preloader. When I execute the movie in flash, it works perfect, but when I upload the swf, the preloader doesn't works. I see 0% and after starts movie.swf normally.
    Here is the code of loader.swf
    Security.allowDomain("www.dominioB.com");
    Security.allowDomain("www.dominioA.com");
    var contexto:LoaderContext = new LoaderContext();
    contexto.applicationDomain = ApplicationDomain.currentDomain;
    var _preloader:MovieClip=preloader
    _preloader.barra.width=0;
    var _DOM:String="http://www.dominioB.com/movie.swf?anticache="+Math.random();
    var myLoader:Loader=new Loader;
    addChild(myLoader)
    myLoader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadPogress);
    myLoader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
    myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onDataLoad);
    var carga=new URLRequest(_DOM);
    myLoader.load(carga, contexto);
    function onDataLoad(evt:Event) {     
              //inicializar datos
    function onLoadPogress(event:ProgressEvent){
         var cargado:int = event.bytesLoaded;
        var total:int = event.bytesTotal;
        var porcentaje:int = cargado/total*100;
        _preloader.txt.text = "Cargado: "+String(porcentaje)+"%";
        _preloader.barra.width = porcentaje*2;
    function httpStatusHandler(event:HTTPStatusEvent):void {
           if(event.status==404){                    
    function ioErrorHandler(e:IOErrorEvent):void {
    function initHandler(e:Event):void {
    Any idea??
    Regards

    movie.swf load perfect, and everything works. It doesn't seem to be a cross-domain issue.
    In loader.swf, all the actionscript is in the timeline, not in a class.
    Thanks.

  • Problems with iweb and safari - 'buttons' not working in safari/firefox...

    Hello. Help! I've been using iweb for a while with no probs - but on trying to launch my most recent site I'm finding the navigation buttons (graphic images not text buttons) work fine in iweb on my mac, plus fine on a PC but only partially in safari/firefox browsers... see sarahgreen.me and you will see that none of them work on the home page. Is this some kind of bug? I was wondering if it is anything to do with there being too many objects on the page or something? They are fine on a PC.
    Thanks for any ideas.
    Sarah

    In iWeb do Command-Shift-L to see the layout of the page.
    The content in the Navigation layer is blocking the content of the Header layer. The body layer is empty.
    Move ( +Use Command-drag+ ) EVERYTHING in the Navigation layer and EVERYTHING in the Header layer INTO the Body layer.
    Put content where it belongs.
    Message was edited by: Wyodor

  • Windows 10 technical preview problem with lumia 730, wifi is not working and how to rollback to windows 8.1 please help

    I installed windows 10 technical preview on my lumia 730 and now iam facing problem 
    1) unable to connect wifi
    so please help me how to roll back to windows 8.1
    in the forums it was written that if u have windows recovery tool then it is possible , but iam not able to find windows recovery tool.
    Please help me my mail id [email protected]

    so please help me how to roll back to windows 8.1
    http://windows.microsoft.com/en-us/windows/preview-backup-restore

  • Tried to download trail version of CS6 had problems with the instalation primarily - did not work (Windows 7). So deleted all files and re-installed the creative cloud now no apps showing on CC? Please help!

    Downloaded CS6 from the cloud on trial version a few weeks back. During instalation my computer crashed and left it kind of partially installed i think. I deleted the files i could find to try and re-instal. Have managed to get the creative cloud back but when i load it up im not given any options - no apps or home or anything just the shell. Does anyone know whats up or cangive me some advice to get my trial please. Many thanks

    When I try to install trial version now it brings up the cloud but nothing happens. Any ideas? Thankyou

  • Has anybody had problems with the global settings panel not working?

    I am on PC, Vista 64bit.  updated to the new flash player and now flash player will not allow me to chage anything in the global settings panel.  I need to allow third party content for editing wix sites and I cannot change any of the settings.  I have uninstalled and reinstalled many times and nothing has helped.
    My adobe reader also crashed and now will not load after uninstall.  Very frustrating!  Everythign worked fine before the update.
    Any ideas?

    To allow Flash Player settings, close all browser windows, then open Windows Explorer and type %APPDATA%\Adobe in the address bar. Delete the 'Flash Player' folder in there.  Do the same in %APPDATA%\Macromedia
    Regarding Adobe Reader, please post in that forum.

  • Problem with new Iphone 4, mms not working to receive.

    My Iphone 4 is not receiving mms texts, but will send them. Ive checked for updates, made sure all settings are correct and rebooted it. What else can I try before restoring? Its brand new as of 3 days and has never received mms.

    Help here >  iPhone: If you can't send or receive text messages

Maybe you are looking for

  • How to use buttons from a different theme in current theme ?

    Hi Friendsl, I was just wondering how can I have those nice looking buttons from Theme-2(Builder Blue ) use in Theme-13(Classic Blue). I created a copy of theme-2 button template in theme-13 and called it "My Button". Now when I went into the button

  • Calendar's before(Object when) method

    Can anyone shed some light on this subject? Why is it permissible to call cal.before(myTextArea) or cal.after("Hello") ??? The API even defines Object when as a Calendar instance! But this isn't enforced in the method signature! What's most alarming

  • Is there an md5 command in Solaris 11

    Hi All, We have a customer looking for the executable 'md5' command in Solaris11.  Cust has several scripts that has the md5 command hardcoded in their scripts, and would like to use the exact 'md5' command.  I inform them about the built-in /usr/bin

  • New facebook app not rotating on 1st gen iPad?

    Tried reinstalling the new Facebook app, powering the iPad off and on.  Still will not rotate.  Was rotating disabled on the 1st gen iPad? My 3rd gen iPad still rotates.

  • How can i find my restore backup password?

    How can i find my restore backup password?