Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6350748

Common icon for buttons and menus with Action.SMALL_ICON is restrictive

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE REQUEST :
      I'm making a small Swing application at present, and am extend AbstractAction to have a clean design (instead of anonymous ActionListeners and suchlike). Some actions appear in menus, some appear in the toolbar, and so on. In the menus, I'm using 16x16px icons, but for clarity, I'd like to use 24x24 icons in the toolbar. Given that the same Action object is shared between the menu AND the toolbar in some cases (that's the whole point of actions...), such icons are either too small for the toolbar or too large for the menu.

      Perhaps "action-aware" components like menus and toolbars could have a method such as setActionIconSize(d:Dimension) (with a null "d" indicating current default behaviour), where (if specified) automatic resizing is performed. Alternatively, and I probably prefer this solution, additional properties could be specified for the Action interface, such as TOOLBAR_ICON and MENUBAR_ICON that override SMALL_ICON if specifed.

      Furthermore, there doesn't seem any action properties to state whether a toolbar buttons should have text AND the icon, and if so, where to position the text with regards to the icon.

      JUSTIFICATION :
      In menu bars, the icon is generally the same size as the menu item text, and the combination of text+icon is usually enough to help navigate and understand functionality.

      The same icons in a toolbar may be too small to understand with text information, so it can be helpful to have a larger version. Contemporary GUIs often have 16x16 icons in menu bars, but sometimes (depending upon the type of application and user interface ergonomics) may prefer 16x16, 24x24, or 32x32 pixel icons.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The "clean" approach for common functions is to use an Action, shared between multiple UI elements in several cases, so it's useful to have the logical representation (the Action) able to provide the information to render it appropriately in multiple contexts.
      ACTUAL -
      The same icon is used in all representations of an icon.

      CUSTOMER SUBMITTED WORKAROUND :
      You need to use the same icon everywhere, forcing either mixed icon sizes in menus or toolbars, or forcing a lowest-common-denominator approach to icon sizes. Either that or duplicate actions for each scenario, and handle that extra complexity. All that for the lack of a couple of properties...

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              svioletsunw Scott Violet (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: