How to Remove Spacebar event from JFormattedTextField/JTextField

Hello Friend,I have problem about JTextField.I want to remove or unregister Spacebar event from JTextField. I have used KeyMap,InputMap,also.So please help me
[186 byte] By [hitesh_karela] at [2007-11-27 7:57:50]
# 1

I found it easier to put a keyup event on the input field and checking the data that is entered. If it does not validate I do the following:

1. I disable the ok button

2. I show an error message

the "netbeans" way to do it and for me this is the most user friendly, and the easiest to implement.

gimbal2a at 2007-7-12 19:39:43 > top of Java-index,Desktop,Core GUI APIs...
# 2

Hello Friends,

That is not ficiable for me.Actuall that JTextField is already use Document listener and focus listener and HexFormatter.

In sort i am making a JFormattedTextField as Hex JTextField which will validate only 0-9 and a-f And A-F will be valide entry and remail it will ignore.

I have made that one .but we require output like

45 56 89 a4 59

Here space will generate by programmer not user,he will enter only data....so i want remove space bar

i have used this way but that is not working

KeyMap space=txtBox.getKeymap()

KeyStroke stroke=KeyStroke.getKeyStroke

(KeyEvent.VK_SPACE,0);

space.removeKeyStrokeBinding(stroke);

but this not working

hitesh_karela at 2007-7-12 19:39:43 > top of Java-index,Desktop,Core GUI APIs...
# 3

JTextField textField = new JTextField();

textField.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyPressed(java.awt.event.KeyEvent e) {

if (e.getKeyCode() == KeyEvent.VK_SPACE) {

e.consume();

}

}

});

c0demonk3ya at 2007-7-12 19:39:43 > top of Java-index,Desktop,Core GUI APIs...
# 4
HI,That is also not working.....still space is generating by space bar
hitesh_karela at 2007-7-12 19:39:43 > top of Java-index,Desktop,Core GUI APIs...
# 5

> HI,

> That is also not working.....still space is

> generating by space bar

Yes it's generated but is immediately consumed in the event listener. If you have another listener which is firing before the key down event then you will have to check if the source is the space bar and consume it there

c0demonk3ya at 2007-7-12 19:39:43 > top of Java-index,Desktop,Core GUI APIs...
# 6
is there any way by which i can remove spacebar event from jtextfieldSince checking event is problematic....because already i have used Document listener with this textbox....which will be problematic
hitesh_karela at 2007-7-12 19:39:43 > top of Java-index,Desktop,Core GUI APIs...
# 7
You where already given this answer 3 days ago when you asked the same question. Quit wasting everybodies time and read your old postings.
camickra at 2007-7-12 19:39:43 > top of Java-index,Desktop,Core GUI APIs...