JPasswordField affects key bindings

I set up some key bindings so my program can react to the arrow keys. I came across a rather confusing problem. I've set up a test case to show it:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
public class TestCase extends JFrame {
     private static final long serialVersionUID = 1L;
     JPanel contentPane;
     CardLayout cl = new CardLayout();
     public TestCase() {
          super("Terraworld GUI Testing Zone");
          setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          setResizable(false);
          contentPane = new JPanel(cl);
          contentPane.add(new TestTitlePanel(), "Title Screen");
          setContentPane(contentPane);
          pack();
          setVisible(true);
     public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                    new TestCase();
     public void addCard(JPanel card, String name, boolean show) {
          contentPane.add(card, name);
          if(show == true) {
               cl.show(contentPane, name);
     public void removeCard(JPanel card, String name) {
          contentPane.remove(card);
          cl.show(contentPane, name);
class TestTitlePanel extends JPanel implements MouseListener {
     private static final long serialVersionUID = 1L;
     JLabel loadCharacter;
     public TestTitlePanel() {
          super();
          setPreferredSize(new Dimension(800, 600));
          loadCharacter = new JLabel("Load Character");
          loadCharacter.addMouseListener(this);
          add(loadCharacter);
     public void mouseClicked(MouseEvent e) {
          if(e.getSource().equals(loadCharacter)) {
               ((TestCase)(getRootPane().getParent())).addCard(new TestLoadCharacterPanel(), "Load Character Screen", true);
     public void mouseEntered(MouseEvent e) {}
     public void mouseExited(MouseEvent e) {}
     public void mousePressed(MouseEvent e) {}
     public void mouseReleased(MouseEvent e) {}
class TestLoadCharacterPanel extends JPanel {
     private static final long serialVersionUID = 1L;
     public TestLoadCharacterPanel() {
          super(null);
          setPreferredSize(new Dimension(800, 600));
          add(new LoadCharacterForm());
     public class LoadCharacterForm extends JPanel implements ActionListener, MouseListener {
          private static final long serialVersionUID = 1L;
          JTextField usernameField;
          JPasswordField passwordField;
          JLabel cancelButton;
          JLabel okButton;
          public LoadCharacterForm() {
               super(null);
               setBounds(204, 167, 396, 225);
               usernameField = new JTextField();
               usernameField.addActionListener(this);
               usernameField.setBounds(263, 46, 109, 20);
               usernameField.setFont(new Font(Font.SANS_SERIF,
                         usernameField.getFont().getStyle(),12));
               usernameField.setText("Default");
               passwordField = new JPasswordField();
               passwordField.addActionListener(this);
               passwordField.setBounds(262, 71, 109, 20);
               passwordField.setText("Default");
               cancelButton = new JLabel("Cancel");
               cancelButton.addMouseListener(this);
               cancelButton.setBounds(163, 113, 45, 15);
               okButton = new JLabel("Ok");
               okButton.addMouseListener(this);
               okButton.setBounds(347, 113, 28, 15);
               add(usernameField);
               add(passwordField);
               add(cancelButton);
               add(okButton);
          public void actionPerformed(ActionEvent e) {
               String username = usernameField.getText();
               String password = new String(passwordField.getPassword());
               String error = "";
               if(!username.equals("") && !password.equals("")) {
                    ((TestCase)(getRootPane().getParent())).addCard(new TestGamePanel(), "Game Screen", false);
                    ((TestCase)(getRootPane().getParent())).removeCard(TestLoadCharacterPanel.this, "Game Screen");
               else {
                    if(username.equals("")) {
                         error = "Username field is empty!";
                    if(password.equals("")) {
                         if(!error.equals("")) {
                              error += System.getProperty("line.separator");
                         error += "Password field is empty!";
                    JOptionPane.showMessageDialog(null, error);
          public void mouseClicked(MouseEvent e) {
               if(e.getSource().equals(okButton)) {
                    actionPerformed(new ActionEvent(usernameField, 1, ""));
               else if(e.getSource().equals(cancelButton)) {
                    ((TestCase)(getRootPane().getParent())).removeCard(TestLoadCharacterPanel.this, "Title Screen");
          public void mouseEntered(MouseEvent e) {}
          public void mouseExited(MouseEvent e) {}
          public void mousePressed(MouseEvent e) {}
          public void mouseReleased(MouseEvent e) {}
class TestGamePanel extends JPanel {
     private static final long serialVersionUID = 1L;
     public TestGamePanel() {
          super(null);
          setPreferredSize(new Dimension(800, 600));
          setFocusable(true);
          requestFocusInWindow();
          Action downAction = new DownAction("Down", "Down");
          Action upAction = new UpAction("Up", "Up");
          Action rightAction = new RightAction("Right", "Right");
          Action leftAction = new LeftAction("Left", "Left");
          getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("DOWN"), downAction.getValue(Action.NAME));
          getActionMap().put(downAction.getValue(Action.NAME), downAction);
          getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("UP"), upAction.getValue(Action.NAME));
          getActionMap().put(upAction.getValue(Action.NAME), upAction);
          getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("RIGHT"), rightAction.getValue(Action.NAME));
          getActionMap().put(rightAction.getValue(Action.NAME), rightAction);
          getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("LEFT"), leftAction.getValue(Action.NAME));
          getActionMap().put(leftAction.getValue(Action.NAME), leftAction);
     class DownAction extends AbstractAction {
          private static final long serialVersionUID = 1L;
          public DownAction(String text, String desc) {
               super(text);
               putValue(SHORT_DESCRIPTION, desc);
          public void actionPerformed(ActionEvent e) {
               JOptionPane.showMessageDialog(null, "Down");
     class UpAction extends AbstractAction {
          private static final long serialVersionUID = 1L;
          public UpAction(String text, String desc) {
               super(text);
               putValue(SHORT_DESCRIPTION, desc);
          public void actionPerformed(ActionEvent e) {
               JOptionPane.showMessageDialog(null, "Up");
     class RightAction extends AbstractAction {
          private static final long serialVersionUID = 1L;
          public RightAction(String text, String desc) {
               super(text);
               putValue(SHORT_DESCRIPTION, desc);
          public void actionPerformed(ActionEvent e) {
               JOptionPane.showMessageDialog(null, "Right");
     class LeftAction extends AbstractAction {
          private static final long serialVersionUID = 1L;
          public LeftAction(String text, String desc) {
               super(text);
               putValue(SHORT_DESCRIPTION, desc);
          public void actionPerformed(ActionEvent e) {
               JOptionPane.showMessageDialog(null, "Left");
}When you run that, click Load Character, then just click OK. If you press the arrow keys, corresponding alerts should come up. Now, if you rerun the program, and edit the JPasswordField in any way, then click OK, if you press the arrow keys, nothing happens. Somehow, by editing the password field, key bindings get messed up.
Does anyone know why this happens and how to fix it?

Eh, I hate it when this happens, but I figured it out not long after I posted this. Sorry.
The problem was the Load Character screen was not being removed properly due to bad technique that I got from a source on Google. So the password field, which (if I understand properly) disables key bindings for security when it has the focus, or something along those lines, was not allowing the key bindings to happen.
To see further evidence, try editing the password field, then place the cursor in the top field (that says "Default") and click OK. It works.
Anyway, to fix the above code, I just changed the cases of TestLoadCharacterPanel.this (which didn't make any sense anyway) to this, which I didn't think would work, since it's an embedded class. But it did.
Sorry for the pointless post.

Similar Messages

  • Control-k key binding broken. How can I check and change my key bindings?

    I use the Terminal app a lot. Unfortunately I am not able to use the control-k shortcut to cut lines in the terminal anymore. How can I check (and change) the Terminal key bindings?
    Thank you!

    Basing on your input, you should get the following values:
    1) session keys
    SK_ENC: 6DCE2A99BACB5207A7A96A92F114D66C
    SK_MAC: 0D446132B168F75CD6F0A780693A4DD3
    SK_DEK: 19F7B0F94837F32874B29B5EFB7809F6
    2) host cryptogram
    1B781553209748EA
    3) Retail MAC
    01761103B810F00E
    Summing up, the External Authenticate command should have the following value:  84 82 01 00 10 1B781553209748EA 01761103B810F00E.
    Try to compare it with your results.
    Regards

  • Key Bindings using the arrow keys

    Following is some code that allows you to move a component around the screen using the arrow keys. I've noticed a problem and I'm just wondering if its Java or my keyboard.
    Lets start with an example that works:
    Press the down and right keys. Then press either the up or left key. The image moves proving that it supports 3 keys.
    Now for the problem:
    Press the up and left keys. Then press either the down or right key. Three things to notice:
    a) the direction doesn't change when the third key is pressed
    b) no output is displayed, so the ActionListener is not being invoked
    c) after a short time, the program starts beeping
    Now try rerunning the code after removing the comments that assign the key bindings to the "a, s, d, f" keys. Redo the above test and it works even if all four keys are pressed.
    I don't remember this problem when I wrote the code a while ago, but I did recently get a cheap new keyboard so I'm just wondering if the problem is my keyboard or whether its a quirk with Java.
    You can download Duke from here:
    http://java.sun.com/docs/books/tutorial/uiswing/examples/components/LayeredPaneDemoProject/src/components/images/dukeWaveRed.gif
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class KeyboardNavigationProblem implements ActionListener
         private JComponent component;
         private int deltaX;
         private int deltaY;
         private Timer timer;
         private int keysPressed;
         private InputMap inputMap;
         public KeyboardNavigationProblem(JComponent component, int delay)
              this.component = component;
              this.deltaX = deltaX;
              this.deltaY = deltaY;
              timer = new Timer(delay, this);
              timer.setInitialDelay( 0 );
              inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
         public void addAction(int keyCode, String description, int deltaX, int deltaY)
              new NavigationAction(keyCode, description, deltaX, deltaY);
         public void updateDeltaX(int delta)
              deltaX += delta;
         public void updateDeltaY(int delta)
              deltaY += delta;
         public void actionPerformed(ActionEvent e)
              int componentWidth = component.getSize().width;
              int componentHeight = component.getSize().height;
              Dimension parentSize = component.getParent().getSize();
              int parentWidth  = parentSize.width;
              int parentHeight = parentSize.height;
              //  Determine next X position
              int nextX = Math.max(component.getLocation().x + deltaX, 0);
              if ( nextX + componentWidth > parentWidth)
                   nextX = parentWidth - componentWidth;
              //  Determine next Y position
              int nextY = Math.max(component.getLocation().y + deltaY, 0);
              if ( nextY + componentHeight > parentHeight)
                   nextY = parentHeight - componentHeight;
              //  Move the component
              component.setLocation(nextX, nextY);
         class NavigationAction extends AbstractAction implements ActionListener
              private int deltaX;
              private int deltaY;
              private KeyStroke pressedKeyStroke;
              private boolean listeningForKeyPressed;
              public NavigationAction(int keyCode, String description, int deltaX, int deltaY)
                   super(description);
                   this.deltaX = deltaX;
                   this.deltaY = deltaY;
                   pressedKeyStroke = KeyStroke.getKeyStroke(keyCode, 0, false);
                   KeyStroke releasedKeyStroke = KeyStroke.getKeyStroke(keyCode, 0, true);
                   inputMap.put(pressedKeyStroke, getValue(Action.NAME));
                   inputMap.put(releasedKeyStroke, getValue(Action.NAME));
                   component.getActionMap().put(getValue(Action.NAME), this);
                   listeningForKeyPressed = true;
              public void actionPerformed(ActionEvent e)
                   if (listeningForKeyPressed)
                        updateDeltaX( deltaX );
                        updateDeltaY( deltaY );
                        inputMap.remove(pressedKeyStroke);
                        listeningForKeyPressed = false;
                           if (keysPressed == 0)
                                timer.start();
                     keysPressed++;
                   else // listening for key released
                        updateDeltaX( -deltaX );
                        updateDeltaY( -deltaY );
                        inputMap.put(pressedKeyStroke, getValue(Action.NAME));
                        listeningForKeyPressed = true;
                        keysPressed--;
                           if (keysPressed == 0)
                                timer.stop();
                   System.out.println(KeyboardNavigationProblem.this.deltaX + " : "
                   + KeyboardNavigationProblem.this.deltaY);
         public static void main(String[] args)
              JPanel contentPane = new JPanel();
              contentPane.setLayout( null );
              JLabel duke = new JLabel( new ImageIcon("dukewavered.gif") );
              duke.setSize( duke.getPreferredSize() );
              duke.setLocation(100, 100);
              contentPane.add( duke );
              KeyboardNavigationProblem navigation = new KeyboardNavigationProblem(duke, 100);
              navigation.addAction(KeyEvent.VK_LEFT, "zLeft", -5, 0);
              navigation.addAction(KeyEvent.VK_RIGHT, "zRight", 5, 0);
              navigation.addAction(KeyEvent.VK_UP, "zUp", 0, -5);
              navigation.addAction(KeyEvent.VK_DOWN, "zDown", 0, 5);
    //          navigation.addAction(KeyEvent.VK_A, "zLeft", -5, 0);
    //          navigation.addAction(KeyEvent.VK_S, "zRight", 5, 0);
    //          navigation.addAction(KeyEvent.VK_D, "zUp", 0, -5);
    //          navigation.addAction(KeyEvent.VK_F, "zDown", 0, 5);
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.setContentPane( contentPane);
              frame.setSize(800, 600);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }

    if you hold down left and right (so it doesn't move), down works, but not up.
    hold up/down, right works but not left.Yes, the problem only seems to be when the up and left in combination with the right or down key is pressed.
    num lock off - use the number pad arrow keys and all works OK Thats interesting, I didn't notice that. Although it just confuses the issue as to what the problem is.
    So it appears to me that:
    a) left + up + down, and
    b) left + up + right
    are special key combinations that are intercepted by either the OS or the JVM. Do these key combinations ring a bell to anybody?
    I'm use JDK1.4.2 on XP. I wonder if other OS will have the same problem?
    Again, this isn't a real, problem, just more of a curiosity. Thanks,

  • Problem: sqldeveloper 1.5 key bindings in mac os x

    Hi -
    I just installed the new sqldeveloper (1.5.0.53.38) on Mac OS X Leopard, and when I try to edit sql queries in the worksheet, I'm finding that many keys don't work. For example, the spacebar and delete keys do nothing.
    I tried loading various different accelerator presets:
    - after loading "Default MacOS X" set, neither space nor delete keys do anything
    - after loading "Default", "Classic" or "Brief" sets, the spacebar works, but not delete
    I tried to fix this by changing the accelerators through the Preferences UI, but I couldn't figure out how to assign the 'backspace' key to the 'delete-previous' accelerator (since it doesn't seem possible to type the actual backspace character in the keystroke box...). I was able to fix the delete key by editing settings.xml by hand, changing this:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">delete-previous</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">[0]</Item>
    </data>
    </second>
    </Item>
    to this:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">delete-previous</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">[8]</Item>
    </data>
    </second>
    </Item>
    I was able to get the spacebar to work again by removing the association between the spacebar key and the completion-insight accelerator, using the Preferences UI.
    So, my questions are:
    - Do I have some weird setup where my delete key is [8] instead of [0]? I'm trying to tell if this is a problem with my environment or with the settings that are shipped with the product.
    - If it's the latter, could the default MacOS X accelerator settings be updated? I seem to remember this same problem happening the last couple of times I installed a new version of SQL Developer.
    Let me know if there's any other information I could provide that would be useful.
    Thanks!

    Another problem I found with the MacOS X key bindings: the 6 key doesn't work!
    In the config that ships with SQL Developer, I found this:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">6</Item>
    </data>
    </second>
    </Item>
    which should be:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">meta 6</Item>
    </data>
    </second>
    </Item>

  • Cut/Copy/Paste - How to set the key bindings ?

    Hi,
    I'm currently using the motif LnF in Windows. It matches the colors and style I want.
    The problem is: people using Windows want to use the standard windows key bindings (that is: CTRL+V, CTRL+C, CTRL+X) instead of the Motif ones.
    Does anyone how to set the old Windows key bindings into the Motif LnF ?
    If anyone can provide some light, it'd be great !
    Regards,
    - Juancho

    The Swing tutorial on "General Rules for Using Text Components" has a demo program that shows you how to assign KeyStrokes to Actions.
    Unfortunately the demo has not been updated in a while and still uses a keymap. The new approach would be to use an 'inputMap' and an 'actionMap'. The code for the copy action would be something like this:
    textComponent.getInputMap().put(keyStroke, "copy");
    textComponent.getActionMap().put("copy", action);
    Again, the demo program 'TextComponentDemo' from the above tutorial will show you how to:
    1) create the keyStroke for Ctrl+C
    2) retrieve the default copy action from the editor kit

  • Problem changing default key bindings using Oracle Terminal

    Hello,
    I'm facing a problem changing default key bindings using Oracle Terminal. I changed
    some bindings, saved them in forms60/fmrusw.res, started the generation and saved again.
    I thought that's it but it wasn't. It took no effect at all in Forms (even after recompilation) although reopening the file in Terminal showed the changes. I'm using Forms in German, which means that even the key bindings displayed in Forms are translated i.e. STRG+F1 instead if CTRL+F1,
    but I can't find a german version of this resource file, so i think it's the same resource file for all supported languages. But what is needed for the changes to take effect ?
    Thanks in advance
    STD
    null

    Hi,
    is it client/server you are working?
    if so you should not be using the fmrusw.res file because I guess your NLS_LANG is German_Germany.WE8ISO8859P1 or something like that. This means the terminal that is being opened is fmrdw.res instead of fmrusw.res and this file should be edited using Oracle Terminal.
    if you are working via the web implementation than you can open the file fmrweb.res in a text editor and change the keybindings in there. If you need to have the PC like key bindings on the web just open the fmrpcweb.res and see if it contains the German texts. If so you can either copy this file over the frmweb.res file or you can specify term=fmrpcweb.res in the serverargs parameter.
    Hope this helps.
    Kind regards,
    Frank van der Borden
    Oracle Support Services
    Netherlands

  • Forms Key-Bindings in Windows

    Is there any way to disable the key bindings in a forms
    application without editing the windows resource file
    (FMRUSW.RES) in Oracle Terminal? I know that the key-bindings
    can be suppressed in the Key-Others trigger, but how do you refer
    to the specific key you want to disable?
    Any help is appreciated. Thanks in advance.
    null

    Hi
    There are over 1000 user-definable key commands in Logic, with many already defined in a variety of presets. I'd suggest using the standard US set (with no numbers keys)
    http://documentation.apple.com/en/logicpro/usermanual/index.html#chapter=8%26sec tion=4%26tasks=true
    HTH
    CCT

  • How to customize key bindings, say emacs-like.

    I have been able to install keyconfig, but I can't find the code for simple things like:
    forward-char
    backward-char
    move-beggining-of-line
    move_end-of-line
    and other emacs-like commands.
    The page
    http://kb.mozillazine.org/Keyconfig_extension:_Thunderbird
    has a long list of command I can shortcut, but none of the simple ones I need to navigate
    the composition window, in emacs-like style.

    Yes, left and right arrows do the job, as well as Home and End keys. However, being a regular emacs user, it takes me less time and comes more natural to find C-f, C-b, C-a and C-e on the keyboard.
    I actually have TB on two machines, home and work. In one of them the emacs-like key bindings work, but not on the other machine, even though they are running the same version of Mac OS and TB.

  • Changing key bindings in xcode

    I have quite a simple problem: a good portion of the key bindings i set in Xcode simply don't work.
    Example: I set "code sense select next placeholder" as command+E on my desktop..yet on my laptop when I set it to that, it just beeps when I push command+E.
    Second Example: I want to change the default key for popping up the class/method list [currently control+2], but it won't let me change it to command+2, or most other things for that matter. I've had so many problems I don't think ALL of the conflicts can be system/xcode presets that are unchangable.
    How do I force Xcode to use the key bindings I want?
    alternately: How do I see which programs are keeping Xcode from recognizing the key bindings I set?
    Thanks,
    Nick

    xcode 3 fixed this problem. hooray!

  • Terminal key bindings for Home and End

    I am recording this here in the hope of savings others some time.
    It is often stated that the following Terminal key bindings have to be asserted to get Home and End keys working as intended:
    \033OH
    \033OF
    I find this misleading as it is neither what most people would type nor what they would see.
    I type:
    escape O H
    escape O F
    This results in:
    \033oh
    \033of
    which works as intended but using 'shift' to produce the capitals depicted in most notes about this will not work.

    My default bindings did not work for home and end but page up and page down inexplicably worked with shift. The image below shows the keys and their bindings (eg \033[5~ and \033[6~ stated here for Google!) I applied to Terminal to make home, end, page up and page down behave in the same way as many other applications including iTerm. Remember to type 'esc' to get '\033'.
    I started out trying to improve the readability of large manual pages (eg man bash). Whilst the changes above improved things considerably I have now found better alternatives.
    I tried iTerm - the keys worked correctly but inconsistencies between the various window size settings did not inspire confidence.
    I now use ManOpen.app which I have configured to open when I type eg 'm chmod' in Terminal - I changed the name of openman to m and put it together with openman.1 in /usr/bin. The pages scroll normally and have hot links to other manual items. This is a simple way to vastly improve manual reading. The only slight negatives I have found are:
    1 - two preference panes will not open - defaults OK for me
    2 - window positions not remembered - since size can be set I can live with this
    3 - text cannot be set to soft wrap to window width (misnamed zoom by some applications).
    I would be interested to hear if others have found better ways of viewing manuals.
    Here are some interesting pages:
    http://en.wikipedia.org/wiki/Tableof_keyboard_shortcuts#Command_lineshortcuts
    http://www.tuaw.com/2008/03/07/here-comes-your-man-viewer/

  • How to modify Emacs key bindings in XCode?

    I'm trying to do an emacs "undo" (ctrl-_) and it doesn't work. How do I add this key binding? Is it possible? I'm really trying to use XCode instead of Eclipse, but I'm having a hard time configuring XCode to have all the nice features I use in Eclipse.
    Thanks,
    Alfredo

    Have you tried this?
    1) Xcode menu > Preferences > Key Bindings > Edit
    2) Find the Undo command
    3) Click on Command-Z then hold down ctrl and shift and underscore
    4) Click on Apply
    Bob

  • Portable xterm key bindings

    Hi all,
    I'm looking for a way to define xterm/bash key bindings in a portable/transferable way. Nothing fancy, I'd just love to use Ctrl+Backspace as "backward-kill-word", Alt+d as "kill-word" and so on. So far I had to define a bunch of key bindings in my .bashrc, but what about all those ssh sessions I open?
    Is there a way to automatically transfer key bindings from localhost to any ssh target? Are there terminal emulators other than xterm that can handle this in a sane way?
    To complicate it further, I can't always install my favorite keymaps at work. We do share accounts on some of our servers, my colleagues aren't keen to use my keybindings 'cause they don't seem to work for them.
    I can't even remember how long I've been fighting by this problem, still I don't see any solution for that. Any help is highly appreciated.

    Why not store your ~/.Xmodmap file in the cloud somewhere, then download it where and when you need it. Better yet, install Dropbox on all your machines so that those files you need on each computer sync each time you change them ??

  • InputMap/ActionMap key bindings for arrow keys, alt key

    I'm having trouble defining InputMap/ActionMap key bindings for the arrow keys and the Alt key. My bound actions never run. I believe the problem is that the arrows are used in focus navigation, and the Alt key is used for opening the menu. How can I get these key bindings to work? Is there any other way that I can get events from these keys? I'd even be happy with simple AWT KeyListener events at this point. Thanks.

    I've been having this same problem. I built a demo application that demonstrates the problem. It all works fine until I add the JTree. The JTree seems to be consuming the arrow key strokes. Here is the code:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    public class ArrowKeyDemo extends JFrame implements ActionListener {
        private javax.swing.JTree tree;
        private javax.swing.JPanel panel;
        public ArrowKeyDemo() {
            initComponents();
            panel.registerKeyboardAction(this, "A",
                    KeyStroke.getKeyStroke(KeyEvent.VK_A, 0, false),
                    JComponent.WHEN_IN_FOCUSED_WINDOW);
            panel.registerKeyboardAction(this, "left",
                    KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false),
                    JComponent.WHEN_IN_FOCUSED_WINDOW);
        private void initComponents() {
            panel = new javax.swing.JPanel();
            tree = new javax.swing.JTree();
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            panel.add(tree);
            getContentPane().add(panel, java.awt.BorderLayout.CENTER);
            pack();
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
        public static void main(String args[]) {
            new ArrowKeyDemo().show();
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println(actionEvent);
    }Having the JTree in there kills the ability to trap key strokes for any other purpose. This seems to be true of other Swing components as well. You can stop the JTree from consuming key strokes by adding the line:
    tree.setActionMap(null);
    But you will probably need to set the ActionMap to null for every Swing component that is trapping key strokes. I'm not 100% sure, but I think that includes scroll panes as well.
    I'd love to hear a more elegant solution.
    --Timothy Rogers

  • Customize key bindings in AS Editor?

    I am learning Flash CS4, and I would love to be able to customize the key bindings in the ActionScript editor. Ideally I'd like to be able to use Emacs bindings (e.g. CTRL-n to go to next line, CTRL-a to go to beginning of line, etc.), but I don't see any way to set this kind of information. As powerful as I am finding Flash, I am a bit surprised at the limitations of the editor. I can't help but feel I'm missing something, but I haven't been able to successfully search for a way to customize the editor on the web. Any help would be greatly appreciated!

    Thanks for replying, kglad. I don't think "Edit -> keyboard shortcuts" is quite what I'm looking for. While it allows you to change an existing shortcut key combination, I'm not trying to run actions from the toolbar, I am trying to perform basic in-editor actions. I would like to be able to use CTRL-f to move the cursor one character forward, CTRL-p to move the cursor to the previous line, CTRL-e to move the cursor to the end of the line, etc. instead of having to use the arrow keys, or the home/end keys.
    Basically I am trying to get the editor to emulate Emacs key bindings, which I have been able to do in IDEs that I've used in my Java development. I was wondering if there was a way to do the same in Flash. Thanks!

  • Terminal Key Bindings

    I have noticed when using terminal. If I launch some in terminal applications, the key bindings for some keys no longer seem to work. Of primary concern are 'up arrow', 'dn arrow' and 'backspace'.
    I know I can go into the Terminal menu -> Window Settings and launch the Terminal Inspector to remedy, but I can't quite figure out how.
    The backspace seems to repair by setting "Delete sends backspace" I thought I could fix Up arrow by setting the key mapping to "\UF700" but I could only get it to enter as \\UF700 and that did not seem to work.
    Any ideas on mapping the up arrow and dn arrow keys?

    You can use the bindkey command for setting the keymap.
    E.g. bindkey -k up up-history. This bind the command up-history to the up arrow key. Without the -k option is this the characters ^[[A for up ^[[B down
    ^[[C right and ^[[D left.
    For an individual keymap use bindkey ^[t clear-screen. The character ^ is the sign for the controll key, t stands for an individual character and clear-screen is the command.
    Write this into the .cshrc if you use the tcsh shell.
    In the bash it is easier.
    The arrow map used nearly the same characters as in the tcsh.
    "\e[A": up-history is the map for the up arrow
    For an individual key is this:
    Control-t:clear-screen.
    Write these into the .inputrc file.
    The default settings for the arrow keys are: up-history, down-history, backward-char and forward-char.

Maybe you are looking for

  • Zend AMF extremely slow first request

    Hi all, I'm having a weird problem with Zend AMF and was wondering if anyone else has seen this before. I've got a very simple PHP/MySQL backend that returns multidimensional arrays to Flex via Zend AMF. Now this all worked fine up to the point that

  • Search help on custom screen

    Hi, I have a question regarding search help on screen. I have searched, but did not find anything for my requirement. Here is my requirement............... I have a drop down on one of the field of the custom screen. This dropdown has three items to

  • In xcode i deleted my default.png file and know my app says 0 target and missing base sdk how can i fix this please

    please help mw fix my app i deleted my default .png file the one that displays an image when u first run the the and after i deleted my app wont run and says at the very top 0 target , missing base sdk. how can i fix this please help.

  • Saving NSView to Bitmap - (ScrollView)

    I have an NSView subclass called StretchView. Here's what I want to do: Since the StretchView has scrollbars and is extended via those scrollbars I want to be able to grab the entire StretchView (including the area not visible on screen) and save tha

  • Some gap bettween my tabbedpane and vbox.

    Hi i have placed one tabbed pane in my application. and 4 vboxes in that. I have put some wipedown effect for my vboxes and for my tabbed pane i have put green color. My intenction is the green color willbe visible for the user at the time of swichin