46 |
import java.awt.Polygon; |
import java.awt.Polygon; |
47 |
import java.awt.Rectangle; |
import java.awt.Rectangle; |
48 |
|
|
49 |
|
import javax.swing.AbstractButton; |
50 |
import javax.swing.JButton; |
import javax.swing.JButton; |
51 |
import javax.swing.SwingConstants; |
import javax.swing.SwingConstants; |
52 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
114 |
public void paintBorder(Component c, Graphics g, int x, int y, int w, |
public void paintBorder(Component c, Graphics g, int x, int y, int w, |
115 |
int h) |
int h) |
116 |
{ |
{ |
117 |
Color saved = g.getColor(); |
Color saved = g.getColor(); |
118 |
g.setColor(highlight); |
AbstractButton b = (AbstractButton) c; |
119 |
|
if (b.getModel().isPressed()) |
120 |
|
{ |
121 |
|
g.setColor(darkShadow); |
122 |
|
g.drawRect(x, y, x + w - 1, y + h - 1); |
123 |
|
} |
124 |
|
else |
125 |
|
{ |
126 |
|
g.setColor(highlight); |
127 |
|
g.drawLine(x + 1, y + 1, x + w - 3, y + 1); |
128 |
|
g.drawLine(x + 1, y + 1, x + 1, y + h - 2); |
129 |
|
|
130 |
|
g.setColor(shadow); |
131 |
|
g.drawLine(x + 1, y + h - 2, x + w - 1, y + h - 2); |
132 |
|
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2); |
133 |
|
|
134 |
|
g.setColor(darkShadow); |
135 |
|
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); |
136 |
|
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); |
137 |
|
|
138 |
g.drawLine(x + 1, y + 1, x + w - 1, y + 1); |
g.setColor(saved); |
139 |
g.drawLine(x + 1, y + 1, x + 1, y + h - 1); |
} |
|
|
|
|
g.setColor(shadow); |
|
|
|
|
|
g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); |
|
|
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); |
|
|
|
|
|
g.setColor(darkShadow); |
|
|
|
|
|
g.drawLine(x, y + h, x + w, y + h); |
|
|
g.drawLine(x + w, y, x + w, y + h); |
|
|
|
|
|
g.setColor(saved); |
|
140 |
} |
} |
141 |
}; |
}; |
142 |
|
|
220 |
paintTriangle(g, x, y, defaultSize, direction, isEnabled()); |
paintTriangle(g, x, y, defaultSize, direction, isEnabled()); |
221 |
} |
} |
222 |
|
|
223 |
|
/** The preferred size for the button. */ |
224 |
|
private static final Dimension PREFERRED_SIZE = new Dimension(16, 16); |
225 |
|
|
226 |
|
/** The minimum size for the button. */ |
227 |
|
private static final Dimension MINIMUM_SIZE = new Dimension(5, 5); |
228 |
|
|
229 |
|
/** The maximum size for the button. */ |
230 |
|
private static final Dimension MAXIMUM_SIZE |
231 |
|
= new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); |
232 |
|
|
233 |
/** |
/** |
234 |
* This method returns the preferred size of the arrow button. |
* This method returns the preferred size of the arrow button. |
235 |
* |
* |
237 |
*/ |
*/ |
238 |
public Dimension getPreferredSize() |
public Dimension getPreferredSize() |
239 |
{ |
{ |
240 |
Insets insets = getInsets(); |
return PREFERRED_SIZE; |
|
int w = defaultSize + insets.left + insets.right; |
|
|
int h = defaultSize + insets.top + insets.bottom; |
|
|
|
|
|
return new Dimension(w, h); |
|
241 |
} |
} |
242 |
|
|
243 |
/** |
/** |
247 |
*/ |
*/ |
248 |
public Dimension getMinimumSize() |
public Dimension getMinimumSize() |
249 |
{ |
{ |
250 |
return getPreferredSize(); |
return MINIMUM_SIZE; |
251 |
} |
} |
252 |
|
|
253 |
/** |
/** |
257 |
*/ |
*/ |
258 |
public Dimension getMaximumSize() |
public Dimension getMaximumSize() |
259 |
{ |
{ |
260 |
return getPreferredSize(); |
return MAXIMUM_SIZE; |
261 |
} |
} |
262 |
|
|
263 |
/** |
/** |