1 33 34 package edu.rice.cs.drjava.ui; 35 36 import javax.swing.text.JTextComponent ; 37 import java.awt.Component ; 38 import java.awt.Color ; 39 40 import edu.rice.cs.drjava.config.*; 41 import edu.rice.cs.drjava.*; 42 43 44 class ForegroundColorListener implements OptionListener<Color > { 45 final Component _target; 46 47 public ForegroundColorListener(Component target) { 48 _target = target; 49 50 final Color color = DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_NORMAL_COLOR); 51 _setColor(color); 52 53 DrJava.getConfig().addOptionListener(OptionConstants.DEFINITIONS_NORMAL_COLOR, this); 54 } 55 56 public void optionChanged(OptionEvent<Color > oce) { _setColor(oce.value); } 57 58 private void _setColor(Color c) { 59 _target.setForeground(c); 60 61 if (_target instanceof JTextComponent ) { 62 ((JTextComponent ) _target).setCaretColor(c); 63 } 64 } 65 } | Popular Tags |