

Enter key does not work after encoding with java
source link: https://www.codesd.com/item/enter-key-does-not-work-after-encoding-with-java.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Enter key does not work after encoding with java
i get a trouble when i write this code for a jButton to open new jfame and all that is by using the "Enter key" but it didn't work ,this the code i have writen :
if(evt.getKeyCode()==KeyEvent.VK_ENTER){
Chooser ch = new Chooser();
ch.setVisible(true);
}
So! why? Please help me and thanks.
Buttons don't need a KeyListener
(and for the most part shouldn't use them), they use an ActionListener
to respond to all activation events, including the action key (which isn't always the Enter), mouse clicks, keyboard shortcuts and programmatically triggered events, it's a much more simplified API.
See How to Use Buttons, Check Boxes, and Radio Buttons, How to Write an Action Listeners and How to Use Actions for more details
You can also set a button as the "default" button which can be activated when not focused (so long as the currently focused component doesn't use/consume the Enter key)
See JRootPane#setDefaultButton
and How to Use Root Panes for more details
Related Articles
pressing the ENTER key does not work for TextField in the applet
HTML Form - Triggering the form using the Enter key does not work when the focus is on a selected list
The ENTER key does not work correctly
adapt.notifyDataSetChanged does not work after searching with the search view
Datatable filtering Primefaces on the Enter key does not work
Java 7 features does not work on Ubuntu with java version & ldquo; 1.7.0_51 & quot;
jquery .html load html to div form key does not work
datepicker on an ASP text box does not work after a return event
Google Maps V2 does not work in production with the correct key
Jquery textarea append does not work after the text box has been reset with val (& ldquo; & rdquo ;;)
On click does not work after inserting dynamic HTML with jquery
Delete key does not work
Self-signed SSL does not work after upgrading from iojs to nodejs v4.4.4
The Asp button does not work after clicking the RadGrid Export to Excel button
Recommend
-
8
Java String split does not work advertisements Java Experts , Please look into the below split command code and let me know why last tw...
-
6
Shein to re-enter India one year after the Chinese apps ban- PingWestShein to re-enter India one year after the Chinese apps ban July 14, 2021 7:46 am Chinese e-commerce store Shein will make a comeback in India as a seller of Amazon’s...
-
8
Xperia SP does not enter fastboot mode ...
-
9
Half-Life 2 VR mod to enter public beta next month after five years in development Fans have been waiting since 2017 By
-
7
Alt-Enter Doesn't Window DOS Graphics in XP (Used to work in NT & W2K) Discussion:
-
8
VR Set To Enter New Phase After A Decade Of Carmack ...
-
4
Why does my SSH private key still work after changing some bytes in the file? Cryptography Stack Exchange is a question and answer site...
-
11
Java source code could switch to UTF-8 encoding The current state of ‘ill-defined encoding’ creates unnecessary problems when working with the JDK codeba...
-
3
Secure Java URL encoding and decodingWritten by: Jura Gorohovsky
-
6
When does it make sense to enter diverse accounts for different Depreciation Area in the FI-AA? ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK