简体   繁体   中英

JTable listen for entering editing mode

This is a pretty simple question, but I couldn't find an answer nonetheless (please forgive my clumsy searching ...). There's a Jtable with editable cells and I want to detect when a cell is being entered for editing (for instance by double-clicking). How would I do this?

Add a PropertyChangeListener to the JTable :

//
//  Implement the PropertyChangeListener interface
//
    @Override
    public void propertyChange(PropertyChangeEvent e)
    {
        //  A cell has started/stopped editing

        if ("tableCellEditor".equals(e.getPropertyName()))
        {
            if (table.isEditing())
                // code for editing started;
            else
                // code for editing stopped;
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM