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.Icon;
21 import javax.swing.JOptionPane;
22
23 /**
24 * Object of this class represents a <code>JOptionPane</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 AAJOptionPane extends JOptionPane {
33
34 /**
35 * Constructor.
36 *
37 * @param object Object.
38 * @param infMessage Information message to set.
39 * @param defaultOption Default option to set.
40 * @param icon Icon to set.
41 */
42 public AAJOptionPane(Object object, int infMessage, int defaultOption, Icon icon) {
43 super(object, infMessage, defaultOption, icon);
44 }
45
46 /**
47 * Enables font anti-aliasing in the current graphics context.
48 * <br />
49 *
50 * @param g Graphics context.
51 */
52 @Override
53 public void paint(Graphics g) {
54 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
55 RenderingHints.VALUE_ANTIALIAS_ON);
56 super.paint(g);
57 }
58
59 }