How to handle Shift+Tab key event

HI,
This is Ramesh.I have added KeyListener to JTable. I am handling key events through key codes. But I am
unable to handling multiple key strokes like Shift+Tab
Can any one please give me suggestion how can I do it
Thanks & Regards
Ramesh K

i dont know about Key BindingsWhich is why you where given a link to the tutorial in the first response.
can you please give me suggestion.You've been given the suggestion 3 times. You can decide to learn to write code the way other Swing components are written. Or, you can do it the old way. The choice is up to you.

Similar Messages

  • Shift+Tab Key Event

    Hallo all,
    I have a big problem ;) I am having JTables and these Jtables must lose their focus when someone clicks on Shift+TAB at the (0,0) th of its cell. I tried to do it in a key event but it doesn't accept my solution. Here is a code chunk:
    AWTEvent currentEvent = EventQueue.getCurrentEvent();
    if( currentEvent instanceof KeyEvent)
            KeyEvent ke = (KeyEvent)currentEvent;
                if(ke.getSource()!=this)
                    return;
                if(rowIndex==getModel().getRowCount()-1 && columnIndex==getModel().getColumnCount()-1
                        && KeyStroke.getKeyStrokeForEvent(ke).equals(shiftTabKeyStroke)){
                    KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent();
                    return;
                }So when I compile it, it makes a return to its 0,0 th cell instead of giving focus on the previous component.

    DB means to say this.
    AWTEvent currentEvent = EventQueue.getCurrentEvent();
    if( currentEvent instanceof KeyEvent)
            KeyEvent ke = (KeyEvent)currentEvent;
                if(ke.getSource()!=this)
                    return;
                if(rowIndex==getModel().getRowCount()-1 && columnIndex==getModel().getColumnCount()-1
                        && KeyStroke.getKeyStrokeForEvent(ke).equals(shiftTabKeyStroke)){
                      SwingUtilities.invokeLater(new Runnable(){
                          public void run()
                                 KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent();                         
                    return;
                }

  • How to Handled Shift +Tab(Focus) click in radion button?

    Hi,
    I am using Jdeveloper 11.1.2.0.
    My scenario is one radio button having three items(Left,Right,Center). Now my radio button focus is first radio(Left). Now I click the the tab sequence. It will go to the next field, whether it is input field.
    Suppose Now I am come to back ward like shift+Tab it is come to the radio button. Here what is happening mean the focus is going to the Last radio button item(Center), what I want is which radio Item I select Initially ,the Same Place cursor want to go. How to proceed to this. Please give some suggestion to proceed.
    Regards,
    Ragu

    Hi,
    so what you are saying is that the tab focus navigation bypasses the other radio buttons whereas tab back focus navigation doesn't. If this is the case, and due to missing information in your question, try this
    set autosubmit="true" on the radio group so the radio button selection is saved.
    If this doesn't help, please provide information about the implementation of how you created the radio group and which data they are bound to. Chances are that this indeed needs to be filed as a bug but also that it is a problem in your model
    Frank

  • How to make the TAB Key Event called

    Hi ,
    I want to make the tab key called twice when I hit on a button. It should jump to the next 2 cell.
    Thanks.
    DT

    Here's a couple related threads
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=583877
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=712386
    I'd also suggest exploring the Search Forums available on the left,
    which is how I found those threads:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=focus+traversal+tab+text&subCat=siteforumid%3Ajava57&site=dev&dftab=siteforumid%3Ajava57&chooseCat=javaall&col=developer-forums

  • How to send Remote controller key event

    Hi Sir,
    Can anyone tell me "how to send key event from "Remote
    Controller" to Flex application?
    for example. I want to control the Flash player or my Flex UI
    application from remote controller such as use firefly
    controller/streamzap controller/Gyration controller. Normally user
    will use mouse or keyboard to enter/generate event, now I want to
    use "Remote controller" to generate the key event. In Flex, how can
    I capture the key event from "remote controller"? Any sample code
    to provide that will be good.
    Thanks.
    Lin

    Here's a couple related threads
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=583877
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=712386
    I'd also suggest exploring the Search Forums available on the left,
    which is how I found those threads:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=focus+traversal+tab+text&subCat=siteforumid%3Ajava57&site=dev&dftab=siteforumid%3Ajava57&chooseCat=javaall&col=developer-forums

  • Capturing the TAB key event.

    How can I capture the TAB key event?
    I am trying to use it within a JTextField to do a normal text tab operation.
    Thanks,
    D

    I want to map the Tab key to a jTextField so that when the user is editing inside the jTextField they can press the TAB key to tab over a predefined number of characters.
    Thanks,
    D

  • [JS] Tab key event (ScriptUI)

    Hi,
    If set to 'window' or 'palette' type, a ScriptUI Window can't receive 'Tab' key events on WinXP.
    Is this the same with other OS?
    Is there a workaround?
    Thanks,
    Marc

    Here's the thread about the bug
    http://forums.adobe.com/message/2068532
    It really was and is a big problem for me and soesn't seem to be getting fixed any time soon
    Steven Bryant
    http://scriptui.com

  • Listening Tab Key Event On JTextField

    Hi
    i am unable to listen Tab Key Event on JTextField ....
    tField.addKeyListener(new KeyAdapter()
    public void keyPressed(KeyEvent e)
    if (e.getKeyCode()==e.VK_TAB)
    JOptionPane.showMessageDialog(null,"Tab Pressed");
    else
    JOptionPane.showMessageDialog(null,"Tab Not Pressed");
    When i pressed Tab Key then it dont come in KeyPressed Event ...Actually it go towards next FocusAble component ..
    Any help in this regard.....

    I also Checked it by using
    tField..setFocusTraversalKeysEnabled(false);
    tField.addKeyListener(new KeyAdapter()
    public void keyPressed(KeyEvent e)
    if (e.getKeyCode()==e.VK_TAB)
    JOptionPane.showMessageDialog(null,"Tab Pressed");
    else
    JOptionPane.showMessageDialog(null,"Tab Not Pressed");
    In this case each time e.getKeyCode() returns 0...
    plz help me

  • How to disable the Tab key?

    Hi,
    Usually,the most end users select partners name or code by the Tab key or pickers, how can I disable Tab key? I want users to select a partner by user-defined values.
    Best Regards!

    Hi,
    We donu2019t have a provision for disable the tab key in B1.
    If you are assigning user defined value in any field, magnifying class will be displaying.
    You should give a KT to end user that donu2019t use tab key, instead of tab key please click on magnifying class in those filed.
    Thanks and Regards,
    Senthil Maruthappan.
    Team Work Never Fails
    Edited by: Senthil Maruthappan on Jul 4, 2009 11:16 AM

  • How to control navigation flow in order using tab and shift tab key?

    In JDeveloper 11.1.1.3, how to set the focus on ADF components in order while a tab key is clicked.I dint find any useful articles so far but I think Javascript is the only way to acheive this.Can anyone give me any ideas on this pls?
    Thanks,
    Swathi Patnam

    Swathi Patnam wrote:
    In JDeveloper 11.1.1.3, how to set the focus on ADF components in order while a tab key is clicked.I dint find any useful articles so far but I think Javascript is the only way to acheive this.Can anyone give me any ideas on this pls?Javascript is possibly one way to achieve it. Take a look at an extract from Frank Nimphius' book [url http://books.google.gr/books?id=wlXyDIEyIHEC&pg=PA615&dq=Nimphius+%22tab+order%22&hl=en&ei=D6bATJqgMYb54Ab06cnTCw&sa=X&oi=book_result&ct=result&resnum=1&ved=0CCMQ6AEwAA#v=onepage&q&f=false] here suggesting an implementation based on JavaScript. Of course you will have to buy the book to see the complete solution. ;)
    Since the tab order is from top to bottom, the other solution suggested - check this post: Re: How to set tab order in ADF - is to keep each horizontal "line" of components in a af:panelFormLayout with its rows attribute set to 1. This is a work-around not based on a tab index but it would do the job if you can consistently group your components inside panelFormLayouts as mentioned.

  • How to recognize the tab key in a JTextField

    I have a drawing program with a main window and a tools palette, which is a JDialog. The tools palette has JToggleButtons and one JTextField. When you have the focus in the JTextField and you press tab repeatedly, it tabs through all the JToggleButtons and then back into the JTextField.
    However I would like to recognize the pressing of the tab key and ask for the focus to go back to the main window.
    I subclassed the JTextField, added a KeyAdapter, but it does not recognize the tab key. I also added the processKeyBinding method, but it doesn't recognize the tab key either.
    How can I recognize the tab key?
    Here is a self-contained test program that illustrates the problem:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class AnanyaCurves extends JFrame
      Tools tools;
      public AnanyaCurves(Dimension windowSize)
        Basics.ananyaCurves = this;
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        setTitle("Ananya Curves");
        tools = new Tools(this);
      public static void main(String[] args)
        int toolsWidth;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        toolsWidth = 200;
        Dimension windowSize = new Dimension(screenSize.width - toolsWidth, screenSize.height - 58);
        AnanyaCurves ananyaCurves = new AnanyaCurves(windowSize);
        ananyaCurves.pack();
        ananyaCurves.setBounds(toolsWidth, 0, windowSize.width, windowSize.height);
        ananyaCurves.setVisible(true);
        ananyaCurves.requestFocus();
      public void setVisible(boolean b)
        tools.setVisible(b);
        super.setVisible(b);
    class Basics extends java.lang.Object
      public static AnanyaCurves ananyaCurves;
      public Basics()
    class Tools extends JDialog
      JToggleButton btnGrid;
      JTextField textGrid;
      JPanel panel;
      public Tools(JFrame frame)
        super(frame, "Tools", false);
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        btnGrid = makeBtn("Grid");
        textGrid = makeTextField();
        panel = makePanel();
        pack();
      public JToggleButton makeBtn(String name)
        JToggleButton btn = new JToggleButton();
        btn.setMaximumSize(new Dimension(108, 24));
        btn.setPreferredSize(new Dimension(108, 24));
        btn.setText(name);
        btn.setFont(new Font("Verdana", Font.PLAIN, 11));
        btn.setMargin(new Insets(5, 10, 5, 10));
        btn.setOpaque(true);
        return btn;
      public ACJTextField makeTextField()
        ACJTextField textField = new ACJTextField();
        textField.setFont(new Font("Verdana", Font.PLAIN, 12));
        textField.setMaximumSize(new Dimension(108, 20));
        textField.setPreferredSize(new Dimension(108, 20));
        textField.setText("0.25");
        textField.setEnabled(true);
        return textField;
      public JPanel makePanel()
        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        panel.add(btnGrid);
        panel.add(textGrid);
        getContentPane().add(panel);
        return panel;
    class ACJTextField extends JTextField
      KeyAdaption keyAdaption;
      public ACJTextField()
        super();
        keyAdaption = new KeyAdaption();
        this.addKeyListener(keyAdaption);
      class KeyAdaption extends KeyAdapter
        public void keyPressed(KeyEvent event)
          int keyCode = event.getKeyCode();
          if (keyCode == KeyEvent.VK_TAB)
            Basics.ananyaCurves.requestFocus();
      protected boolean processKeyBinding(KeyStroke keyStroke, KeyEvent keyEvent, int int2, boolean boolean3)
        int keyCode = keyEvent.getKeyCode();
        if (keyCode == KeyEvent.VK_TAB)
          Basics.ananyaCurves.requestFocus();
          return false;
        return super.processKeyBinding(keyStroke, keyEvent, int2, boolean3);
    }Thanks for looking at this.

    Wow, Michael, you work like magic! Thanks so much! I would be happy to give you a commercial key to my Ananya Curves program also once the second release is on my website. It's a program for drawing curves in an easier way without pulling on tangent lines, with all control points right on the curve. Just send me an email to [email protected] if you are interested!

  • How to handle exceptions thrown by event

    Hi all,
    i have this slight problem, i'm trying to handle accessing a databse from a button click, i'm trying to simulate somebody logging on to a network. the code is as follows;
    *@author James Taylor
    *@version 30-11-2003
    *Logon gui
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    public class LogonUI extends JFrame {
         //instance variables
         private JLabel userNameL;
         private JPasswordField password;
         private JButton logon;
         ButtonHandler handler;
         Connection con;
         Statement stmt;
          *Constructor initialises and creates UI, adds functionality to the button.
         public LogonUI() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              super("Employee Logon");
              Container c = getContentPane();
              c.setLayout(new FlowLayout() );
              //handles what happens when user presses the button
               handler = new ButtonHandler();
              userNameL = new JLabel("Please Enter Password:");
              c.add(userNameL);
              password = new JPasswordField(15);
              c.add(password);
              logon = new JButton( "Logon" );
              //anonymous inner class that is created once the button is pressed.
              //it connects to database to validate user
              logon.addActionListener( handler );
              c.add(logon);
              c.setBackground( Color.pink );
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              setSize(250,150);
              setVisible(true);
          *class that opens connection to validate user
         private class ButtonHandler implements ActionListener {
              public void actionPerformed(ActionEvent ae)throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
                   try{
                        boolean isValidUser = false;
                        //Load mysql driver
                         Class.forName("com.mysql.jdbc.Driver").newInstance();
                         //make a connection
                        String url = "jdbc:mysql://localhost/flight";
                        con = DriverManager.getConnection(url)
                        //Create and instantiate a statement obj
                        stmt = con.createStatement();
                        //get a result set
                        ResultSet rs = stmt.executeQuery("SELECT Password FROM employees");
                        //Iterate through the result set
                        while ( rs.next() ){     
                             String savedPassword = rs.getString("Password");
                             if (password.getText().equals(savedPassword) ){
                                  isValidUser = true;
                                  JOptionPane.showMessageDialog(null,"Yipeeeee");
                        if (isValidUser == false){
                             JOptionPane.showMessageDialog(null,"Invalid Password");     
                        stmt.close();
                        con.close();
                   }catch(Exception e){ e.printStackTrace();}
              public static void main (String[] args) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              LogonUI testAirApp = new LogonUI();
    }When the user presses the button the app tries to validate the user.
    I have not been able to test the code due to SQL Exceptions thrown in the handler class, and when i try and throw them up from here i get;
    LogonUI.java:52: actionPerformed(java.awt.event.ActionEvent) in LogonUI.ButtonHandler cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; overridden method does not throw java.lang.InstantiationExceptionAny ideas on my code and how to handle these exceptions will be very appreciated. Regards, James

    Turn your checked exceptions into unchecked exceptions and retrieve the cause later:
    RuntimeException unchecked = new RuntimeException(checked);
    Throwable t = unchecked.getCause();Stephen

  • Tab key event not fired in JTabbedPane

    Hello,
    I wanted to add the functionality of moving between tabs when Ctrl+Tab is pressed like Windows tabs.
    But the tab key listener event is not getting fired by pressing Tab. For all the other key pushes it is working good. It this a problem with Java? Any workarounds?
    Here is the sample code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TestTab extends JFrame
         public void drawGUI()
              //getContentPane().setLayout(new GridLayout(1, 1));
              JTabbedPane lTabbedPane = new JTabbedPane();
              JPanel lFirstPanel = new JPanel();
              lFirstPanel.add(new JLabel("First Panel"));;
              JPanel lSecondPanel = new JPanel();
              lSecondPanel.add(new JLabel("Second Panel"));;
              lTabbedPane.addTab("Tab1", null, lFirstPanel, "Does nothing");
              lTabbedPane.addTab("Tab1", null,lSecondPanel, "Does nothing");
              getContentPane().add(lTabbedPane);
              lTabbedPane.addKeyListener(new KeyAdapter()
                   public void keyPressed(KeyEvent lKeyEvent)
                        System.out.println(lKeyEvent.getKeyText(lKeyEvent.getKeyCode()));
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         public static void main(String[] args)
              TestTab lTestTab = new TestTab();
              lTestTab.drawGUI();
              lTestTab.setSize(200, 200);
              lTestTab.setVisible(true);

    The KeyPressed events for TAB and CTRL-TAB are typically consumed by the KeyboardFocusManager for component traversal. What you have to do is adjust traversal keys and add CTRL-TAB as an action of your JTabbedPane. This is usually done with the InputMap/ActionMap, not a KeyListener:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) {
            Set tabSet = Collections.singleton(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
            KeyStroke ctrlTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_DOWN_MASK);
            final int FORWARD = KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS;
            final JTabbedPane tp = new JTabbedPane();
            //setFocusTraversalKeys to remove ctrl-tab as a forward gesture
            tp.setFocusTraversalKeys(FORWARD, tabSet);
            for (int i=0; i<6; ++i) {
                JPanel p = new JPanel(new GridLayout(0,1));
                JTextArea area = new JTextArea();
                area.setFocusTraversalKeys(FORWARD, Collections.EMPTY_SET);
                p.add(new JScrollPane(area));
                area = new JTextArea();
                area.setFocusTraversalKeys(FORWARD, Collections.EMPTY_SET);
                p.add(new JScrollPane(area));
                tp.addTab("tab " + i,p);
            //add ctrlTab as an action to move to next tab
            Action nextTab = new AbstractAction("nextTab") {
                public void actionPerformed(ActionEvent evt) {
                    int idx = tp.getSelectedIndex();
                    if (idx != -1) {
                        idx = (idx + 1) % tp.getTabCount();
                        tp.requestFocusInWindow();
                        tp.setSelectedIndex(idx);
            InputMap im = tp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
            im.put(ctrlTab, nextTab.getValue(Action.NAME));
            tp.getActionMap().put(nextTab.getValue(Action.NAME), nextTab);
            JFrame f= new JFrame("X");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(tp);
            f.setSize(400,300);
            f.setVisible(true);
    [/code[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to implement "ALT + some key" event ?

    Hello,
    I'd like JDialog to catch key events only when user holds ALT button and presses some regular key (e.g. A,B,C, etc...).
    How this can be done ?
    Thanks for any advice !

    maybe you should use mnemonics?
    i don't know what is it you want to do.
    buti if you want for example to have JDialog, where are some buttons (OK & CANCEL) and want user to be able to click them by pressing ALT+O or ALT+C, then you might need to use mnemonics...
    if you want to enable some new kind of copy/paste/whatever combinations, then you might want to use keybindings
    http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html
    or see tutorial about using menus, and the part there which tells about enabling key operations
    http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#mnemonic
    or be more specific about your problem... what and Why are you trying to do.

  • How to stop the "Tab Key" from acting as a "SEND" button in gmail

    Since installing the Firefox update today, when I hit the keyboard Tab Key in the course of composing an email on gmail, it sends the (!unfinished!) message. I need to disable this "feature". How?

    In the compose window if you hit tab you are tabbing through the buttons on the compose window. You have to hit space in order to sent the message. Please check to see if there is a feature in your gmail that is added to the default. Or see if there is an add on that has saved this feature. You can try safe mode to eliminate the add on theory [[Troubleshoot Firefox issues using Safe Mode]] and reset Firefox if it is a saved application preference.

Maybe you are looking for

  • Please put Flash on iPhone!!!

    It's really becoming a problem. More and more sites are flash-based, and I find I cannot look up important information. Apple, work it out with Adobe! License FLASH whatever it takes. And soon.

  • Force landscape view

    I am creating an Flex Mobile App that is mostly portrait. I do have a few views I need to be landscape. In design view I choose landscape but when viewed in simulator/device it shows as portrait. Is there a property or something I can set on the view

  • Foreign JMS Server Limitation

    Hi all,           Iam facing a limitation with Foreign JMS server.           We are tyring to migrate from Message Bridge to Foreign JMS server.           Our current setup is           We have 3 MQ queues which are bridged to one JMS destination(que

  • How to add instance SQL to UCCX 8.0 datasource

    I do success connect to SQL 2005 default instance using JTML URL as jdbc:jtds:sqlserver://192.168.61.199:1433/Cisco; But I coundn't connect to SQL 2005 with instance such as jdbc:jtds:sqlserver://192.168.51.6:1433/imind_ctc_db:INSTANCE=instance_name

  • Option to encrypt time machine network disks not available

    I have two MBP' (Os10.8.4) machines that backup over a network to a MM running 10.6.8 retail. In TM the box to encrypt the backup is grayed out.  I read in Pondini' excellent instructions ( http://pondini.org/TM/31.html ) that it is only available in