Changeset 7545 in josm for trunk/src/org


Ignore:
Timestamp:
2014-09-16T19:15:00+02:00 (10 years ago)
Author:
Don-vip
Message:

fix issue with ExtendedDialog where default button cannot be activated with Enter if focus is on a multiline label

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java

    r7434 r7545  
    1111import java.awt.Toolkit;
    1212import java.awt.event.ActionEvent;
     13import java.awt.event.KeyEvent;
    1314import java.util.ArrayList;
    1415import java.util.Arrays;
     
    209210     *
    210211     * @param content Any element that can be displayed in the message dialog
    211      * @param placeContentInScrollPane if  true, places the content in a JScrollPane
     212     * @param placeContentInScrollPane if true, places the content in a JScrollPane
    212213     * @return {@code this}
    213214     */
     
    447448    private void setupEscListener() {
    448449        Action actionListener = new AbstractAction() {
    449             @Override public void actionPerformed(ActionEvent actionEvent) {
     450            @Override
     451            public void actionPerformed(ActionEvent actionEvent) {
    450452                // 0 means that the dialog has been closed otherwise.
    451453                // We need to set it to zero again, in case the dialog has been re-used
     
    608610    /**
    609611     * Convenience function that converts a given string into a JMultilineLabel
    610      * @param msg
    611      * @return JMultilineLabel
     612     * @param msg the message to display
     613     * @return JMultilineLabel displaying {@code msg}
    612614     */
    613615    private static JMultilineLabel string2label(String msg) {
     
    616618        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    617619        lbl.setMaxWidth(screenSize.width/2);
     620        // Disable default Enter key binding to allow dialog's one (then enables to hit default button from here)
     621        lbl.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), new Object());
    618622        return lbl;
    619623    }
Note: See TracChangeset for help on using the changeset viewer.