Changeset 12947 in josm
- Timestamp:
- 2017-10-08T15:02:10+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r12946 r12947 5 5 6 6 import java.awt.Color; 7 import java.awt.Component; 7 8 import java.awt.Dimension; 8 9 import java.awt.GridBagLayout; … … 27 28 import javax.swing.ListSelectionModel; 28 29 import javax.swing.event.ListSelectionEvent; 30 import javax.swing.table.DefaultTableCellRenderer; 29 31 import javax.swing.table.DefaultTableModel; 30 import javax.swing.table.TableCellRenderer;31 32 32 33 import org.openstreetmap.josm.Main; … … 46 47 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 47 48 import org.openstreetmap.josm.gui.util.GuiHelper; 48 import org.openstreetmap.josm.spi.preferences.Config;49 49 import org.openstreetmap.josm.tools.ColorHelper; 50 50 import org.openstreetmap.josm.tools.GBC; … … 218 218 }); 219 219 colors.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 220 final TableCellRenderer oldColorsRenderer = colors.getDefaultRenderer(Object.class); 221 colors.setDefaultRenderer(Object.class, (t, o, selected, focus, row, column) -> { 222 if (o == null) 223 return new JLabel(); 224 if (column == 1) { 225 Color c = (Color) o; 226 JLabel l = new JLabel(ColorHelper.color2html(c)); 227 GuiHelper.setBackgroundReadable(l, c); 228 l.setOpaque(true); 229 return l; 230 } 231 return oldColorsRenderer.getTableCellRendererComponent(t, getName(o.toString()), selected, focus, row, column); 220 colors.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer() { 221 @Override 222 public Component getTableCellRendererComponent( 223 JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { 224 Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 225 if (value != null && comp instanceof JLabel) { 226 JLabel label = (JLabel) comp; 227 Color c = (Color) value; 228 label.setText(ColorHelper.color2html(c)); 229 GuiHelper.setBackgroundReadable(label, c); 230 label.setOpaque(true); 231 return label; 232 } 233 return comp; 234 } 232 235 }); 233 236 colors.getColumnModel().getColumn(1).setWidth(100);
Note:
See TracChangeset
for help on using the changeset viewer.