This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
The New > Sample Forms > OKCancelDialog does not conform to JLF or accessibility requirements. It should have a default button (set using JRootPane.setDefaultButton()) which responds to the "Enter" key. Also, the cancel button should respond to the "Esc" key. Similarly, the Sample Forms > Application and MDI Application forms should have mnemonics on the menu items. These are simple fixes that would enable developers to start creating accessible applications.
reassigned
Target milestone -> 3.3.1.
Set target milestone to TBD
Yes, that's true and still valid issue. Reassigne to form for evaluation, it is probably usersguide's issue ;)
We will rethink meaning and form of these templates for the next release.
*** Issue 106315 has been marked as a duplicate of this issue. ***
Yes, I always need to code myself Escape/Enter keys handling for each OK/Cancel dialog. Please change the template to contain code like following: getRootPane().setDefaultButton(this.okButton); Action cancelKeyAction = new AbstractAction("Cancel") { public void actionPerformed(ActionEvent e) { doClose(RET_CANCEL); } }; cancelButton.setAction(cancelKeyAction); String cancelName = "cancel"; InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = getRootPane().getActionMap(); KeyStroke cancelKeyStroke = KeyStroke.getKeyStroke((char) KeyEvent.VK_ESCAPE, 0); inputMap.put(cancelKeyStroke, cancelName); actionMap.put(cancelName, cancelKeyAction);
Jaro, thanks for the suggestion. Attaching a patch. However, after I clean&build form module locally and restart with new userdir I still don't see the change in newly created classes in a testing project. Tomasi, Honzo, is the patch OK?
Created attachment 105242 [details] patch
> Tomasi, Honzo, is the patch OK? No, it is not. First of all, the patch changes just .java files. The changes must be done in .form files as well (in fact, they must be done in .form files primarily). Mnemonics are set incorrectly. Swing components don't support setting of mnemonics using ampersand (i.e., '&' character) in their text. The new code in OK/Cancel dialog uses several new local variables. I would be very careful with them. They can clash with the user-created components with the same names. Final nitpick: Why there is a cast in javax.swing.KeyStroke.getKeyStroke((char) java.awt.event.KeyEvent.VK_ESCAPE, 0); doesn't javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0); work as well?
Fixed. Modified files: http://hg.netbeans.org/core-main/rev/360791497b7f
Thanks, Honzo!