Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1110

somehow listening for "ed

From "raven" <raven@THRWHITE.remove-dii-this>
Subject somehow listening for "ed
Message-ID <esf0ci$ofp$1@atlantis.news.tpi.pl> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:31 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Hello

What is the most "correct" way for listening for "editing of cell (x,y) has finished" in JTable.
Optimally I would like something like that
(fake code begins:)
jTable1.addCellEditingStatusListener ( new CellEditingStatusListener() {
        public void cellEditingFinished(CellEditingEvent evt) {
                int row = evt.getRow();
                int column = evt.getColumn();
                Object newValue = evt.GetNewValue();
        }
        // (...)
}

(end of fake code)

I haven't found any similar way. The situation seems weird to me. Any comments on that?


However I'm aware of other possible ways:
*** 1. extend JTable/JXTable and override method public void editingStopped(ChangeEvent e) with code
that would fire the aforementioned (yet to be created) "cellEditingFinished" event
*** 2. do the listening on the "table model side" (as opposed to the "GUI" (not-model) side)
*** 3. something like this but i didn't figure out how to get cell coordinates of the just-edited cell

cellEditor.addCellEditorListener(new CellEditorListener() {
        public void editingCanceled(ChangeEvent e) {
        }
        public void editingStopped(ChangeEvent e) {
                JOptionPane.showMessageDialog(null,"column: "+jXTable1.getEditingColumn()); 
                // shows -1 ! so this approach doesn't seem to be useful for what i'm trying to achieve
        };
});
*** 4. something like this but i didn't figure out how to get cell coordinates  of the just-edited cell

jXTable1.addPropertyChangeListener("tableCellEditor", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
                //..

TIA for replies

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread


Thread

somehow listening for "ed "raven" <raven@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000

csiph-web