/[classpath]/classpath/javax/swing/plaf/basic/BasicTextUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicTextUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34 by rabbit78, Thu Aug 25 20:32:02 2005 UTC revision 1.35 by rabbit78, Thu Sep 8 12:02:46 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package javax.swing.plaf.basic;  package javax.swing.plaf.basic;
40    
41    import java.awt.Color;
42  import java.awt.Container;  import java.awt.Container;
43  import java.awt.Dimension;  import java.awt.Dimension;
44  import java.awt.Graphics;  import java.awt.Graphics;
# Line 342  public abstract class BasicTextUI extend Line 343  public abstract class BasicTextUI extend
343      public void propertyChange(PropertyChangeEvent event)      public void propertyChange(PropertyChangeEvent event)
344      {      {
345        if (event.getPropertyName().equals("document"))        if (event.getPropertyName().equals("document"))
346          {          {
347            // Document changed.            // Document changed.
348            modelChanged();                modelChanged();
349          }          }
350          else if (event.getPropertyName().equals("enabled"))
351            {
352              updateComponentColors();
353            }
354      }      }
355    }    }
356    
# Line 425  public abstract class BasicTextUI extend Line 430  public abstract class BasicTextUI extend
430    DocumentHandler documentHandler = new DocumentHandler();    DocumentHandler documentHandler = new DocumentHandler();
431    
432    /**    /**
433       * The standard foreground color. This is the color which is used to paint
434       * text in enabled text components.
435       */
436      Color foreground;
437    
438      /**
439       * The standard background color. This is the color which is used to paint
440       * text in enabled text components.
441       */
442      Color background;
443    
444      /**
445       * The inactive foreground color. This is the color which is used to paint
446       * text in disabled text components.
447       */
448      Color inactiveForeground;
449    
450      /**
451       * The inactive background color. This is the color which is used to paint
452       * text in disabled text components.
453       */
454      Color inactiveBackground;
455    
456      /**
457     * Creates a new <code>BasicTextUI</code> instance.     * Creates a new <code>BasicTextUI</code> instance.
458     */     */
459    public BasicTextUI()    public BasicTextUI()
# Line 507  public abstract class BasicTextUI extend Line 536  public abstract class BasicTextUI extend
536    
537      String prefix = getPropertyPrefix();      String prefix = getPropertyPrefix();
538      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      UIDefaults defaults = UIManager.getLookAndFeelDefaults();
     textComponent.setBackground(defaults.getColor(prefix + ".background"));  
     textComponent.setForeground(defaults.getColor(prefix + ".foreground"));  
539      textComponent.setMargin(defaults.getInsets(prefix + ".margin"));      textComponent.setMargin(defaults.getInsets(prefix + ".margin"));
540      textComponent.setBorder(defaults.getBorder(prefix + ".border"));      textComponent.setBorder(defaults.getBorder(prefix + ".border"));
541      textComponent.setFont(defaults.getFont(prefix + ".font"));      textComponent.setFont(defaults.getFont(prefix + ".font"));
542    
543      caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate"));      caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate"));
544    
545        // Fetch the colors for enabled/disabled text components.
546        foreground = defaults.getColor(prefix + ".foreground");
547        background = defaults.getColor(prefix + ".background");
548        inactiveForeground = defaults.getColor(prefix + ".inactiveForeground");
549        inactiveBackground = defaults.getColor(prefix + ".inactiveBackground");
550        updateComponentColors();
551    }    }
552    
553    /**    /**
# Line 1043  public abstract class BasicTextUI extend Line 1077  public abstract class BasicTextUI extend
1077      View view = factory.create(elem);      View view = factory.create(elem);
1078      setView(view);      setView(view);
1079    }    }
1080    
1081      /**
1082       * Updates the colors of the text component according to its enabled
1083       * state.
1084       */
1085      void updateComponentColors()
1086      {
1087        if (textComponent.isEnabled())
1088          {
1089            textComponent.setForeground(foreground);
1090            textComponent.setBackground(background);
1091          }
1092        else
1093          {
1094            textComponent.setForeground(inactiveForeground);
1095            textComponent.setBackground(inactiveBackground);
1096          }
1097      }
1098  }  }

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26