src/share/classes/javax/swing/DefaultListCellRenderer.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  53  * If not overridden, these frequently called methods would execute code paths
  54  * that are unnecessary for the default list cell renderer.
  55  * If you write your own renderer,
  56  * take care to weigh the benefits and
  57  * drawbacks of overriding these methods.
  58  *
  59  * <p>
  60  *
  61  * <strong>Warning:</strong>
  62  * Serialized objects of this class will not be compatible with
  63  * future Swing releases. The current serialization support is
  64  * appropriate for short term storage or RMI between applications running
  65  * the same version of Swing.  As of 1.4, support for long term storage
  66  * of all JavaBeans&trade;
  67  * has been added to the <code>java.beans</code> package.
  68  * Please see {@link java.beans.XMLEncoder}.
  69  *
  70  * @author Philip Milne
  71  * @author Hans Muller
  72  */

  73 public class DefaultListCellRenderer extends JLabel
  74     implements ListCellRenderer<Object>, Serializable
  75 {
  76 
  77    /**
  78     * An empty <code>Border</code>. This field might not be used. To change the
  79     * <code>Border</code> used by this renderer override the
  80     * <code>getListCellRendererComponent</code> method and set the border
  81     * of the returned component directly.
  82     */
  83     private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
  84     private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
  85     protected static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER;
  86 
  87     /**
  88      * Constructs a default renderer object for an item
  89      * in a list.
  90      */
  91     public DefaultListCellRenderer() {
  92         super();


 324     * for more information.
 325     */
 326     @Override
 327     public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
 328 
 329     /**
 330      * A subclass of DefaultListCellRenderer that implements UIResource.
 331      * DefaultListCellRenderer doesn't implement UIResource
 332      * directly so that applications can safely override the
 333      * cellRenderer property with DefaultListCellRenderer subclasses.
 334      * <p>
 335      * <strong>Warning:</strong>
 336      * Serialized objects of this class will not be compatible with
 337      * future Swing releases. The current serialization support is
 338      * appropriate for short term storage or RMI between applications running
 339      * the same version of Swing.  As of 1.4, support for long term storage
 340      * of all JavaBeans&trade;
 341      * has been added to the <code>java.beans</code> package.
 342      * Please see {@link java.beans.XMLEncoder}.
 343      */

 344     public static class UIResource extends DefaultListCellRenderer
 345         implements javax.swing.plaf.UIResource
 346     {
 347     }
 348 }
   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  53  * If not overridden, these frequently called methods would execute code paths
  54  * that are unnecessary for the default list cell renderer.
  55  * If you write your own renderer,
  56  * take care to weigh the benefits and
  57  * drawbacks of overriding these methods.
  58  *
  59  * <p>
  60  *
  61  * <strong>Warning:</strong>
  62  * Serialized objects of this class will not be compatible with
  63  * future Swing releases. The current serialization support is
  64  * appropriate for short term storage or RMI between applications running
  65  * the same version of Swing.  As of 1.4, support for long term storage
  66  * of all JavaBeans&trade;
  67  * has been added to the <code>java.beans</code> package.
  68  * Please see {@link java.beans.XMLEncoder}.
  69  *
  70  * @author Philip Milne
  71  * @author Hans Muller
  72  */
  73 @SuppressWarnings("serial") // Same-version serialization only
  74 public class DefaultListCellRenderer extends JLabel
  75     implements ListCellRenderer<Object>, Serializable
  76 {
  77 
  78    /**
  79     * An empty <code>Border</code>. This field might not be used. To change the
  80     * <code>Border</code> used by this renderer override the
  81     * <code>getListCellRendererComponent</code> method and set the border
  82     * of the returned component directly.
  83     */
  84     private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
  85     private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
  86     protected static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER;
  87 
  88     /**
  89      * Constructs a default renderer object for an item
  90      * in a list.
  91      */
  92     public DefaultListCellRenderer() {
  93         super();


 325     * for more information.
 326     */
 327     @Override
 328     public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
 329 
 330     /**
 331      * A subclass of DefaultListCellRenderer that implements UIResource.
 332      * DefaultListCellRenderer doesn't implement UIResource
 333      * directly so that applications can safely override the
 334      * cellRenderer property with DefaultListCellRenderer subclasses.
 335      * <p>
 336      * <strong>Warning:</strong>
 337      * Serialized objects of this class will not be compatible with
 338      * future Swing releases. The current serialization support is
 339      * appropriate for short term storage or RMI between applications running
 340      * the same version of Swing.  As of 1.4, support for long term storage
 341      * of all JavaBeans&trade;
 342      * has been added to the <code>java.beans</code> package.
 343      * Please see {@link java.beans.XMLEncoder}.
 344      */
 345     @SuppressWarnings("serial") // Same-version serialization only
 346     public static class UIResource extends DefaultListCellRenderer
 347         implements javax.swing.plaf.UIResource
 348     {
 349     }
 350 }