View Javadoc

1   /**
2    * This program is free software: you can redistribute it and/or modify
3    * it under the terms of the GNU General Public License as published by
4    * the Free Software Foundation, version 3.
5    *
6    * This program is distributed in the hope that it will be useful,
7    * but WITHOUT ANY WARRANTY; without even the implied warranty of
8    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9    * GNU General Public License for more details.
10   *
11   * You should have received a copy of the GNU General Public License
12   * along with this program. If not, see <http://www.gnu.org/licenses/>.
13   */
14  
15  package net.curre.prefcount.gui.aa;
16  
17  import java.awt.*;
18  import javax.swing.*;
19  
20  /**
21   * Object of this class represents a <code>JLabel</code>
22   * that has font anti-aliasing enabled in the graphics context
23   * when rendering this component.
24   * <p/>
25   * Created date: Jan 28, 2008
26   *
27   * @author Zhenya Nyden
28   */
29  public class AAJLabel extends JLabel {
30  
31    /** Default constructor. */
32    public AAJLabel() {
33    }
34  
35    /**
36     * Constructor that sets the label.
37     *
38     * @param string Label.
39     */
40    public AAJLabel(String string) {
41      super(string);
42    }
43  
44    /**
45     * Constructor that sets the label.
46     *
47     * @param string Label.
48     * @param i      int.
49     */
50    public AAJLabel(String string, int i) {
51      super(string, i);
52    }
53  
54    /**
55     * Enables font anti-aliasing in the current graphics context.
56     * <br />
57     *
58     * @param g Graphics context.
59     */
60    public void paint(Graphics g) {
61      ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
62                                        RenderingHints.VALUE_ANTIALIAS_ON);
63      super.paint(g);
64    }
65  
66  }