Changeset 10024 in josm for trunk


Ignore:
Timestamp:
2016-03-21T01:00:06+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #12656 - increase display time for styles and presets tooltips

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

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

    r9977 r10024  
    136136        final SourceEntryListCellRenderer listCellRenderer = new SourceEntryListCellRenderer();
    137137        this.lstAvailableSources.setCellRenderer(listCellRenderer);
     138        GuiHelper.extendTooltipDelay(lstAvailableSources);
    138139        this.availableSourcesUrl = availableSourcesUrl;
    139140        this.sourceProviders = sourceProviders;
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r9916 r10024  
    2424import java.awt.event.HierarchyListener;
    2525import java.awt.event.KeyEvent;
     26import java.awt.event.MouseAdapter;
     27import java.awt.event.MouseEvent;
    2628import java.awt.image.FilteredImageSource;
    2729import java.lang.reflect.InvocationTargetException;
     
    4345import javax.swing.SwingUtilities;
    4446import javax.swing.Timer;
     47import javax.swing.ToolTipManager;
    4548import javax.swing.UIManager;
    4649import javax.swing.plaf.FontUIResource;
     
    475478        return e != null && e.getSource() instanceof Component ? SwingUtilities.getWindowAncestor((Component) e.getSource()) : null;
    476479    }
     480
     481    /**
     482     * Extends tooltip dismiss delay to a default value of 1 minute for the given component.
     483     * @param c component
     484     * @since 10024
     485     */
     486    public static void extendTooltipDelay(Component c) {
     487        extendTooltipDelay(c, 60000);
     488    }
     489
     490    /**
     491     * Extends tooltip dismiss delay to the specified value for the given component.
     492     * @param c component
     493     * @param delay tooltip dismiss delay in milliseconds
     494     * @see <a href="http://stackoverflow.com/a/6517902/2257172">http://stackoverflow.com/a/6517902/2257172</a>
     495     * @since 10024
     496     */
     497    public static void extendTooltipDelay(Component c, final int delay) {
     498        final int defaultDismissTimeout = ToolTipManager.sharedInstance().getDismissDelay();
     499        c.addMouseListener(new MouseAdapter() {
     500            @Override
     501            public void mouseEntered(MouseEvent me) {
     502                ToolTipManager.sharedInstance().setDismissDelay(delay);
     503            }
     504
     505            @Override
     506            public void mouseExited(MouseEvent me) {
     507                ToolTipManager.sharedInstance().setDismissDelay(defaultDismissTimeout);
     508            }
     509        });
     510    }
    477511}
Note: See TracChangeset for help on using the changeset viewer.