001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: * The Original Software is NetBeans. The Initial Developer of the Original
026: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027: * Microsystems, Inc. All Rights Reserved.
028: *
029: * If you wish your version of this file to be governed by only the CDDL
030: * or only the GPL Version 2, indicate your decision by adding
031: * "[Contributor] elects to include this software in this distribution
032: * under the [CDDL or GPL Version 2] license." If you do not indicate a
033: * single choice of license, a recipient has the option to distribute
034: * your version of this file under either the CDDL, the GPL Version 2 or
035: * to extend the choice of license to its licensees as provided above.
036: * However, if you add GPL Version 2 code and therefore, elected the GPL
037: * Version 2 license, then the option applies only if the new code is
038: * made subject to such option by the copyright holder.
039: */
040:
041: package org.netbeans.lib.profiler.ui.components;
042:
043: import java.awt.*;
044: import javax.swing.*;
045:
046: /**
047: * Anti-aliased JLabel.
048: *
049: * @author Ian Formanek
050: */
051: public class JAntiLabel extends JLabel {
052: //~ Constructors -------------------------------------------------------------------------------------------------------------
053:
054: /**
055: * Creates a <code>JLabel</code> instance with
056: * no image and with an empty string for the title.
057: * The label is centered vertically
058: * in its display area.
059: * The label's contents, once set, will be displayed on the leading edge
060: * of the label's display area.
061: */
062: public JAntiLabel() {
063: super ();
064: }
065:
066: /**
067: * Creates a <code>JLabel</code> instance with the specified text.
068: * The label is aligned against the leading edge of its display area,
069: * and centered vertically.
070: *
071: * @param text The text to be displayed by the label.
072: */
073: public JAntiLabel(String text) {
074: super (text);
075: }
076:
077: /**
078: * Creates a <code>JLabel</code> instance with the specified image.
079: * The label is centered vertically and horizontally
080: * in its display area.
081: *
082: * @param image The image to be displayed by the label.
083: */
084: public JAntiLabel(Icon image) {
085: super (image);
086: }
087:
088: /**
089: * Creates a <code>JLabel</code> instance with the specified
090: * text and horizontal alignment.
091: * The label is centered vertically in its display area.
092: *
093: * @param text The text to be displayed by the label.
094: * @param horizontalAlignment One of the following constants
095: * defined in <code>SwingConstants</code>:
096: * <code>LEFT</code>,
097: * <code>CENTER</code>,
098: * <code>RIGHT</code>,
099: * <code>LEADING</code> or
100: * <code>TRAILING</code>.
101: */
102: public JAntiLabel(String text, int horizontalAlignment) {
103: super (text, horizontalAlignment);
104: }
105:
106: /**
107: * Creates a <code>JLabel</code> instance with the specified
108: * image and horizontal alignment.
109: * The label is centered vertically in its display area.
110: *
111: * @param image The image to be displayed by the label.
112: * @param horizontalAlignment One of the following constants
113: * defined in <code>SwingConstants</code>:
114: * <code>LEFT</code>,
115: * <code>CENTER</code>,
116: * <code>RIGHT</code>,
117: * <code>LEADING</code> or
118: * <code>TRAILING</code>.
119: */
120: public JAntiLabel(Icon image, int horizontalAlignment) {
121: super (image, horizontalAlignment);
122: }
123:
124: /**
125: * Creates a <code>JLabel</code> instance with the specified
126: * text, image, and horizontal alignment.
127: * The label is centered vertically in its display area.
128: * The text is on the trailing edge of the image.
129: *
130: * @param text The text to be displayed by the label.
131: * @param icon The image to be displayed by the label.
132: * @param horizontalAlignment One of the following constants
133: * defined in <code>SwingConstants</code>:
134: * <code>LEFT</code>,
135: * <code>CENTER</code>,
136: * <code>RIGHT</code>,
137: * <code>LEADING</code> or
138: * <code>TRAILING</code>.
139: */
140: public JAntiLabel(String text, Icon icon, int horizontalAlignment) {
141: super (text, icon, horizontalAlignment);
142: }
143:
144: //~ Methods ------------------------------------------------------------------------------------------------------------------
145:
146: public void paintComponent(Graphics g) {
147: if (g instanceof Graphics2D) {
148: ((Graphics2D) g).setRenderingHint(
149: RenderingHints.KEY_TEXT_ANTIALIASING,
150: RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
151: }
152:
153: super.paintComponent(g);
154: }
155: }
|