JSpinner in JTable: commit edit

Hi all,
I have a JSpinner in a JTable, with corresponding renderer and editor.
All works good, but now I want that when the user changes the value of the spinner this change is immediately committed (and not only when the user goes to another cell in the table)
Any suggestions? Thx a lot

To get better help sooner, post a SSCCE that clearly demonstrates your problem.
Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
db

Similar Messages

  • Plz tell me how to use JSpinner with JTable

    I have retrieve records from database but as the number of records(rows) are more than 1000 , i want to use JSpinner with JTable . plz solve my problem by giving the appropriate code for the same.

    hi
    check this links
    http://www.exampledepot.com/egs/javax.swing.table/CustRend.html
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    hope this will help you.. this explains exactly what you want.
    regards
    Aniruddha

  • Use JSpinner with JTable

    I have retrieve records from database but as the number of records(rows) are more than 1000 , i want to use JSpinner with JTable. How can i do so?

    you can start by being more clear on what your requirements are.

  • JSpinner inside JTable

    I implemented a JTable where a Column is of 'type' JSpinner. I have a class
    SpinnerRenderer implements TableCellRenderer to implement JSpinner rendering in the cell
    and a class
    SpinnerCellEditor extends       AbstractCellEditor
                                   implements   TableCellEditor to return a JSpinner to edit.
    Note: both classes return proper JSpinner located in a global Vector
    without creating a new one each time.
    My problem is where to place the fireEditingStopped method of SpinnerCellEditor as some JSpinner remains
    active, no more linked to the JTable rendering and repainted without rigth context.
    Any suggestion would be really welcome.
    Thanks
    jjmoka

    Try these:
    http://www.mail-archive.com/[email protected]/msg01181.html
    http://javaalmanac.com/egs/javax.swing.table/Spinner.html?l=rel
    and/or, Google for "jspinner jtable"
    Jamie

  • JTable cell edits return to original values

    Hi
    I am making some progress with using AbstractTableModel, however I have a problem whereby any edits that I make to cells within the table are being lost when I add a new row��the original values are re-appearing.
    I have searched through the forum looking for a solution but with no success thus far.
    I believe that the solution lies with the fireTableDataChanged() method but thus far I have had no success. My problem (I believe) is that I cannot work out how to fire it when a user leaves the newly edited cell.
    The method that adds the new rows is shown below and is called from a button on the Frame that houses the jTable. I have tried firing the method from here, hoping that all table edits will persist, but unfortunately they still disappear.
    public void fillTable()
            if(c > 0)
                for (int i = 0; i < c; i = i + 1)
                    this.setValueAt(((JobItemClass) items.get(i)).getItemNumber(), i, 0);
                    this.setValueAt(((JobItemClass) items.get(i)).getDescription(), i, 1);
                    this.setValueAt(((JobItemClass) items.get(i)).getCostPerItem(), i, 2);
                    this.setValueAt(((JobItemClass) items.get(i)).getQuantity(), i, 3);
        public void addRow()
            newItem = new JobItemClass();   //Create an object to hold the new row defsault values
            newItem.setItemNumber(c + 1);
            newItem.setDescription("");
            newItem.setCostPerItem(0.0);
            newItem.setQuantity(0);
            items.add(c, newItem);          //Add the default object to the array
            c = c + 1;                      //Update the variable holding the array size
            table = new Object[c][4];       //Increase the size of the object that acts as the table
            fireTableRowsInserted(c, c);    //Alert the object acting as the table that there is a new row
            fillTable();                    //Refresh the display to reflect the new row default values      
        }As always, any help greatly appreciated
    GB

    Thanks again for the replies people.
    I decided to edit this message and post updated code which can be seen below. This is a result of re-reading the helpfull advice from both azukov and camickr who took the time to respond to my initial request for help. I still have to work out how to validate user input but am sure that the tableChanged method will be the key.
    A simple tutorial also provided great assistance, especially helping eith the implementation of the TableModelListener. I have provided a link to the tutorial here:
    http://www.javalobby.org/articles/jtable/
    The coding was carried out in netbeans 5.5, libraries have not been included.
    Here is my updated code......table model first:
    public class MyJobItemTableModel extends AbstractTableModel
        JobItemClass newItem;   //Procides a default record when nothing available
        int jobNo;
        int c;
        ArrayList items;        //Stores the objects that provide the records
        public MyJobItemTableModel(int j)
            jobNo = j;
            items = (new JobAllItems(jobNo)).getItems();
            c = items.size();
        String columnName[] = { "Item Number", "Item Description", "Cost per item", "Quantity" };       
        Class columnType[] = { Integer.class, String.class, Double.class, Integer.class };
        /**************************This method probably now redundant************************
        public void storeCellValue(int row, int col)
            if(col == 0)
                ((JobItemClass) items.get(row)).setItemNumber((Integer) this.getValueAt(row, col));
            if(col == 1)
                ((JobItemClass) items.get(row)).setDescription((String) this.getValueAt(row, col));
            if(col == 2)
                ((JobItemClass) items.get(row)).setCostPerItem((Double) this.getValueAt(row, col));
            if(col == 3)
                ((JobItemClass) items.get(row)).setQuantity((Integer) this.getValueAt(row, col));
        public void addRow()
            c = c + 1;                          //Update the variable holding the array size
            newItem = new JobItemClass();       //Create a default object to fill the new row
            newItem.setItemNumber(c);
            newItem.setDescription("");
            newItem.setCostPerItem(0.0);
            newItem.setQuantity(0);
            items.add(c-1, newItem);
            this.fireTableRowsInserted(c, c);   //Update the display to show the added row.
        public int getColumnCount()
            return 4;
        public int getRowCount()
            return items.size();
        public Object getValueAt(int r, int c)
            JobItemClass jic = (JobItemClass) items.get(r);
            switch(c)
                case 0:
                    return jic.getItemNumber();
                case 1:
                    return jic.getDescription();
                case 2:
                    return jic.getCostPerItem();
                case 3:
                    return jic.getQuantity();
                default:
                    return new Object();               
        public String getColumnName(int column)
            return columnName[column];
        public Class getColumnClass(int c)
            return columnType[c];
        public boolean hasNoItems()
            if(items.size() == 0)
                return true;
            else
                return false;
        public boolean isCellEditable(int r, int c)
            return true;
        public void setValueAt(Object aValue, int r, int c)
            JobItemClass jic = (JobItemClass) items.get(r);
            switch(c)
                case 0:
                    jic.setItemNumber((Integer)aValue);
                    break;
                case 1:
                    jic.setDescription((String)aValue);
                    break;
                case 2:
                    jic.setCostPerItem((Double)aValue);
                    break;
                case 3:
                    jic.setQuantity((Integer)aValue);
                    break;              
            fireTableCellUpdated(r, c);
    }......and now the view (what the user sees)
    public class ViewItems extends javax.swing.JPanel
        protected MyJobItemTableModel myModel;
        /** Creates new form ViewItems */
        public ViewItems()
            initComponents();
        public void createTable(int jobNo)
            myModel = new MyJobItemTableModel(jobNo);
            myModel.addTableModelListener(new ViewItems.ViewItemsTableModelListener());
            jTable1.setModel(myModel);
            //jTable1.setSurrendersFocusOnKeystroke(true);  //not sure what this does
            if (myModel.hasNoItems())
                myModel.addRow();          
            public void run(int jobNo)
                createTable(jobNo);
                try
                    UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                    JFrame frame = new JFrame("Invoice Breakdown");
                    frame.addWindowListener(new WindowAdapter()
                        public void windowClosing(WindowEvent evt)
                            setVisible(false);
                    frame.getContentPane().add(this);
                    frame.pack();
                    frame.setVisible(true);
                catch (Exception e)
                    e.printStackTrace();
            /**This class is required in order to respond to any changes that happen
             * to the table or data within, i.e. the user editing data in a cell.
             * The tablemodel (MyJobItemTableModel) will 'fire' the event and the
             * tableChanged() method will be executed.
            public class ViewItemsTableModelListener implements TableModelListener
                public void tableChanged(TableModelEvent evt)
                    if (evt.getType() == TableModelEvent.UPDATE)
                        int column = evt.getColumn();
                        int row = evt.getFirstRow();
                        System.out.println("row: " + row + " column: " + column);
                        jTable1.setColumnSelectionInterval(column + 1, column + 1);
                        jTable1.setRowSelectionInterval(row, row);
            /** This method is called from within the constructor to
             * initialize the form.
             * WARNING: Do NOT modify this code. The content of this method is
             * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents()
            jScrollPane1 = new javax.swing.JScrollPane();
            jTable1 = new javax.swing.JTable();
            btnAddItem = new javax.swing.JButton();
            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][]
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null}
                new String []
                    "Title 1", "Title 2", "Title 3", "Title 4"
            jScrollPane1.setViewportView(jTable1);
            btnAddItem.setText("Add Item");
            btnAddItem.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnAddItemActionPerformed(evt);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
                            .addContainerGap())
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                            .add(btnAddItem)
                            .add(264, 264, 264))))
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(49, 49, 49)
                    .add(btnAddItem)
                    .addContainerGap(54, Short.MAX_VALUE))
        }// </editor-fold>                       
        private void btnAddItemActionPerformed(java.awt.event.ActionEvent evt)                                          
            ViewItems.this.myModel.addRow();
        // Variables declaration - do not modify                    
        private javax.swing.JButton btnAddItem;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTable jTable1;
        // End of variables declaration                  
        }Edited by: greenockboy on Oct 15, 2007 8:17 PM

  • How to set JTable cell editable/non-editable dynamically using NetBean?

    I am using NetBean 6.5, create a database desktop application, I using the persistence entity manager to bind my JTable with database.
    Now, I want to set practicular cells which are enable and disable, I tried to create my own table model and override the isEditable() method, which it seems didn't work. I guessed the problem is the persistence connection between my Table and database.
    How can I solve it? Any example? I just googled the web and can't find example which use netbean combined with database. I know that a single JTable would work when creating your own model.
    thx.

    I know what coding i did, Yes u r right but im new to GUI programming only,
    That's why i posted it to forums, I gone through the Control Flow Statements link what u have given.
    U didnt get my question at all.
    Again the problem im facing is the table is already displayed with 2nd column uneditable.
    When some Action done on table, i need to make 2nd column editable at run time.
    Thanks if u provide me the solution instead of deciding what type of programmer im.

  • Initialize Jtable in Edit Mode without clicking mouse

    I am writing an inventory software where I need JTable to start in edit mode in my invoicing dialogue.
    Here is the code I tried (which is not working):
    ProductsGrid.setRowSelectionInterval(0, 0);
    ProductsGrid.setColumnSelectionInterval(0,0);
    ProductsGrid.setEditingRow(0);
    ProductsGrid.editCellAt(0, 0);
    ProductsGrid.getEditorComponent().requestFocus();
    Additionally, I would like the newly added row to be in edit mode, after I select and add a product from a pop-up dialogue.
    Any ideas
    Thanks

    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.
    Maybe this posting will help:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=640471

  • Escape key in jtable while editing

    I am trying to unregister the escape key from the jtable when it is in an editing mode. The field in an editable mode is a JTextField. I tried:
    this.getInputMap().remove(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));I also tried removing it from the JTextField in MyCellEditorObject (which extends DefaultCellEditor)
    But the escape key does not seem to be in either of these components when I do:
    KeyStroke[] ks = this.getInputMap().allKeys();
    if(null == ks)
        System.out.println("null ks........................");
    else
        for (int i = 0; i < ks.length; i++)
            System.out.println(ks.toString());
    Once I get this figured out I need to add and remove other keys to whatever object is handling the events.
    Does anyone know what object is handling the escape key in the JTable while it is in an editing state using a JTextField?

    Well, for others who may have the same problem this is what I found so far:
    The jtable.getInputMap() will always return null (hardcoded in BasicTableUI). To get the input map one has to put:
    jtable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
    Then
    KeyStroke[] ks = this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).allKeys();
    returns keys in the input map and the parent input map....(.keys() will exclude the keys in the parent input map).
    For the JTable all the keys are registered in the parent inputMap.
    m_table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent().remove(KeyStroke.getKeyStroke(KeyEvent.VK_ALPHANUMERIC, 0));
    m_tablegetInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent().remove(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false));
    m_table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true), "quitRelease");
    m_table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0), "actionMApKeyObject");
    m_table.getActionMap().put("quitRelease", new QuitAction());
    m_table.getActionMap().put("send", new SendAction());
    private class QuitAction  extends AbstractAction
        public void actionPerformed(ActionEvent ae)
           //do quit cellediting stopped? yes then press quit btn no thenstop ...
    private class SendAction  extends AbstractAction
        public void actionPerformed(ActionEvent ae)
           //do send
    }I still would like to know more about the input maps...and the parent input map???
    As well as the ActionMaps all introduced in 1.3.
    Does anyone know of any URLs or books that contain good explanations and samples
    (I have not found any)...
    I am also interested in how this could be applied more globally
    like the enter key pressing all buttons in my application.
    Or having text fields respond to keyReleased rather than pressed.

  • JTable with editable JComboBoxes

    For some reason once I added editable JComboBoxes to a JTable I can no longer tab among the fields in the table. If I just select a cell, I can tab to the other cells in that row, and then to proceeding rows as I reach the end of each. However if I double click the cell and enter data or select from the combobox. I no longer can tab to the next cell. At that point once I do hit tab, I am taken to the next table. Not the next cell in the row, or the next row in the current table.
    I have tried messing with a bunch of listeners, but I am not using the right listener on the right object? What listerner and object should the listener belong to? Table, model, cell editor, combobox, jpanel, jframe ? I hope this is not to vague.

    Well I am starting to think it's an implementation issue. Like I am not doing it how I should. I am basically doing
    JComboBox jcb = new JComboBox();
    jcb.setEditable(true);
    column.setCellEditor(new DefaultCellEditor(jcb));
    When I think I should be inheriting, and creating my own editor and/or renderer? Now my combobox vars are globally available in the class, so I can set and clear their contents. It does not matter that each row in the table has the same content in the combo boxes, that's basically what I want. User to be able to select an existing entry or make a new one.
    What I am trying to do is on tables have a drop down box that shows up when a user types a matching entry. If no entry matches, no popup box. If entry matches, box pops up and shows possible entries starting with what they are typing. Like code completion in IDE's like Netbeans. However I am doing this in a table. I thought a JComboBox would be a good widget to start with?

  • JTable disable editing, row selecion

    hii all,
    i want to disable the cell editing in the JTable and select a complete row.
    i tried with more than a way but faild.

    You have to write a separate CellEditor class with overriding isCellEditable() returning false.
    public class MyTableCellEditor extends DefaultCellEditor
    public MyTableCellEditor (JTextField textField)
    super(textField);
    public boolean isCellEditable(EventObject e)
    return false;
    public boolean shouldSelectCell()
    return true;
    and then get the TableColumn object, say tcm,of the JTable's Column.
    And then tcm.setCellEditor(new MyCellEditor(new JTextField())) to an instance of the above CellEditor class.
    And also call JTable methods as setRowSelectionEnabled(true) etc..

  • How to know a JTable is editing?

    Hi all,
    how can I test if a JTable's cell is open for editing? I've tried the isEditing() method, but this method just tests if is the table has a CellEditor.
    Any other ideas?

    <h2>This was the original post</h2>
    jan_kauffman wrote:
    Hi all,
    how can I test if a JTable's cell is open for editing? I've tried the isEditing() method, but this method just tests if is the table has a CellEditor.
    Any other ideas?db

  • Start or stop edit jtable cell editing

    Hello,
    I got a problem with the jtable DefaultModel isCellEditable.
    If I set the IsCellEditable to false, I would not be able to enable the cell selection as and when I want it.
    What I have in mind is the add a mouselister so that if the user select a row using fast left mouse click like the procedure shown below
    private class MouseClickHandler extends MouseAdapter {
    public void mouseClicked(MouseEvent event) {
    int no_mouseclick = 0;
    no_mouseclick = event.getClickCount();
    if (no_mouseclick >= 2) {
    int cur_row = 0;
    cur_row = table.getSelectedRow();
    // table.setColumnSelectionAllowed(true);
    // table.setRowSelectionAllowed(true);
    for (int i=0;i<table.getColumnCount();i++){
    table.editCellAt(cur_row,i);
    System.out.println("mouse row--->" + cur_row);
    I could overwrite the IsCellEditable to true to enable that particular or cell contains in that row to be able to accept input and overwrite any data which in my case obtained from the Sql database a sort of like input module using tabulation . I am also thinking of using text component or combobox to display the value for user selection , but I do not know how to enable a particular cell for editing if the Jtable created is using a non-editable DefaultModel. If I set the IsCellEditable to true, every single cell would be enable for editing , and this defeat the purpose of enable user input only upon double mouseclicks.
    By the way , I am interested to know how to track the data changes in the cell within the jtable so that only those have been modified are notify from the Table model and updated into the Sql table
    Could anyone of you out there provide some hints please
    Thanks

    Hello,
    Tablemodellistener could detect the changes in the data, how about the backend database updating and transactional activity that must be associated with the data changes?
    What is on my mind is that , the moment there is changes in the data detected by the TableModellistener, whatever records associated with or brougt up by Jtable would be all deleted from the database and then follow by the new set of new records to be inserted into the database. The disadvantage of this method is that everytime the backend database connection and activity need to be executed the moment there is a change in the data in the jtable cell. For example the user may be just amendment to only one cell , but all the records associated need to be deleted and then inserted again.
    Perhaps there are better solution to deal with Jtable and JDBC backend connection where in this case, I am using JDO to undertake the database activity like the observable modelling .
    Could someone provide the hint please
    Thank

  • Setting color of an item in a Jcombobox in a JTable when editing

    Hello,
    I have a situation where I have a JCombobox in a JTable . The JCombobox is non-editable. The items within the combobox are colored in pink or blue in order to help the user differentiate between the two categories that are in the list.
    But the problem is that when the user is on that cell and is just typing the first letter(s) in the combobox, he does see the item starting with that letter(s) but that item is not shown as colored. However, if the user clicks on the combobox with a mouse, the list pops-up and the items are shown as colored. I want the first part to work where the user can just use keyboard and see the items as colored in that cell itself. By default, currently when the row is selected the foreground is white and background is black. I want that particularly when this combobox has focus and an item is selected, the foreground should be of the same color as the color of the item.
    Can someone help?
    Thanks a lot in advance.

    Additional information on above:
    I associate a customized renderer with the column of my table for which i want to set the colors.
    TableColumn tc6 = jTableDRS.getColumnModel().getColumn(myDRSModel.FINANCECODE_COLUMN);
    tc6.setCellRenderer(new ColorRenderer());
    here is the renderer that I am using...
    public class ColorRenderer extends JLabel implements TableCellRenderer {
    protected Border noFocusBorder;
    public ColorRenderer() {
    noFocusBorder = new EmptyBorder(1, 2, 1, 2);
    setOpaque(true);
    setBorder(noFocusBorder);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    Color foreground = null;
    Color background = null;
    Font font = null;
    if(column == myDRSModel.FINANCECODE_COLUMN)
    setFont((font != null) ? font : table.getFont());
    String str = (String)value.toString();
    if (!str.equalsIgnoreCase("SELECT ONE")) {
    int y = financedesc.indexOf(str);
    if((payreceiveind.get(y).toString()).equals("R")){
    setForeground(Color.RED);
    } else if((payreceiveind.get(y).toString()).equals("P")){
    setForeground(new Color(147,112,240));
    if(isSelected)
    if((payreceiveind.get(y).toString()).equals("R")){
    setForeground(Color.RED);
    } else if((payreceiveind.get(y).toString()).equals("P")){
    setForeground(new Color(147,112,240));
    setBackground(table.getSelectionBackground());
    else{
    setBackground(table.getBackground());
    else
    if(isSelected)
    setForeground(table.getSelectionForeground());
    setBackground(table.getSelectionBackground());
    else
    setForeground(table.getForeground());
    setBackground(table.getBackground());
    setValue(value);
    return this;
    protected void setValue(Object value) {
    setText((value == null) ? "" : value.toString());
    }

  • JTable starts editing when F3 is pressed - howto disable?

    Hi,
    I would like to add some shortcuts to my application (F3, F4, F5, ...), however when the JTable has focus and JTable's cursor is on a editable cell, it starts the editing process.
    Is there a way to tell the JTable to "ignore" some keys?
    Thank you in advance, Clemens

    It behaves differently because it tries to pass key strokes to the editor and overrides processKeyBinding to that end. Try:
    import java.awt.EventQueue;
    import java.awt.event.KeyEvent;
    import java.util.EventObject;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    public class TestJTable {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JTable table = new JTable(new DefaultTableModel(1, 1)) {
                        @Override
                        public boolean editCellAt(int row, int column, EventObject e) {
                            if (e instanceof KeyEvent) {
                                int code = ((KeyEvent) e).getKeyCode();
                                int start = KeyEvent.VK_F1;
                                int end = KeyEvent.VK_F21;
                                if (code != KeyEvent.VK_F2
                                        && code >= start && code <= end) {
                                    return false;
                            return super.editCellAt(row, column, e);
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().add(new JScrollPane(table));
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    }Actually JTable does check if the key press triggers an action, but that means it only works if you install the key binding on the table input map with WHEN_ANCESTOR_OF_FOCUSED_COMPONENT.

  • JTable & Cell editing

    Hi,
    I am using JTable and facing following problem. My UI has a JTable and JButton with mnemonic set. The button populates the date into the table. Here is the sequence
    1) Enter into editing mode by pressing F2 and enter value EE
    2) I press the mnemonic set for button
    3) ActionListener attached to button is executed. This ActionListener populates the data into the table.
    4) The cell on which editing was started remains in the editing mode and the value for edited cell does not change to the populated by ActionListener but remains EE. (This is the problem)
    What i want is whenever focus moves out of the table if the table is in editing mode then it should cancel the editing.
    I tried attaching the focus listener but problem with this is focusLost is fired even when i press F2 i.e. start editing.
    Any help will be of great use
    Thanks in advance
    Sachin

    Hi,
    It works in normal scenaios. I faced problem in following
    1) My cell editor has a verifier attached. if i show a dialog box from verify method and then return false from method focus remains in cell only, this is fine.
    2) If i show the dialog and return true from verify method, table remains in editing mode and focus gets transferred to the field. This time i am navigating through mouse.
    3) In the same scenario (2) if i tab out of the field cell does not come out of edit mode i have to press tab to come out of the field.
    Any idea??
    Sachin

Maybe you are looking for

  • Reports Query Doubt??

    hi all, Thanks to ALL the replies to my query. I have a doubt in Oracle reports. This is the query in the format trigger. ctr,cnt - are summary columns in the group above which counts the detail group I have to retrieve the records for status codes e

  • Anybody know of a cheap MTC-syncable Quicktime player?

    I've decided to offload my video playback to a second machine, and am looking for something that will play back a Quicktime movie synced to MTC, with the ability to adjust the size of the movie. Pro Tools is close, but the movie only fills about 1/4

  • Import previews doesn't work

    Hello, I'm using Lightroom v2.4 and Camera RAW v5.4. I have a Canon EOS 30D and Windows XP SP3, but Lightroom fails to display any import previews at all. The photos are just not displayed.Please see attached image I can view and edit the photos in L

  • Trial install fails on Vista 64

    I wonder if anyone can help me? I was going to buy Premiere Pro as it is highly recommended by our media folk, but now am not sure. I can't get the trial version to install on Vista 64; the only message is "Setup has encountered an error. Contact pro

  • CRM - Role of technical resource

    Hi Experts, I would like to know what role technical (development) resource expected to play in CRM projects. I am from ABAP, XI & EP background, would like to work on CRM projects in future. I would appreciate if you have spell out skills which are