Changeset 11552 in josm


Ignore:
Timestamp:
2017-02-12T12:51:09+01:00 (3 years ago)
Author:
Don-vip
Message:

fix #14353 - robustness to systems not defining standard Java UI color constants

File:
1 edited

Legend:

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

    r10977 r11552  
    1616import javax.swing.JLabel;
    1717import javax.swing.JTable;
    18 import javax.swing.UIDefaults;
    1918import javax.swing.UIManager;
    2019import javax.swing.table.DefaultTableCellRenderer;
     
    4241
    4342    static {
    44         UIDefaults defaults = UIManager.getDefaults();
    45         SELECTED_BG = new ColorProperty(marktr("Discardable key: selection Background"),
    46                 defaults.getColor("Table.selectionBackground")).cached();
    47         NORMAL_BG = new ColorProperty(marktr("Discardable key: background"),
    48                 defaults.getColor("Table.background")).cached();
     43        Color selectionBackground = UIManager.getColor("Table.selectionBackground");
     44        if (selectionBackground == null) {
     45            selectionBackground = Color.BLUE;
     46        }
     47        SELECTED_BG = new ColorProperty(marktr("Discardable key: selection Background"), selectionBackground).cached();
     48        Color background = UIManager.getColor("Table.background");
     49        if (background == null) {
     50            background = Color.WHITE;
     51        }
     52        NORMAL_BG = new ColorProperty(marktr("Discardable key: background"), background).cached();
    4953    }
    5054
     
    5761            c.setBackground((isSelected ? SELECTED_BG : NORMAL_BG).get());
    5862        } else {
    59             UIDefaults defaults = UIManager.getDefaults();
    60             c.setForeground(defaults.getColor("Table."+(isSelected ? "selectionF" : "f")+"oreground"));
    61             c.setBackground(defaults.getColor("Table."+(isSelected ? "selectionB" : "b")+"ackground"));
     63            c.setForeground(UIManager.getColor("Table."+(isSelected ? "selectionF" : "f")+"oreground"));
     64            c.setBackground(UIManager.getColor("Table."+(isSelected ? "selectionB" : "b")+"ackground"));
    6265        }
    6366    }
Note: See TracChangeset for help on using the changeset viewer.