Statistics
| Revision:

root / import / ext3D / trunk / install-extension3d / IzPack / src / lib / com / izforge / izpack / gui / ButtonFactory.java @ 15280

History | View | Annotate | Download (3.56 KB)

1
/*
2
 *  $Id: ButtonFactory.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
3
 *  IzPack
4
 *  Copyright (C) 2002 Jan Blok (jblok@profdata.nl - PDM - www.profdata.nl)
5
 *
6
 *  File :               ButtonFactory.java
7
 *  Description :        a ButtonFactory.
8
 *  Author's email :     jblok@profdata.nl
9
 *  Author's Website :   http://www.profdata.nl
10
 *
11
 *  This program is free software; you can redistribute it and/or
12
 *  modify it under the terms of the GNU General Public License
13
 *  as published by the Free Software Foundation; either version 2
14
 *  of the License, or any later version.
15
 *
16
 *  This program is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU General Public License for more details.
20
 *
21
 *  You should have received a copy of the GNU General Public License
22
 *  along with this program; if not, write to the Free Software
23
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24
 */
25
package com.izforge.izpack.gui;
26

    
27
import java.awt.Color;
28

    
29
import javax.swing.Action;
30
import javax.swing.Icon;
31
import javax.swing.JButton;
32

    
33
/**
34
 * This class makes it possible to use default buttons on macosx platform
35
 */
36
public class ButtonFactory
37
{
38
        private static boolean useHighlightButtons = false;
39
        private static boolean useButtonIcons = false;
40

    
41

    
42
  /**
43
   * Enable icons for buttons
44
   * This setting has no effect on OSX
45
   */
46
        public static void useButtonIcons()
47
        {
48
    useButtonIcons(true);
49
        }
50

    
51
  /**
52
   * Enable or disable icons for buttons
53
   * This setting has no effect on OSX
54
   * @param useit flag which determines the behavior
55
   */
56
  public static void useButtonIcons(boolean useit)
57
  {
58
    if(System.getProperty("mrj.version")==null)
59
    {
60
      useButtonIcons = useit;
61
    }
62
  }
63

    
64
  /**
65
   * Enable highlight buttons
66
   * This setting has no effect on OSX
67
   */
68
        public static void useHighlightButtons()
69
        {
70
    useHighlightButtons(true);
71
        }
72

    
73
  /**
74
   * Enable or disable highlight buttons
75
   * This setting has no effect on OSX
76
   * @param useit flag which determines the behavior
77
  */
78
  public static void useHighlightButtons(boolean useit)
79
  {
80
    if(System.getProperty("mrj.version")==null)
81
    {
82
      useHighlightButtons = useit;
83
    }
84
    useButtonIcons(useit);
85
  }
86

    
87
        public static JButton createButton(Icon icon, Color color)
88
        {
89
                if (useHighlightButtons)
90
                {
91
      if (useButtonIcons)     
92
        return new HighlightJButton(icon, color);
93
      else
94
        return new HighlightJButton("", color);
95
       
96
                }
97
                else
98
                {
99
                        if (useButtonIcons)
100
                        {
101
                                return new JButton(icon);
102
                        }
103
                        else
104
                        {
105
                                return new JButton();
106
                        }
107
                }
108
        }
109

    
110
        public static JButton createButton(String text, Color color)
111
        {
112
                if (useHighlightButtons)
113
                {
114
                        return new HighlightJButton(text, color);
115
                }
116
                else
117
                {
118
                        return new JButton(text);
119
                }
120
        }
121

    
122
        public static JButton createButton(String text, Icon icon, Color color)
123
        {
124
                if (useHighlightButtons)
125
                {
126
      if (useButtonIcons)     
127
        return new HighlightJButton(text,icon, color);
128
      else
129
        return new HighlightJButton(text, color);
130
                }
131
                else
132
                {
133
                        if (useButtonIcons)
134
                        {
135
                                return new JButton(text,icon);
136
                        }
137
                        else
138
                        {
139
                                return new JButton(text);
140
                        }
141
                }
142
        }
143

    
144
        public static JButton createButton(Action a, Color color)
145
        {
146
                if (useHighlightButtons)
147
                {
148
                        return new HighlightJButton(a, color);
149
                }
150
                else
151
                {
152
                        return new JButton(a);
153
                }
154
        }
155

    
156
}
157