F2 key not working with custom JTable Column

I have a custom JTable Column (which is a JPanel with a JTextfield and JButton). Everything works as expected, except when the user presses "F2" to start editing the custom column cell. When the user presses F2, the custom cell goes into editing mode, but I am unable to type anything in it.
Below is the SSCCE.
Steps to Reproduce problem:
1) Run the Program
2) Select any cell in first Column.
3) Press "F2" and try to type into the cell. Can't type anything.
package com.ns;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.EventObject;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
public class TextButtonCellFrame extends javax.swing.JFrame {
    // Variables declaration - do not modify                    
    private JTextField inputText;
    private JScrollPane jScrollPane1;
    private JPanel testPanel;
    private JTable testTable;
    // End of variables declaration                  
    public TextButtonCellFrame() {
        initComponents();
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {
        testPanel = new JPanel();
        jScrollPane1 = new JScrollPane();
        testTable = new JTable();
        inputText = new JTextField();
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        testTable.setModel(new 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"
        testTable.setCellSelectionEnabled(true);
        testTable.setRowHeight(52);
        testTable.setSurrendersFocusOnKeystroke(true);
        testTable.getColumnModel().getColumn(0).setCellRenderer(new MyTableCellRenderer());
        testTable.getColumnModel().getColumn(0).setCellEditor(new MyTableCellEditor(new JTextField()));
        testTable.getColumnModel().getColumn(0).setPreferredWidth(200);
        jScrollPane1.setViewportView(testTable);
        testPanel.add(jScrollPane1);
        inputText.setPreferredSize(new Dimension(50, 20));
        testPanel.add(inputText);
        getContentPane().add(testPanel, BorderLayout.CENTER);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-576)/2, (screenSize.height-417)/2, 576, 417);
    }// </editor-fold>                       
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TextButtonCellFrame().setVisible(true);
    public class MyTableCellRenderer extends JPanel implements TableCellRenderer {
        Point point;
        JButton button1 = new JButton("Test 1");
        JTextField txtField = new JTextField();
        public MyTableCellRenderer() {
            setLayout(new BorderLayout());
            this.add(button1, BorderLayout.EAST);
            this.add(txtField,BorderLayout.CENTER);
        public Component getTableCellRendererComponent(JTable table, Object value,
                boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
            if (isSelected) {
                txtField.setBackground(testTable.getSelectionBackground());
                txtField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
            else {
                txtField.setBackground(testTable.getBackground());
                txtField.setBorder(null);
            return this;
    public class MyTableCellEditor extends DefaultCellEditor {
        JPanel panel = new JPanel();
        JButton button1 = new JButton ("Test 1");
        JTextField txtField;
        MyTableCellEditor(JTextField txtField) {
            super (txtField);
            this.txtField = txtField;
            panel.setLayout(new BorderLayout());
            panel.add(button1, BorderLayout.EAST);
            panel.add(txtField,BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == button1)
                JOptionPane.showMessageDialog(null, "Action One Successful");
        public Component getTableCellEditorComponent(JTable table, Object value,
                                    boolean isSelected, int row, int column) {
            return panel;
       public boolean isCellEditable(final EventObject anEvent) {
          if (anEvent instanceof KeyEvent) {
             final KeyEvent keyEvent = (KeyEvent) anEvent;
             SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                   if (!Character.isIdentifierIgnorable(keyEvent.getKeyChar())) {
                      txtField.setText(txtField.getText() + keyEvent.getKeyChar());
                   txtField.setCaretPosition(txtField.getText().length());
                   txtField.requestFocusInWindow();
            return super.isCellEditable(anEvent);
}The code for isCellEditable(final EventObject anEvent) which is needed to edit the cell using keyboard was provided by DarrylBurke here
regards,
nirvan.

The F2 key when pressed generates an action event (either JTable generates it or some other component). I am not sure how to handle the action event in the isCellEditable() method. Also, F(X) range of keys other than F2 dump some junk character in the JTextfield when pressed. I am now stuck at this point and don't know how handle F(X) range of keys.
regards,
nirvan.

Similar Messages

  • Using shift key not working with bluetooth keyboard

    Am I missing something here? Or does the shift key not work with the iphone using a bluetooth keyboard?  I'm using the logitech K810 for reference on iphone 6 iOS 8.1

    The shift key works just fine on my Bluetooth keyboard.  So I would imagine this is an issue with your keyboard.

  • Discoverer Viewer/Plus does not work with Custom EUL owned by APPS user

    I am facing a unique issue with one of my customers. They have a custom EUL named XX_EUL_US and this does not allow connecting through discoverer viewer or discoverer plus.
    I have worked with custom EULS before at other customers and this was never the case. I am being told that this issue is happening as the EUL owner is APPS instead of some other user. Is this the case? Can discoverer viewer not be used with EULs owned by apps user?
    Please not that the Default EUL in ICX profiles is set to this EUL and no other EUL profiles are set.
    Appreciate any thoughts on this.

    Hi,
    I am not sure what you mean when you say you have a "custom EUL named XX_EUL_US". The EUL table should be created in a schema named XX_EUL_US. This will then be the EUL owner. You will then need to connect to Discoverer Administrator as the EUL owner and grant privileges to Apps users and/or responsibilities.
    The user should then be able to connect to Discoverer Plus/View using their apps username, responsibility and password.
    To be able to connect directly from an apps menu you need to have the ICX parameters set correctly. The ICX: Discoverer Default End User Layer Schema Prefix should be set to XX_EUL (without the _US). The ICX: Discoverer End User Layer Language Override should be set to US or not set at all.
    Rod West

  • Brightness and volume control keys not working with windows 7?

    brightness, volume control and some other keys keys are not working with windows 7 with macbook pro retina. Can I fix it?

    Welcome to the Apple Support Communities
    Have you installed Boot Camp drivers? You need them to make your computer work properly on Windows, and to use your function keys as Play or Pause, volume and brightness keys.
    To install them, follow these steps:
    1. Press the X key while your Mac is starting to start into OS X.
    2. Open Boot Camp Assistant and tick only the option to download Windows support software.
    3. Windows support software will be downloaded and Boot Camp Assistant will ask you to burn it into a DVD or USB drive, so do it.
    4. Start into Windows, insert the DVD or USB drive and install Boot Camp drivers. Your Mac and your volume and brightness keys will be working after installing the drivers

  • BT848 TV not working with custom 2.6.22 kernel

    Hi,
    I installed a custom compiled 2.6.22 kernel (built the traditional way, using menuconfig in /usr/src/linux-2.6.22) but then tvtime could not work with my BT848 TV card (error message - "not a video4linux device" and "cannot open capture device /dev/video". The device is there and a simple video app. I wrote myself says:
    cyclops: Opened V4L2 device: /dev/v4l/video0
    cyclops: VIDIOC_QUERYCAP: error 25, Inappropriate ioctl for device
    The TV worked with kernel 2.6.21, although to listen to radio with gqradio I had to start tvtime first to get any sound. I double checked my config but can't see anything missing, I have compiled custom kernels many times and so I could say I am not inexperienced. I am using latest Arch x86-64 on an AMD Athlon 64 machine.
    Has anyone else experienced this problem?
    My thanks in advance!

    Hi,
    I installed a custom compiled 2.6.22 kernel (built the traditional way, using menuconfig in /usr/src/linux-2.6.22) but then tvtime could not work with my BT848 TV card (error message - "not a video4linux device" and "cannot open capture device /dev/video". The device is there and a simple video app. I wrote myself says:
    cyclops: Opened V4L2 device: /dev/v4l/video0
    cyclops: VIDIOC_QUERYCAP: error 25, Inappropriate ioctl for device
    The TV worked with kernel 2.6.21, although to listen to radio with gqradio I had to start tvtime first to get any sound. I double checked my config but can't see anything missing, I have compiled custom kernels many times and so I could say I am not inexperienced. I am using latest Arch x86-64 on an AMD Athlon 64 machine.
    Has anyone else experienced this problem?
    My thanks in advance!

  • Right shift key not working with middle row of letters

    The right shift key on my Macbook Pro does not work with the middle row of letters. It works with all other letters and numbers, just not A-L. Nothing out of the ordinary happened, it just stopped capitalizing

    Try resetting your SMC and PRAM.
    Resetting the System Management Controller >>
    If that does not work, test it using an external keyboard.
    Dave M.
    MacOSG Founder/Ambassador  An Apple User Group  iTunes: MacOSG Podcast
    Macsimum News Associate Editor  Creator of 'Mac611 - Mobile Mac Support'

  • Brightness key not working with Dell monitor

    Should my new wireless keyboard brightness keys be working with my Dell monitor?

    Hello I managed to solve my problem of brightness key not working by Installing the Intel HD Graphic 3000 Driver from Intel official site. So if your Graphic card is Intel HD 3000 Graphic and your system is 64 Bit OS then you can follow the below link to download it and install.....https://downloadcenter.intel.com/download/24971/Intel-HD-Graphics-Driver-for-Windows-7-8-64-bit Note :- This Graphic driver only support the following intel Processor And If Your Are still running the built in intel graphic card, then only download it and install at you own risk.Supports Intel(R) HD graphics on:            2nd generation Intel(R) Core(TM) i3 processor            2nd generation Intel(R) Core(TM) i5 processor            2nd generation Intel(R) Core(TM) i5 vPro(TM) processor            2nd generation Intel(R) Core(TM) i7 processor            2nd generation Intel(R) Core(TM) i7 vPro(TM) processor            Intel(R) Pentium(R) Processor  900/B900/G600/G800 Series            Intel(R) Celeron(R) Processor 700/800/B700/B800/G400/G500 Series

  • Volume and brightness keys not working with new keyboard on imac

    I just purchased a new wired keyboard for imac and brightness and volume control keys not working . i have tried adjusting keyboard settings. I have software version 10.5.8. Do I need to upgrade software. Thank you for any help.

    Do you have "Automatically Adjust Brightness" check box ticked in System Preferences > Displays > Display ? If so, you can't manually adjust brightness.

  • Shift key not working with some keys

    I am using a MAC Pro with two hard drives.  One runs Leopard and the other MS windows.  while in windows, the birghtness key illuminated (f2 key) and suddenly the shift 2, w, s, x keys quit working.  I decided to reboot and while holding the option key to boot into windows, the system did not recognize the option key and booted me into Leopard.  so now I notice the shift 2, w, s, x, and option key are not working.  Any suggestions?  Also, the brightness icon is still lit up on my screen and I am not able to make it go away or even adjust...

    I'm having this same exact issue. Anyone know of a fix? Is it possible junk in the keyboard?
    I tested my keys using the keyboard viewer, and when I hit function it recognizes it, but it doesn't when it is loading.

  • Eject key not working with MBA Superdrive

    For MBA owners with MBA Superdrive, could you please let me know if the Eject key is working? I just bought a MBA Superdrive but the Eject key on the keyboard is not ejecting disc. When i press the Eject key, i don't see the gray Eject icon on the screen, unlike all other function keys (for example, volume control, keyboard backlight control and screen brightness control). I can ctrl-click (or right-click) on the disc and select "Eject" to eject disc. If i do a ctrl-Eject, i can get the "Are you sure you want to shut down your computer now" window to show up so the Eject key does not appear to have any physical or electrical issue. I can also boot into Boot Camp (Windows 7) and the Eject key works perfectly.
    I have installed and uninstalled Virtual Box and Parallels so i am not sure if my problem is related to that.
    Apple's tech support recommendation is to do an archive install, which in theory will keep all my personal data but create a new Systems folder. But i would like to try something less drastic before going that route.

    Thanks. I not only did an "archive install" of Snow Leopard, i also did a erase install. But the Eject key is still not working like it's supposed to. I think i am going to try clearing the PRAM next.

  • Apple wired keyboard - certain keys not working with shift

    I treated myself to a new Apple wired keyboard MB110B/A for my mac mini.
    My previous keyboard worked fine, however the new keyboard causes the computer to enter the Hardware Test mode every time the computer is restarted. The computer only starts normally without the keyboard connected (or with my old keyboard connected).
    Once the computer has started, if I plug the new keyboard in, it appears to work normally with the following exceptions. The following keys do not register when the "shift" key is pressed: 2, w, s, x. This fault does not occur with my old keyboard.
    As these keys are in a line, I think there may be a wiring fault inside the keyboard. If so, would this explain the computer entering Hardware Test mode every time it is started with the keyboard connected?
    Thanks in advance.

    Definitely sounds like a hardware fault in the keyboard to me. I assume it's the same whichever USB port it's connected to? (and if you plug it into another Mac, too)?
    Of course, as that keyboard is glued together in final assembly, it's completely unrepairable.
    If it's a reproducible fault (and new anyway): take/send it back for replacement. You shouldn't have any trouble with Apple arguing.

  • Flex Print Job not working with custom component

    Hi All,
    I have to print pages with header, body and footer. So the thought process was to create a custom component fro header, footer and body. Header component is based on Box, Body is a renderer (which will have fix value of items - and will decide the number of possible pages) and footer is again based on Box.
    But when i created a simple Custom component like this for header
    <?xml version="1.0" encoding="utf-8"?>
      <mx:VBox  xmlns:fx=http://ns.adobe.com/mxml/2009
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <mx:HBox>      <mx:Label id="testLabel" text="Test Container"/>
    </mx:HBox> 
    </mx:VBox>
    Then when i try to add this to FlexPrintJob, and save it as 'xps' to see the print output, i get error message that this file is in use or damaged.
        var myPrintJob:FlexPrintJob = new FlexPrintJob();
      if(!myPrintJob.start()){
          return;
    var header:Header = new Header();
    header.width = myPrintJob.pageWidth;
    header.visible = false;
    FlexGlobals.topLevelApplication.addChild(panierPrintHeader);
    myPrintJob.addObject(header);
    myPrintJob.send();
    FlexGlobals.topLevelApplication.removeChild(panierPrintHeader);
     But this does not work and i get the above mentioned exception. Now when i not use the custom component and just have a label or HBox or anything on stage before the print functionality is invoked, it works fine. And this too haapens only if you have a mxml component, i tried by creating a new Label component using actionscript and then provide the same to the printJob, which did not work either. I need help on this, else i will have to take print functionality to server side(Java) which has some business implications, the reason why i am spending time on flex for printing. 
    Thanks and Regards,
    Jigar
    Looks like custom component print is not working fine with flex or i am doing something terribly wrong.
    Looking forward for help.

    Is there nobody in flex community who can help on this....
    Looks like a toothless class that adobe actionscript team has provided, which is not liked across much

  • Esc key not working with JDialog

    Hi,
    We are facing a KeyListening problem with JDialog. We developed an application using JRE 1.4.0. When we migrate from 1.4.0 to 1.4.2.The Esc keys(All keys) associated with the JDialog is not listening. Following is code piece is showing the Esc key. The same piece of code is working with 1.4.0 and with lesser versions. U'r help will be appriciated.
    import java.awt.Container;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    public class EscDialog extends JDialog implements KeyListener {
         static EscDialog ed = new EscDialog();
         public static void main(String[] args) {
              ed.setSize(200, 300);
              ed.addKeyListener(ed);
              JButton jb = new JButton("Test");
              JPanel jp = new JPanel();
              jp.add(jb);
              Container cp = ed.getContentPane();
              cp.add(jp);
              ed.show();
         public void keyPressed(KeyEvent anEvent) {
              if (anEvent.getKeyCode() == KeyEvent.VK_ESCAPE)
                   System.exit(0);
         public void keyTyped(KeyEvent anEvent) {
         public void keyReleased(KeyEvent anEvent) {
    }

    An example:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JDialog {
        public Test () {
            getContentPane ().setLayout (new FlowLayout ());
            getContentPane ().add (new JLabel ("Press escape to exit..."));
            getRootPane ().getInputMap ().put (KeyStroke.getKeyStroke (KeyEvent.VK_ESCAPE, 0), "dispose");
            getRootPane ().getActionMap ().put ("dispose", new AbstractAction () {
                public void actionPerformed (ActionEvent event) {
                    dispose ();
            pack ();
            setDefaultCloseOperation (DO_NOTHING_ON_CLOSE);
            setLocationRelativeTo (null);
            setTitle ("Test");
            setVisible (true);
        public static void main (String[] parameters) {
            new Test ();
    }Kind regards,
      Levi

  • Keyboard: audio and Brightness control keys not working with or without fn

    The Keys for controling Audio and Brightness (F1-F5) do not work.
    Also combined with pressing the "fn" key the keys do not work.
    So i only control audio with the remote control or the slider in the menubar.
    Making a reboot with deleting pram didn't help.
    I'm running the up to date version of leopard on a macbook pro (core2duo).
    I also searched in the forum for this problem.
    I oten read about "sytem control"-"keyboard and mouse"-"keyboard" and the F1, F2, etc. to use as...
    but switching this button on or off doesn't change anything.

    problem solved:
    the couse was the software update 1.1 for macbook pro, because there i had the problem like in this thread: http://discussions.apple.com/thread.jspa?messageID=6142512&#6142512
    and did the solution like that, but there i maybe made some mistakes with renaming and copying, so i rinstalled the update and renamed it a copied to plugins, and now all works as it should.
    thanks for help

  • F7 & F8 shortcut keys not working with Apple's new keyboard

    Using a Mac with Macs newish low profile keyboard.
    Nothing happens when I use these keys.
    The F5 & F6 keys work just fine.
    Is there something I'm doing wrong?
    Or is the new Apple keyboard not compatible with these shortcuts?
    What to do?
    plmk,
    thanks.

    You can go to the System Preferences --> Keyboard and Mouse and check "Use F1, F2 etc keys..." and F7 and F8 will work.
    But I don't know where the function key is on those new keyboards.

Maybe you are looking for

  • TS1538 after update to itunes 11.1.4.62 won't recognize iphone for syn

    after i updated my itunes to version 11.1.4.62 (as of 29/01/2014) and after i plugged my usb cable connected with my iphone, my iphone didn't appear as usual on the itunes for syn but my window 8 do pick up the iphone device and the iphone is chargin

  • Error in Soap Communication Channel

    Hi All, I am using Soap as sender from UPXI and again Soap as receiver in EUPI but while doing end to end test SOAP sender channel was failing. Below was the error which I cam seeing the channel mointoring. Message processing failed. Cause: com.sap.e

  • Correlation in union, is good or we should put it out side.

    hi , 1) Select t.* from  t  where not exist ( select t1.id from t1 where t1.id=t.id                             union                            select t2.id from t2 where t2.id=t.id ) 2) select t.* from  t  where t.id not in ( select t1.id from t1 

  • Mobile apps which interacts Oracle Database Server

    Dear Friends, I want to develop mobile application which will interact with my database server(Which is on my Desktop). What are the things I have to study? Can I use Netbeans IDE or JDevloper with ADF for this. Which is the best? Please give me rela

  • Sent messages re-appearing from years ago.

    Today I checked for something I sent over the weekend in my Sent items in the Mail client on my Mac, and discovered that a lot of emails I sent over a year ago (up to 3 years ago) have magically appeared in my sent mail as having been sent only a cou