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.LayoutManager;
20 import java.awt.RenderingHints;
21 import javax.swing.JPanel;
22
23 /**
24 * Object of this class represents a <code>JPanel</code>
25 * that has font anti-aliasing enabled in the graphics context
26 * when rendering this component.
27 * <p/>
28 * Created date: Jan 28, 2008
29 *
30 * @author Yevgeny Nyden
31 */
32 public class AAJPanel extends JPanel {
33
34 /** Default constructor. */
35 public AAJPanel() {
36 }
37
38 /**
39 * Constructor.
40 *
41 * @param layoutManager Layout manager to set.
42 */
43 public AAJPanel(LayoutManager layoutManager) {
44 super(layoutManager);
45 }
46
47 /**
48 * Constructor.
49 *
50 * @param layoutManager Layout manager to set.
51 * @param b Boolean.
52 */
53 public AAJPanel(LayoutManager layoutManager, boolean b) {
54 super(layoutManager, b);
55 }
56
57 /**
58 * Constructor.
59 *
60 * @param b Boolean.
61 */
62 public AAJPanel(boolean b) {
63 super(b);
64 }
65
66 /**
67 * Enables font anti-aliasing in the current graphics context.
68 * <br />
69 *
70 * @param g Graphics context.
71 */
72 @Override
73 public void paintComponent(Graphics g) {
74 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
75 RenderingHints.VALUE_ANTIALIAS_ON);
76 super.paintComponent(g);
77 }
78
79 }