Java Code Examples for javax.swing.JComponent.addKeyListener()

The following are Jave code examples for showing how to use addKeyListener() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Equella   File: FlatterButtonUI.java   View Source Code Vote up 6 votes
@Override
public void installUI(JComponent c)
{
	super.installUI(c);

	mBackgroundNormal = UIManager.getColor("Button.background");
	mBackgroundPressed = UIManager.getColor("Button.backgroundPressed");
	mBackgroundActive = UIManager.getColor("Button.backgroundActive");
	mTextNormal = UIManager.getColor("Button.textNormal");
	mTextPressed = UIManager.getColor("Button.textPressed");
	mTextActive = UIManager.getColor("Button.textActive");
	mTextDisabled = UIManager.getColor("Button.textDisabled");
	mBorder = UIManager.getBorder("Button.border");

	c.addKeyListener(this);
}
 
Example 2
Project: java-swing-template   File: Utilities.java   View Source Code Vote up 5 votes
public static void attachFocusMoveOnKey(JComponent current, final JComponent target, final int keyCode) {
    current.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == keyCode) {
                target.requestFocusInWindow();
            }
        }

    });
}