How do I get Integer in JTable cell to be selected when edit using keyboard

I have some cells in a JTable, when I double-click on the cell to edit it the current value (if any) is selected and is replaced by any value I enter, which is the behaviour I want. But when I use the keyboard to navigate to the cell and start editing, new values are added to the end of the current value which is not what I want.
I have created my own IntegerCellEditor (see below) and added a focus event or the textfield used when editing to select all the current text but it has no effect, any ideas please ?
public class IntegerCellEditor extends DefaultCellEditor
    public IntegerCellEditor( JTextField textfield )
        super( textfield );    
        //Ensure old value is always selected, when start editing
        ((JTextField)getComponent()).addFocusListener(new FocusAdapter()
                public void focusGained(FocusEvent fe){
                    ((JTextField)getComponent()).selectAll();
        ((JTextField)getComponent()).setHorizontalAlignment(JTextField.RIGHT);
     * Return as Integer (because delegate converts values to Strings).
    public Object getCellEditorValue()
        return Integer.valueOf((String)delegate.getCellEditorValue());
}

But when I use the keyboard to navigate to the cell and start editing,
new values are added to the end of the current value which is not what I want.How does the use know that typing will replace the text and not append? Usually if text is to be deleted, it is highlighted to give the user a visual cue.
Here is a renderer that does this, in case your interested:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=752727

Similar Messages

  • (JTable) How can i get the first columns cell in a selected row?

    Hello. I am trying to figure out how i can get the first columns cell within a selected row no matter what cell is selected in that row. I have a class that extends AbstractTableModel which represents the table. Now i have another class that extends DefaultSelectionModel. Each model is added to the JTable via setModel(TableModel dataModel), setSelectionModel(ListSelectionModel newModel). Now i don't understand what i have to return from getMaxSelectionIndex(). Any ides? Thanks.
      class xTableModel extends AbstractTableModel{
         private static String[] cols;
         private Object[][] data;
            public void setTableModel(Object data[][], String[] cols){
             this.cols = cols;
             this.data = data;
            public String getColumnName(int col){
             return cols[col];
            public int getRowCount() {
             return data.length;
            public Object getValueAt(int row, int col) {
             return data[row][col];           
            public void setValueAt(Object value,int row,int col){
             data[row][col]=value;
            public int getColumnCount(){
             return cols.length;
    class ColumnListenerModel extends DefaultListSelectionModel{
         public int getMaxSelectionIndex(){}

    int row = table.getSelectedRow();
    Object data = table.getValueAt(row, 0);

  • I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the Component and Audio ports on my TV?

    I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the MacBook Pro and connected to the TVs Component and Audio in ports.

    Will not work.  To my knowledge, dual converting like that isn't supported.  The Mac must detect the connected video output device and that sort of info cannot be done across an analog component uni-directional connection.

  • I traded iPads with my daughter. How do I get my iTunes account on this one? When I try to update it wants her information?

    I traded iPads with my daughter. How do I get my iTunes account on this one? When I try to update it wants her iTunes information.

    You can tap on the account in Settings > Store (Settings > iTunes & App Stores if it's on iOS 6) and log out of it and then log in with yours. But if any of the apps that are currently on the iPad were downloaded by her account then only her account will be able to download updates to those apps - content from the store is tied to the account that downloaded it, not to the account that is currently logged in.

  • How can I get my e-mail address associated with Adobe Digital Editions?

    How can I get my e-mail address associated with Adobe Digital Editions?

    gjortega,
    Your sidekick may be relaying through a different server. If its on AT&T, it could be using cwmx.com for outgoing. However, cwmx.com only works for AT&T/Cingular EDGE customers. When on Wi-fi it won't allow you to send through it.
    Many internet providers, but not all, provide an authenticating SMTP server to use when travelling. If you configured your outgoing server to use the email providers authenticating SMTP server information on a port different from port 25, you will be able to use it on most networks. Some wireless networks filter a wider range of ports, such as some work places.
    This article discusses the issue in more detail:
    http://docs.info.apple.com/article.html?artnum=305634
    Hope this helps,
    Nathan C.

  • Since installing the last iPhoto update sharing a photo via e-mail opens a google e-mail format instead of an Apple Mail format.  How can I get the Apple Mail format to come up when I click on share?

    Since installing the last iPhoto update sharing a photo via e-mail opens a google e-mail format instead of an Apple Mail format.  How can I get the Apple Mail format to come up when I click on share?

    iPhoto preferences - set the email client to Mail
    LN

  • How do I get a new icloud account for my phone when it was setup with my wifes account?

    How do I get a new icloud account for my phone when it was setup with my wifes account?

    Go to Settings>iCloud and sign out. Any synced data, such as calendars and contacts, will be removed.
    To get a new ID: go to http://appleid.apple.com and create a new ID - you will need a different non-Apple email address from any ID you already have.
    Then go back to Settings>iCloud and sign in there, enabling any data types you want to sync in the list there. You will be asked to create a new @icloud.com address when enabling Mail.

  • How can we get a alert message in  the current browser we are using the mom

    how can we get a alert message in the current browser we are using the moment we have entered some data in
    the table...
    I need a popup alert the moment a new record is added in a table... in apex database is 11g xe..
    The idea is I am using a apex application. .The moment new data is added in the table ..I am alerted by a message window..that a new record has been added...
    Thanks
    Edited by: pauljohny on Jun 11, 2012 10:23 AM

    pauljohny wrote:
    how can we get a alert message in the current browser we are using the moment we have entered some data in the table...
    "Current browser"? When viewing anything, or just when using an APEX app?
    Ans .. Just when using apex app....even if the apex app is minimised ..The current browser will be the one where I am using apex app...
    What i am looking for some scheduler .. to check ..in the table every 5 minute for change if there is a change..then a popup alert be shown...
    Split it into [at least] 2 components, database and browser. I'd expect someone calling themself a "DBA Architect" to have some ideas about the database side of things, even if not clued up on JavaScript and AJAX?
    I dont think its a database isssue... When i say to check every 5 minutes ..it could be easily done via dbms_scheduler ...I am having issue in getting the popup alert message...
    in apex... Dont know wether there is a plugin like modal window(available from skill builder) which shall help in this scenario,.Or might be have to use java scripting and ajax ..
    and if it is that (Java scripting and Ajax) .....then shall have to be familiar with java scripting and Ajax...and this shall be a bit time consuming..
    Had a feeling this could be accomplished via java scripting and ajax.. ...but still looking for some easy way..

  • How do you get your ipod touch to make a noise when people text you and to pop up on the screen my friend did something to her ipod to do this but i dont know how please help!!!!!!!!!!!!!!!!!!!!!!!!!!! its like she updated it but i already tried it!!!!!!

    how do you get your ipod touch to make a noise when people text you and to pop up on the screen my friend did something to her ipod to do this but i dont know how please help!!!!!!!!!!!!!!!!!!!!!!!!!!! its like she updated it but i already tried it!!!!!!i am very confused and want my ipod touch 4g like that please help thxns:)

    Go to Settings>Notifications and turn alerts/sounds on for the app(s) in question.  Not all apps have all options.

  • I have my iTunes library between an external hard drive and my PC.  How do I get all of it onto the PC?  When I consolidate it leaves the songs on the external drive.

    My iTunes library is split between an external hard drive and my PC.  How do I get all the songs onto my PC?  When I consolidate, it brings the names of the songs to the PC but they are empty files.

    Hold down the "option" + "command" keys and launch iPhoto.
    Select the "Rebuild Thumbnails" choice.

  • How do I get a disc out of my super drive when I forgot to eject it from the drive before pulling out the USB cable ?

    how do I get a disc out of my super drive when I forgot to eject it from the drive before pulling out the USB cable ?

    How force eject disc: Apple Support Communities
    Mac Mini: Eject DVD Apple Support Communities

  • Hey apples, how do I get my iPhone 4 sync'ed with my itunes account using my laptop?

    Hey apples, how do I get my iPhone 4 sync'ed with my itunes account using my laptop = how do I add my existing itunes from my account from my laptop to my iPhone 4.  Thanks.

    Overview of syncing iPhone, iPad or iPod touch with your computer:  http://support.apple.com/kb/HT1386
    Keep in mind that with the iPhone, you can sync all iTunes content with only one computer.  Trying to sync iTunes content with a second computer will result in iTunes erasing the content from the first computer.  However, non-itunes content such as contacts, calendars, mail settings, notes, etc. (anything in the Info pane) can be synced from another computer.
    If you have songs on a different computer, copy them to the computer you use to sync:
    iTunes for Mac: How to copy purchases between computers, http://support.apple.com/kb/ht1373
    iTunes for Windows: How to copy purchases between computers, http://support.apple.com/kb/HT1727

  • How do you get your album's songs to stay together when you put them on your ipod/iphone, when some songs have a ft. artist?

    How do you get your album's songs to stay together when you put them on your ipod/iphone, when some songs have a ft. artist?
    Even when I try to change the featured artist in my I tunes, it won't stay with my other songs, and I want to be able to listen to my album in the order of the songs that the album has it.

    The iTunes/iPod software isn't set up to let you sync songs from more than one libray, but if you manually manage the iPod you can add tracks from multiple computers without removing the existing content. Personnaly I think syncing with a library is a much better way to manage your iPod, so I'd suggest you just copy the stuff you bought at work onto a memory stick, then take it home and import it into your iTunes library there.
    tt2

  • How do you get wi fi on your i pod touch when your to far away from the router

    How do you get wi fi on your i pod touch when your to far away from the router

    You don't

  • HELP! How do I get rid of the volume noise that plays when I switch from internal speakers to external speakers?

    How do I get rid of the volume noise that plays when I switch from internal speakers to external speakers? I'm trying to watch something on my TV through an HDMi cable (& apple adapter) and when I go to switch the sound control in preferences from internal speakers to SONY TV, the annoying "popping" noise occurs on my TV's speakers.

    Go to Edit > Preferences > General > Import Settings and check the box for error correction, and then try one of the problem CDs again.

Maybe you are looking for

  • Problem with USB audio device

    Hi all I have many problem with a USB device sound, i have a plantronic headset with a usb adapter to connect on my macbook pro, I have already this problem in the past but i have found a astuce to fix this problem. Before, when i'm on teamspeak 2, 3

  • Import part of the sequence from another project

    I'm working on about the fifth edit of a project and now want to move part of a sequence (about 40 clips) from one project to another. I understand I could import the entire sequence and then delete all but the portion I want, or delete all but the p

  • Dropdown list not updating when bound db changes

    I hope someone can help me.  I have a form created by Livecycle Designer ES.  It contains a dropdown list populated by a bound to a database table. All works well until the database table is altered.  The dropdown list does not reflect the change.  I

  • SO Creation - Diff. Tax codes

    It is possible in one sales order for multiple line items having diff tax codes. I want to prevent multiple tax codes in same sales order. How do I do that ?

  • Droid X - Windows 7 - Missing bluetooth Peripheral driver

    Anybody know how and/or where to fix the missing bluetooh peripheral driver to my windows 7 laptop?