Results 1 to 5 of 5
  1. #1
    mjones is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default JToolbar: How to unselect first item

    When I create my toolbar a dotted box appears around the first item, then if I select another item it will move to the last selected item.

    does any1 know how to remove this behaviour!?

    cheers

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Call (AbstractButton method) setFocusPainted(false) on the buttons.

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    What behaviour? This is normal.

    The dotted box is there so the user knows which button has focus. This allows the user to tab from key to key and then use the keyboard to activate the button.

    Good GUI design "does not" assume that all users use the mouse. In fact, for any application advanced users will use the keyboard instead of the mouse because its faster.

    However, if you want to cripple your application by preventing users from using the keyboard, then you can use:

    button.setFocusable(false);

  4. #4
    mjones is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default

    thanks worked fine.

    cheers

  5. #5
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Good point. Users often demand keyboard short-cuts for everything.

Similar Threads

  1. jcheckbox item listener
    By GUIJAVA in forum New To Java
    Replies: 2
    Last Post: 02-09-2010, 11:15 AM
  2. Extract item from a string
    By firewalll in forum New To Java
    Replies: 2
    Last Post: 09-02-2009, 05:00 AM
  3. [SOLVED] Item too big for JComboBox
    By nwboy74 in forum AWT / Swing
    Replies: 5
    Last Post: 02-23-2009, 08:21 PM
  4. JToolBar movable but not floatable
    By Fosters in forum AWT / Swing
    Replies: 0
    Last Post: 08-22-2008, 03:04 PM
  5. grabbing an item from an arraylist.
    By newtojava7 in forum New To Java
    Replies: 1
    Last Post: 03-17-2008, 08:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •