40 |
import java.awt.Color; |
import java.awt.Color; |
41 |
import java.awt.Component; |
import java.awt.Component; |
42 |
import java.awt.Dimension; |
import java.awt.Dimension; |
43 |
|
import java.awt.Insets; |
44 |
import java.awt.Graphics; |
import java.awt.Graphics; |
45 |
import java.awt.Polygon; |
import java.awt.Polygon; |
46 |
import java.awt.Rectangle; |
import java.awt.Rectangle; |
47 |
|
import javax.swing.border.Border; |
48 |
import javax.swing.Icon; |
import javax.swing.Icon; |
49 |
import javax.swing.JButton; |
import javax.swing.JButton; |
50 |
import javax.swing.SwingConstants; |
import javax.swing.SwingConstants; |
172 |
/** The top and left edges of the button. */ |
/** The top and left edges of the button. */ |
173 |
private transient Color highlight = Color.BLACK; |
private transient Color highlight = Color.BLACK; |
174 |
|
|
175 |
|
/** The border around the ArrowButton. */ |
176 |
|
private transient Border tmpBorder = new Border() |
177 |
|
{ |
178 |
|
public Insets getBorderInsets(Component c) |
179 |
|
{ |
180 |
|
return new Insets(0, 0, 0, 0); |
181 |
|
} |
182 |
|
|
183 |
|
public boolean isBorderOpaque() |
184 |
|
{ |
185 |
|
return false; |
186 |
|
} |
187 |
|
|
188 |
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) |
189 |
|
{ |
190 |
|
Rectangle bounds = getBounds(); |
191 |
|
|
192 |
|
Color saved = g.getColor(); |
193 |
|
g.setColor(highlight); |
194 |
|
|
195 |
|
g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height); |
196 |
|
g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); |
197 |
|
|
198 |
|
g.setColor(shadow); |
199 |
|
|
200 |
|
g.drawLine(bounds.x + 1, bounds.y + bounds.height - 1, |
201 |
|
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); |
202 |
|
g.drawLine(bounds.x + bounds.width - 1, bounds.y + 1, |
203 |
|
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); |
204 |
|
|
205 |
|
g.setColor(darkShadow); |
206 |
|
|
207 |
|
g.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width, |
208 |
|
bounds.y + bounds.height); |
209 |
|
g.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width, |
210 |
|
bounds.y + bounds.height); |
211 |
|
|
212 |
|
g.setColor(saved); |
213 |
|
} |
214 |
|
}; |
215 |
|
|
216 |
/** |
/** |
217 |
* Creates a new BasicArrowButton object. |
* Creates a new BasicArrowButton object. |
218 |
* |
* |
222 |
{ |
{ |
223 |
super(); |
super(); |
224 |
setDirection(direction); |
setDirection(direction); |
225 |
|
setBorder(tmpBorder); |
226 |
} |
} |
227 |
|
|
228 |
/** |
/** |
278 |
public void paint(Graphics g) |
public void paint(Graphics g) |
279 |
{ |
{ |
280 |
super.paint(g); |
super.paint(g); |
|
Rectangle bounds = getBounds(); |
|
|
|
|
|
Color saved = g.getColor(); |
|
|
g.setColor(highlight); |
|
|
|
|
|
g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height); |
|
|
g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); |
|
|
|
|
|
g.setColor(shadow); |
|
|
|
|
|
g.drawLine(bounds.x + 1, bounds.y + bounds.height - 1, |
|
|
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); |
|
|
g.drawLine(bounds.x + bounds.width - 1, bounds.y + 1, |
|
|
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); |
|
|
|
|
|
g.setColor(darkShadow); |
|
|
|
|
|
g.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width, |
|
|
bounds.y + bounds.height); |
|
|
g.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width, |
|
|
bounds.y + bounds.height); |
|
|
|
|
|
g.setColor(saved); |
|
281 |
} |
} |
282 |
|
|
283 |
/** |
/** |