Ignore:
Timestamp:
2014-04-27T17:34:22+02:00 (10 years ago)
Author:
Don-vip
Message:

see #8465 - fix generics for JComboBox/JList

File:
1 edited

Legend:

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

    r6889 r7015  
    2121    protected int index;        // 0-based index
    2222    protected int defaultIndex;
    23     protected Object[] entries;
     23    protected String[] entries;
    2424    protected String label;
    2525
     
    3333     * @param defaultIndex the default index for the combo-box
    3434     */
    35     public ListProjectionChoice(String name, String id, Object[] entries, String label, int defaultIndex) {
     35    public ListProjectionChoice(String name, String id, String[] entries, String label, int defaultIndex) {
    3636        super(name, id);
    3737        this.entries = Utils.copyArray(entries);
     
    4747     * @param label a label shown left to the combo-box
    4848     */
    49     public ListProjectionChoice(String name, String id, Object[] entries, String label) {
     49    public ListProjectionChoice(String name, String id, String[] entries, String label) {
    5050        this(name, id, entries, label, 0);
    5151    }
     
    5454     * Convert 0-based index to preference value.
    5555     */
    56     protected abstract String indexToZone(int index);
     56    protected abstract String indexToZone(int idx);
    5757
    5858    /**
     
    6767            zone = args.iterator().next();
    6868        }
    69         int index;
     69        int idx;
    7070        if (zone == null) {
    71             index = defaultIndex;
     71            idx = defaultIndex;
    7272        } else {
    73             index = zoneToIndex(zone);
    74             if (index < 0 || index >= entries.length) {
    75                 index = defaultIndex;
     73            idx = zoneToIndex(zone);
     74            if (idx < 0 || idx >= entries.length) {
     75                idx = defaultIndex;
    7676            }
    7777        }
    78         this.index = index;
     78        this.index = idx;
    7979    }
    8080
    8181    protected class CBPanel extends JPanel {
    82         public JosmComboBox prefcb;
     82        public JosmComboBox<String> prefcb;
    8383
    84         public CBPanel(Object[] entries, int initialIndex, String label, final ActionListener listener) {
    85             prefcb = new JosmComboBox(entries);
     84        public CBPanel(String[] entries, int initialIndex, String label, final ActionListener listener) {
     85            prefcb = new JosmComboBox<>(entries);
    8686
    8787            prefcb.setSelectedIndex(initialIndex);
     
    109109        }
    110110        CBPanel p = (CBPanel) panel;
    111         int index = p.prefcb.getSelectedIndex();
    112         return Collections.singleton(indexToZone(index));
     111        int idx = p.prefcb.getSelectedIndex();
     112        return Collections.singleton(indexToZone(idx));
    113113    }
    114 
    115114}
Note: See TracChangeset for help on using the changeset viewer.