Bug 71018 - Keyboard focus is wrong in license dialog
Keyboard focus is wrong in license dialog
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Window System
5.x
All All
: P3 (vote)
: 6.x
Assigned To: issues@platform
issues@platform
issue_reviewed
: A11Y, FOCUS, SIMPLEFIX
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-04 20:37 UTC by _ tboudreau
Modified: 2009-09-11 21:52 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2006-01-04 20:37:15 UTC
Initial keyboard focus in the license dialog is on the JTextArea with the 
license text.  There is no visible indication of focus, since the caret is not 
visible because it is read only.

Pressing tab once sends focus to the scrollbar - also no visible indication of 
focus.

Pressing tab again moves focus to the Accept button.

Initial focus should be the accept button, so one keystroke can dismiss the 
dialog.

P2 because for anyone installing from a non-installer distribution (such as on 
Macintosh), the *very first* impression they will get from NetBeans - the very 
first thing they will ever see of NetBeans - is a dialog with poor focus 
behavior and no visible response the first time tab is pressed.  That's not 
exactly starting off on the right foot.
Comment 1 Roman Strobl 2006-01-11 12:55:07 UTC
I'm not sure where this belogs... please evaluate.
Comment 2 David Simonek 2006-01-11 13:53:40 UTC
Belongs to Marek AFAIK, not sure which component though.
Comment 3 Marian Mirilovic 2006-01-11 14:02:14 UTC
Reproducible on Lin ...
Comment 4 mslama 2006-01-11 14:04:39 UTC
Jesse in issue #64286 asked to put focus on license text. (Logical as user
should first review whole license text.) As focus cannot be at 2 places at the
same time please agree on right place for initial focus.
Comment 5 Marian Mirilovic 2006-01-11 14:09:34 UTC
Agreed, the user has to be forced to go through the text. 
I think it's usual way Licence Agreement dialogs do.
Comment 6 _ tboudreau 2006-01-11 19:12:24 UTC
I tend to disagree (since nobody actually reads the license text in practice 
unless they're a license nut), but regardless, the next stop from the license 
field shouldn't be the scrollbar.

I've seen it done both ways - many apps put focus on the accept button, not 
the license.  And if we really want to have the best of both worlds, take the 
down and up arrow key actions and bind them in the JRootPane of the dialog so 
up and down arrows work no matter where focus is.
Comment 7 Jesse Glick 2006-01-11 23:27:00 UTC
Re. focus going to the scrollbar - this is at the discretion of the LaF. JDK 1.4
will send focus to the scroll bar. As of JDK 5's Ocean it does not do this. At
least it works for me in 5.0u6 and Mustang - pressing TAB once puts focus on the
Accept button.

There is a mnemonic for Accept so you do not need to tab to it. Presumably this
is not available on Macs, but if you use a Mac you are volunteering to use the
mouse. Better might be to have no mnemonic for Accept but have it be the default
button so Enter works, and have no mnemonic for Exit since it matches behavior
of window close. (Cf. JLF guidelines.)

Binding Up and Down (and Page Up and Page Down) to corresponding actions in the
text field would work too, but it's extra work.
Comment 8 Jesse Glick 2006-01-11 23:31:34 UTC
For "have no mnemonic for Exit" read "have no mnemonic for Exit but bind
ESCAPE", which is what the JLF (and common sense) prescribes.

Don't see any jusitification for this to be P2. If you are using a modern JDK,
and you press TAB, you get focus sent to a button which you can press SPACE on;
or you can use Alt-A to begin with (on non-Mac platforms); or you can click with
the mouse, as most people probably do anyway since this dialog is not part of
routine daily workflow.
Comment 9 _ tboudreau 2006-01-12 06:45:09 UTC
> Re. focus going to the scrollbar - this is at the discretion of the LaF. JDK 
> 1.4 will send focus to the scroll bar.

I was using 1.4 when I encountered this, for reasons irrelevant here.

> There is a mnemonic for Accept so you do not need to tab to it. 

Mnemonics are not visible by default on win xp - not discoverable enough.

> Better might be to have no mnemonic for Accept but have it be the default
> button so Enter works

Haven't tried it, but AFAIK in any text control but a JTextField, it's Ctrl-
Enter, not Enter that invokes the default button.  A little non-intuitive.

> Don't see any jusitification for this to be P2.

A user's very first invocation of NetBeans shouldn't start with a dialog in 
which there is no obvious focus invocation, and in which keyboard interaction 
is not utterly intuitive.  That's the reason I made it P2.
Comment 10 Jesse Glick 2006-01-12 07:26:05 UTC
"Mnemonics are not visible by default on win xp" - exactly. They appear if and
when you press Alt. If you're a KB user on Windows you are presumably accustomed
to pressing Alt when you are looking for mnemonics.

"in any text control but a JTextField, it's Ctrl-Enter, not Enter that invokes
the default button" - yes, and it appears that's true even for noneditable text
fields. Fortunately it is easy to work around, e.g.

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
public class X extends javax.swing.JFrame {
    public X() {
        initComponents();
        getRootPane().setDefaultButton(accept);
       
getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("ESCAPE"),
"exit");
        getRootPane().getActionMap().put("exit", new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("exited");
            }
        });
       
pane.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),
"accept");
        pane.getActionMap().put("accept", new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("accepted");
            }
        });
    }
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        pane = new javax.swing.JEditorPane();
        exit = new javax.swing.JButton();
        accept = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        pane.setEditable(false);
        pane.setText("Blah blah blah\nblah blah blah\nho ho ho");
        jScrollPane1.setViewportView(pane);

        exit.setText("Exit");
        exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitActionPerformed(evt);
            }
        });

        accept.setText("Accept");
        accept.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acceptActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
               
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()
                        .add(accept)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(exit))
                    .add(jScrollPane1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
245, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
               
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(exit)
                    .add(accept))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>
    private void acceptActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("accepted");
    }
    private void exitActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("exited");
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new X().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton accept;
    private javax.swing.JButton exit;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JEditorPane pane;
    // End of variables declaration
}
Comment 11 mslama 2006-01-12 07:56:49 UTC
I recall on Linux, Solaris and Windows (where we provide regular installer) this
dialog is displayed ONLY when user does not use regular installer but use zip
distribution. (User must accept license in installer.) On these platforms only
minority of users do not use installer. On Mac OS X it is different as we
provide InstallShield installer only for asbundle. For NetBeans IDE we provide
tar ball (equivalent to zip distrobution) so user will see this dialog.

Mnemonic on Win L&F: Yes mnemonic is visible only when you press Alt but it is
default for all mnemonic (buttons, menus,...) so I do not see any reason why to
complain it is less visible.

Is solution to make Enter selecting Accept button enough for this issue? Many
thanks go to Jesse for hint. :)
Comment 12 Lukas Hasik 2008-04-10 21:21:51 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 13 Jaromir Uhrik 2009-05-11 10:22:08 UTC
Marku, any update on this issue? 
I think there should really be the possibility to scroll up/down by arrows. Now there is the workaround for reading of whole text by using PgUp/PgDown.
Comment 14 Stanislav Aubrecht 2009-09-07 14:16:02 UTC
- 'accept' is now default button, pressing enter while editor pane has input focus accepts the license
- 'escape' key rejects the license
- up/down arrows scroll license text (not the caret position)

core-main 1ffeb1b65371
Comment 15 Quality Engineering 2009-09-11 21:52:20 UTC
Integrated into 'main-golden', will be available in build *200909111401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/1ffeb1b65371
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #71018 - make 'accept license' dialog window more keyboard friendly


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo