47 |
import javax.swing.ButtonModel; |
import javax.swing.ButtonModel; |
48 |
import javax.swing.JButton; |
import javax.swing.JButton; |
49 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
50 |
|
import javax.swing.JMenuBar; |
51 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
52 |
import javax.swing.border.AbstractBorder; |
import javax.swing.border.AbstractBorder; |
53 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
247 |
} |
} |
248 |
|
|
249 |
/** |
/** |
250 |
|
* Returns the border insets. |
251 |
|
* |
252 |
|
* @param c the component (ignored). |
253 |
|
* |
254 |
|
* @return The border insets. |
255 |
|
*/ |
256 |
|
public Insets getBorderInsets(Component c) |
257 |
|
{ |
258 |
|
return borderInsets; |
259 |
|
} |
260 |
|
|
261 |
|
/** |
262 |
|
* Populates <code>insets</code> with the border insets, then returns it. |
263 |
|
* |
264 |
|
* @param c the component (ignored). |
265 |
|
* @param insets the object to populate with the border insets. |
266 |
|
* |
267 |
|
* @return The border insets. |
268 |
|
* |
269 |
|
* @throws NullPointerException if <code>insets</code> is <code>null</code>. |
270 |
|
*/ |
271 |
|
public Insets getBorderInsets(Component c, Insets insets) |
272 |
|
{ |
273 |
|
insets.left = borderInsets.left; |
274 |
|
insets.top = borderInsets.top; |
275 |
|
insets.bottom = borderInsets.bottom; |
276 |
|
insets.right = borderInsets.right; |
277 |
|
return insets; |
278 |
|
} |
279 |
|
} |
280 |
|
|
281 |
|
/** |
282 |
|
* A border used for {@link JMenuBar} components. |
283 |
|
*/ |
284 |
|
public static class MenuBarBorder |
285 |
|
extends AbstractBorder |
286 |
|
implements UIResource |
287 |
|
{ |
288 |
|
/** The border insets. */ |
289 |
|
protected static Insets borderInsets = new Insets(1, 0, 1, 0); |
290 |
|
|
291 |
|
// TODO: find where this color really comes from |
292 |
|
private static Color borderColor = new Color(153, 153, 153); |
293 |
|
|
294 |
|
/** |
295 |
|
* Creates a new border instance. |
296 |
|
*/ |
297 |
|
public MenuBarBorder() |
298 |
|
{ |
299 |
|
} |
300 |
|
|
301 |
|
/** |
302 |
|
* Paints the border for the component. A border is painted only if the |
303 |
|
* component is a selected {@link JMenu} or an armed {@link JMenuItem}. |
304 |
|
* |
305 |
|
* @param c the component. |
306 |
|
* @param g the graphics device. |
307 |
|
* @param x the x-coordinate of the border area. |
308 |
|
* @param y the y-coordinate of the border area. |
309 |
|
* @param w the width of the border area. |
310 |
|
* @param h the height of the border area. |
311 |
|
*/ |
312 |
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, |
313 |
|
int h) |
314 |
|
{ |
315 |
|
g.setColor(borderColor); |
316 |
|
g.drawLine(x, y + h - 1, x + w, y + h - 1); |
317 |
|
} |
318 |
|
|
319 |
|
/** |
320 |
* Returns the border insets. |
* Returns the border insets. |
321 |
* |
* |
322 |
* @param c the component (ignored). |
* @param c the component (ignored). |