Changeset 9778 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-02-10T20:47:11+01:00 (8 years ago)
Author:
bastiK
Message:

see #12507 - fix mouse wheel scrolling at some places

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

Legend:

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

    r9760 r9778  
    176176
    177177        JScrollPane sp = new JScrollPane(p);
    178         // putting JTable directly in a JScrollPane works nicely, but with
    179         // JPanel wrapper, the default scroll increment is too small
    180         sp.getVerticalScrollBar().setUnitIncrement(16);
     178        GuiHelper.setDefaultIncrement(sp);
    181179        createLayout(sp, false, Arrays.asList(
    182180                new SideButton(onoffAction, false),
  • trunk/src/org/openstreetmap/josm/gui/preferences/audio/AudioPreference.java

    r9078 r9778  
    1717import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    1818import org.openstreetmap.josm.gui.widgets.JosmTextField;
     19import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    1920import org.openstreetmap.josm.tools.GBC;
    2021
     
    5657    @Override
    5758    public void addGui(PreferenceTabbedPane gui) {
    58         JPanel audio = new JPanel(new GridBagLayout());
     59        JPanel audio = new VerticallyScrollablePanel(new GridBagLayout());
    5960
    6061        // audioMenuVisible
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java

    r9078 r9778  
    2222import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    2323import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
     24import org.openstreetmap.josm.gui.util.GuiHelper;
    2425import org.openstreetmap.josm.tools.GBC;
    2526
     
    6465        JScrollPane scrollpane = new JScrollPane(panel);
    6566        scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
     67        GuiHelper.setDefaultIncrement(scrollpane);
    6668        gui.getDisplayPreference().addSubTab(this, tr("GPS Points"), scrollpane);
    6769        panel = new JPanel(new GridBagLayout());
     
    167169        scrollpane = new JScrollPane(panel);
    168170        scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
     171        GuiHelper.setDefaultIncrement(scrollpane);
    169172        gui.getDisplayPreference().addSubTab(this, tr("OSM Data"), scrollpane);
    170173    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java

    r9078 r9778  
    3232import org.openstreetmap.josm.gui.widgets.FileChooserManager;
    3333import org.openstreetmap.josm.gui.widgets.JosmComboBox;
     34import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    3435import org.openstreetmap.josm.tools.GBC;
    3536import org.openstreetmap.josm.tools.date.DateUtils;
     
    5455     */
    5556    private JosmComboBox<LookAndFeelInfo> lafCombo;
    56     JPanel panel;
     57    VerticallyScrollablePanel panel;
    5758    private final JCheckBox showSplashScreen = new JCheckBox(tr("Show splash screen at startup"));
    5859    private final JCheckBox showID = new JCheckBox(tr("Show object ID in selection lists"));
     
    99100        });
    100101
    101         panel = new JPanel(new GridBagLayout());
     102        panel = new VerticallyScrollablePanel(new GridBagLayout());
    102103        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    103104
     
    147148        panel.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL));
    148149
    149         JScrollPane scrollpane = new JScrollPane(panel);
     150        JScrollPane scrollpane = panel.getVerticalScrollPane();
    150151        scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    151152        gui.getDisplayPreference().addSubTab(this, tr("Look and Feel"), scrollpane);
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java

    r8568 r9778  
    6161
    6262        showBounds.setEnabled(false);
    63         add(new JScrollPane(showBounds), GBC.eop().fill());
     63        add(showBounds, GBC.eop().fill());
    6464
    6565        add(new JLabel(tr("3. Select image format")), GBC.eol());
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r9414 r9778  
    121121
    122122        p.add(new JPanel(), GBC.eol().fill(GBC.BOTH));
    123         return new JScrollPane(p);
     123        return GuiHelper.setDefaultIncrement(new JScrollPane(p));
    124124    }
    125125
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    r9543 r9778  
    3636import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3737import org.openstreetmap.josm.gui.widgets.JosmComboBox;
     38import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    3839import org.openstreetmap.josm.tools.GBC;
    3940
     
    292293     * This is the panel holding all projection preferences
    293294     */
    294     private final JPanel projPanel = new JPanel(new GridBagLayout());
     295    private final VerticallyScrollablePanel projPanel = new VerticallyScrollablePanel(new GridBagLayout());
    295296
    296297    /**
     
    346347        projPanel.add(GBC.glue(1, 1), GBC.std().fill(GBC.HORIZONTAL).weight(1.0, 1.0));
    347348
    348         JScrollPane scrollpane = new JScrollPane(projPanel);
    349         gui.getMapPreference().addSubTab(this, tr("Map Projection"), scrollpane);
     349        gui.getMapPreference().addSubTab(this, tr("Map Projection"), projPanel.getVerticalScrollPane());
    350350
    351351        selectedProjectionChanged(pc);
  • trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java

    r9543 r9778  
    3434import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    3535import org.openstreetmap.josm.gui.util.GuiHelper;
     36import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    3637import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
    3738import org.openstreetmap.josm.io.remotecontrol.RemoteControl;
     
    8182    public void addGui(final PreferenceTabbedPane gui) {
    8283
    83         JPanel remote = new JPanel(new GridBagLayout());
     84        JPanel remote = new VerticallyScrollablePanel(new GridBagLayout());
    8485
    8586        final JLabel descLabel = new JLabel("<html>"
  • trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java

    r8510 r9778  
    2727import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2828import org.openstreetmap.josm.gui.util.GuiHelper;
     29import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    2930import org.openstreetmap.josm.tools.GBC;
    3031
     
    5556    @Override
    5657    public void addGui(PreferenceTabbedPane gui) {
    57         JPanel testPanel = new JPanel(new GridBagLayout());
     58        JPanel testPanel = new VerticallyScrollablePanel(new GridBagLayout());
    5859        testPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    5960
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r9576 r9778  
    3737import javax.swing.JPanel;
    3838import javax.swing.JScrollPane;
     39import javax.swing.Scrollable;
    3940import javax.swing.SwingUtilities;
    4041import javax.swing.Timer;
     
    341342
    342343    /**
     344     * Set the default unit increment for a {@code JScrollPane}.
     345     *
     346     * This fixes slow mouse wheel scrolling when the content of the {@code JScrollPane}
     347     * is a {@code JPanel} or other component that does not implement the {@link Scrollable}
     348     * interface.
     349     * The default unit increment is 1 pixel. Multiplied by the number of unit increments
     350     * per mouse wheel "click" (platform dependent, usually 3), this makes a very
     351     * sluggish mouse wheel experience.
     352     * This methods sets the unit increment to a larger, more reasonable value.
     353     * @param sp the scroll pane
     354     * @return the scroll pane (same object) with fixed unit increment
     355     * @throws IllegalArgumentException if the component inside of the scroll pane
     356     * implements the {@code Scrollable} interface ({@code JTree}, {@code JLayer},
     357     * {@code JList}, {@code JTextComponent} and {@code JTable})
     358     */
     359    public static JScrollPane setDefaultIncrement(JScrollPane sp) {
     360        if (sp.getViewport().getView() instanceof Scrollable) {
     361            throw new IllegalArgumentException();
     362        }
     363        sp.getVerticalScrollBar().setUnitIncrement(10);
     364        sp.getHorizontalScrollBar().setUnitIncrement(10);
     365        return sp;
     366    }
     367
     368    /**
    343369     * Returns extended modifier key used as the appropriate accelerator key for menu shortcuts.
    344370     * It is advised everywhere to use {@link Toolkit#getMenuShortcutKeyMask()} to get the cross-platform modifier, but:
Note: See TracChangeset for help on using the changeset viewer.