/[classpath]/classpath/javax/swing/table/DefaultTableCellRenderer.java
ViewVC logotype

Diff of /classpath/javax/swing/table/DefaultTableCellRenderer.java

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

revision 1.7.2.7 by gnu_andrew, Wed Nov 2 00:44:02 2005 UTC revision 1.7.2.8 by gnu_andrew, Sun Nov 27 21:00:41 2005 UTC
# Line 71  public class DefaultTableCellRenderer ex Line 71  public class DefaultTableCellRenderer ex
71    }    }
72    
73    /**    /**
74       * Stores the color set by setForeground().
75       */
76      Color foreground;
77    
78      /**
79       * Stores the color set by setBackground().
80       */
81      Color background;
82    
83      /**
84     * Creates a default table cell renderer with an empty border.     * Creates a default table cell renderer with an empty border.
85     */     */
86    public DefaultTableCellRenderer()    public DefaultTableCellRenderer()
# Line 86  public class DefaultTableCellRenderer ex Line 96  public class DefaultTableCellRenderer ex
96    public void setForeground(Color c)    public void setForeground(Color c)
97    {    {
98      super.setForeground(c);      super.setForeground(c);
99        foreground = c;
100    }    }
101    
102    /**    /**
# Line 96  public class DefaultTableCellRenderer ex Line 107  public class DefaultTableCellRenderer ex
107    public void setBackground(Color c)    public void setBackground(Color c)
108    {    {
109      super.setBackground(c);      super.setBackground(c);
110        background = c;
111    }    }
112    
113    /**    /**
# Line 107  public class DefaultTableCellRenderer ex Line 119  public class DefaultTableCellRenderer ex
119    public void updateUI()    public void updateUI()
120    {    {
121      super.updateUI();      super.updateUI();
122        background = null;
123        foreground = null;
124    }    }
125    
126    /**    /**
# Line 140  public class DefaultTableCellRenderer ex Line 154  public class DefaultTableCellRenderer ex
154    
155      if (isSelected)      if (isSelected)
156        {        {
157          setBackground(table.getSelectionBackground());          super.setBackground(table.getSelectionBackground());
158          setForeground(table.getSelectionForeground());          super.setForeground(table.getSelectionForeground());
159        }        }
160      else      else
161        {        {
162          setBackground(table.getBackground());          if (background != null)
163          setForeground(table.getForeground());            super.setBackground(background);
164            else
165              super.setBackground(table.getBackground());
166            if (foreground != null)
167              super.setForeground(foreground);
168            else
169              super.setForeground(table.getForeground());
170        }        }
171    
172      if (hasFocus)      if (hasFocus)
173        {        {
         setBackground(table.getBackground());  
174          setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));          setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
175            if (table.isCellEditable(row, column))
176              {
177                super.setBackground(UIManager.getColor("Table.focusCellBackground"));
178                super.setForeground(UIManager.getColor("Table.focusCellForeground"));
179              }
180        }        }
181      else      else
182        setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));        setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
183    
     setEnabled(table.isEnabled());  
184      setFont(table.getFont());      setFont(table.getFont());
185    
186        // If the current background is equal to the table's background, then we
187        // can avoid filling the background by setting the renderer opaque.
188        Color back = getBackground();
189        setOpaque(back != null && back.equals(table.getBackground()));
190        
191      return this;          return this;    
192    }    }
193    

Legend:
Removed from v.1.7.2.7  
changed lines
  Added in v.1.7.2.8

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