From 41596d129b61107aa412694b3afc58e76305744e Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 04 Apr 2008 12:02:59 +0000
Subject: [PATCH] Inherit from DefaultTableCellRenderer instead of JLabel for the TableCellRenderes we implement.

---
 opends/src/guitools/org/opends/guitools/statuspanel/ui/StatusPanelDialog.java |   42 +++++++++++++++++++++++++++---------------
 1 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/statuspanel/ui/StatusPanelDialog.java b/opends/src/guitools/org/opends/guitools/statuspanel/ui/StatusPanelDialog.java
index a287ef4..a7ae210 100644
--- a/opends/src/guitools/org/opends/guitools/statuspanel/ui/StatusPanelDialog.java
+++ b/opends/src/guitools/org/opends/guitools/statuspanel/ui/StatusPanelDialog.java
@@ -62,6 +62,7 @@
 import javax.swing.PopupFactory;
 import javax.swing.SwingConstants;
 import javax.swing.ToolTipManager;
+import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.JTableHeader;
 import javax.swing.table.TableCellRenderer;
 import javax.swing.table.TableColumn;
@@ -1346,7 +1347,7 @@
   /**
    * Class used to render the databases table cells.
    */
-  class DatabasesCellRenderer extends JLabel implements TableCellRenderer
+  class DatabasesCellRenderer extends DefaultTableCellRenderer
   {
     private static final long serialVersionUID = -256719167426289735L;
 
@@ -1364,13 +1365,14 @@
      */
     public Component getTableCellRendererComponent(JTable table, Object value,
         boolean isSelected, boolean hasFocus, int row, int column) {
+      String text = null;
       if (value instanceof String)
       {
-        setTextValue(this, (String)value);
+        text = (String)value;
       }
       else if (value instanceof Message)
       {
-        setTextValue(this, ((Message)value).toString());
+        text = ((Message)value).toString();
       }
       else if (value instanceof Set)
       {
@@ -1379,10 +1381,10 @@
         {
           baseDns.add((String)v);
         }
-        setTextValue(this, "<html>" +
-            UIFactory.applyFontToHtml(Utils.getStringFromCollection(
-                baseDns, "<br>"),
-                UIFactory.SECONDARY_FIELD_VALID_FONT));
+        text = "<html>" +
+        UIFactory.applyFontToHtml(Utils.getStringFromCollection(
+            baseDns, "<br>"),
+            UIFactory.SECONDARY_FIELD_VALID_FONT);
       }
       else
       {
@@ -1393,7 +1395,7 @@
           int nEntries = (Integer)value;
           if (nEntries >= 0)
           {
-            setTextValue(this, String.valueOf(nEntries));
+            text = String.valueOf(nEntries);
           }
           else
           {
@@ -1412,25 +1414,32 @@
           setNotAvailableBecauseServerIsDown(this);
         }
       }
+      if (text != null)
+      {
+        setTextValue(this, text);
+      }
+      JComponent comp = (JComponent)
+      super.getTableCellRendererComponent(table, getText(), isSelected,
+        hasFocus, row, column);
       if (column == 0)
       {
-        setBorder(BorderFactory.createCompoundBorder(
+        comp.setBorder(BorderFactory.createCompoundBorder(
             BorderFactory.createMatteBorder(0, 1, 0, 0,
                 UIFactory.PANEL_BORDER_COLOR),
                 BorderFactory.createEmptyBorder(4, 4, 4, 4)));
       }
       else
       {
-        setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
+        comp.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
       }
-      return this;
+      return comp;
     }
   }
 
   /**
    * Class used to render the listeners table cells.
    */
-  class ListenersCellRenderer extends JLabel implements TableCellRenderer
+  class ListenersCellRenderer extends DefaultTableCellRenderer
   {
     private static final long serialVersionUID = -256719167426289735L;
 
@@ -1450,18 +1459,21 @@
         boolean isSelected, boolean hasFocus, int row, int column) {
 
       setTextValue(this, (String)value);
+      JComponent comp = (JComponent)
+        super.getTableCellRendererComponent(table, getText(), isSelected,
+          hasFocus, row, column);
       if (column == 0)
       {
-        setBorder(BorderFactory.createCompoundBorder(
+        comp.setBorder(BorderFactory.createCompoundBorder(
             BorderFactory.createMatteBorder(0, 1, 0, 0,
                 UIFactory.PANEL_BORDER_COLOR),
                 BorderFactory.createEmptyBorder(4, 4, 4, 4)));
       }
       else
       {
-        setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
+        comp.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
       }
-      return this;
+      return comp;
     }
   }
 }

--
Gitblit v1.10.0