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.Graphics;
18  import java.awt.Graphics2D;
19  import java.awt.RenderingHints;
20  import javax.swing.JButton;
21  
22  /**
23   * Object of this class represents a <code>JButton</code>
24   * that has font anti-aliasing enabled in the graphics context
25   * when rendering this component.
26   * <p/>
27   * Created date: Jan 28, 2008
28   *
29   * @author Yevgeny Nyden
30   */
31  public class AAJButton extends JButton {
32  
33    /** Default constructor. */
34    public AAJButton() {
35    }
36  
37    /**
38     * Constructor that sets the label.
39     *
40     * @param string Label.
41     */
42    public AAJButton(String string) {
43      super(string);
44    }
45  
46    /**
47     * Enables font anti-aliasing in the current graphics context.
48     *
49     * @param g Graphics context/
50     */
51    @Override
52    public void paint(Graphics g) {
53      ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
54                                        RenderingHints.VALUE_ANTIALIAS_ON);
55      super.paint(g);
56    }
57  
58  }