key-events

ENTER key using in JTextField java

一个人想着一个人 提交于 2019-11-28 13:53:45
I'm using two JTextField in Java Swing form. Now I enter the values in JTextField1 . Next if I press ENTER KEY means the cursor move to JTextField2 . How to do this? camickr Add an ActionListener to the first text field. In the ActionEvent you can get the source object, cast it to a JTextField and then invoke the transferFocus() method. Use actionListener for the textField . Code snippet: textField1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ textField1.transferFocus(); } }); 来源: https://stackoverflow.com/questions/8585544/enter-key-using-in-jtextfield

Fire a JButton with spacebar, or enter key, or mouse click

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 05:30:16
问题 I'm trying to get a simple JFrame with a single button to fire an event when any of these events happen: The Enter key is pressed AND the JButton has focus The Spacebar is pressed AND the JButton has focus The JButton is clicked. It seems that the Enter and Spacebar come "for free" along with the default mouse click using addActionListener on the JButton; trouble is, I've read that the the key bindings are dependent on the Look and Feel used. I've tried to get universal behavior across LaF by

Always in upper case… (C# winforms)

六月ゝ 毕业季﹏ 提交于 2019-11-28 02:02:23
I have a TextBox in my form and I added this event on it: private void txtValue_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyData.ToString()); } But it always prints the upper case of the letter even though I entered a lower case letter in the textBox. Please see image below: How should I get the right display? Thanks... KeyDown and KeyUp use KeyEventArgs , which exposes the Keys enum via the KeyData property. The enum does not have representation for lower-case alphabetic values. http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx The KeyPress event allows

Use keyPressEvent to catch enter or return

你离开我真会死。 提交于 2019-11-27 18:30:02
问题 I have a simple form with some combos, labels, buttons and a QTextEdit. I try to catch the enter or return key with keyPressEvent, but for some reason I'm not able to. The ESC key however, that I also use, is recognized. Here's a piece of the code: def keyPressEvent(self, e): print e.key() if e.key() == QtCore.Qt.Key_Return: self.created.setText('return') if e.key() == QtCore.Qt.Key_Enter: self.created.setText('enter') if e.key() == QtCore.Qt.Key_Escape: self.cmbEdit = not(self.cmbEdit) if

KeyPressed and mousePressed Event in an unfocused Component

若如初见. 提交于 2019-11-27 15:12:42
What are several ways of detecting a key stroke without the need of focusing on the component that the event was implemented? Here's my idea on this: Even without focusing on myComponent , upon pressing a key, the action should take part. ** Same question for the mousePressed event. A mouse click will be detected even when not clicking on the component.** myComponent.addKeyListener( new KeyAdapter() { @Override public void keyPressed( KeyEvent e ){ // My action here } }); Upon answering Question1 , can it also be done even if the application is running on background? Say I have a browser,

Jquery: how to trigger click event on pressing enter key

本秂侑毒 提交于 2019-11-27 10:26:35
I need to execute a button click event upon pressing key enter. As it is at the moment the event is not firing. Please Help me with the syntax if possible. $(document).on("click", "input[name='butAssignProd']", function () { //all the action }); this is my attempt to fire click event on enter. $("#txtSearchProdAssign").keydown(function (e) { if (e.keyCode == 13) { $('input[name = butAssignProd]').click(); } }); Vijay try out this.... $('#txtSearchProdAssign').keypress(function (e) { var key = e.which; if(key == 13) // the enter key code { $('input[name = butAssignProd]').click(); return false;

ENTER key using in JTextField java

蹲街弑〆低调 提交于 2019-11-27 08:02:39
问题 I'm using two JTextField in Java Swing form. Now I enter the values in JTextField1 . Next if I press ENTER KEY means the cursor move to JTextField2 . How to do this? 回答1: Add an ActionListener to the first text field. In the ActionEvent you can get the source object, cast it to a JTextField and then invoke the transferFocus() method. 回答2: Use actionListener for the textField . Code snippet: textField1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){

Always in upper case… (C# winforms)

﹥>﹥吖頭↗ 提交于 2019-11-26 23:37:15
问题 I have a TextBox in my form and I added this event on it: private void txtValue_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyData.ToString()); } But it always prints the upper case of the letter even though I entered a lower case letter in the textBox. Please see image below: How should I get the right display? Thanks... 回答1: KeyDown and KeyUp use KeyEventArgs , which exposes the Keys enum via the KeyData property. The enum does not have representation for lower-case

KeyPressed and mousePressed Event in an unfocused Component

和自甴很熟 提交于 2019-11-26 17:07:26
问题 What are several ways of detecting a key stroke without the need of focusing on the component that the event was implemented? Here's my idea on this: Even without focusing on myComponent , upon pressing a key, the action should take part. ** Same question for the mousePressed event. A mouse click will be detected even when not clicking on the component.** myComponent.addKeyListener( new KeyAdapter() { @Override public void keyPressed( KeyEvent e ){ // My action here } }); Upon answering

Get a key from JTextArea

与世无争的帅哥 提交于 2019-11-26 15:33:48
All I want to do, If I'm pressing '{' this key in JtextArea.automatically '}' this will be print also. if(evt.KEY_PRESSED == '{') System.out.print("}"); is this is okay?? for listening changes into JTextComponent is there DocumentListener, if you have to need control over inputed Char, sings, whitespace chars or word(s) you have to implements DocumentFilter notice for Chars reservated by programing language(s) you have to use double escapes, \\( instead of ( or \\{ instead of { otherwise you get Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Illegal repetition