1 /* MetalIconFactory.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.swing
.plaf
.metal
;
41 import java
.awt
.Color
;
42 import java
.awt
.Component
;
43 import java
.awt
.Graphics
;
44 import java
.io
.Serializable
;
46 import javax
.swing
.AbstractButton
;
47 import javax
.swing
.Icon
;
48 import javax
.swing
.JCheckBox
;
49 import javax
.swing
.JCheckBoxMenuItem
;
50 import javax
.swing
.JFileChooser
;
51 import javax
.swing
.JInternalFrame
;
52 import javax
.swing
.JRadioButton
;
53 import javax
.swing
.JRadioButtonMenuItem
;
54 import javax
.swing
.JSlider
;
55 import javax
.swing
.SwingConstants
;
56 import javax
.swing
.UIManager
;
57 import javax
.swing
.plaf
.UIResource
;
61 * Creates icons for the {@link MetalLookAndFeel}.
63 public class MetalIconFactory
implements Serializable
66 /** A constant representing "dark". */
67 public static final boolean DARK
= false;
69 /** A constant representing "light". */
70 public static final boolean LIGHT
= true;
72 /** A shared instance of the MenuArrowIcon. */
73 private static Icon menuArrow
;
75 /** A shared instance of the MenuItemArrowIcon. */
76 private static Icon menuItemArrow
;
79 * An icon displayed for {@link JCheckBoxMenuItem} components.
81 private static class CheckBoxMenuItemIcon
implements Icon
, Serializable
84 * Creates a new icon instance.
86 public CheckBoxMenuItemIcon()
88 // Nothing to do here.
92 * Returns the width of the icon, in pixels.
94 * @return The width of the icon (10 pixels).
96 public int getIconWidth()
102 * Returns the height of the icon, in pixels.
104 * @return The height of the icon (10 pixels).
106 public int getIconHeight()
114 * @param c the component.
115 * @param g the graphics device.
116 * @param x the x-coordinate.
117 * @param y the y-coordinate.
119 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
121 JCheckBoxMenuItem item
= (JCheckBoxMenuItem
) c
;
124 g
.setColor(MetalLookAndFeel
.getBlack());
126 g
.setColor(MetalLookAndFeel
.getControlDarkShadow());
127 g
.drawLine(x
, y
, x
+ 8, y
);
128 g
.drawLine(x
, y
+ 1, x
, y
+ 8);
129 g
.drawLine(x
+ 2, y
+ 8, x
+ 8, y
+ 8);
130 g
.drawLine(x
+ 8, y
+ 2, x
+ 8, y
+ 7);
132 g
.setColor(MetalLookAndFeel
.getWhite());
133 g
.drawLine(x
+ 1, y
+ 1, x
+ 7, y
+ 1);
134 g
.drawLine(x
+ 1, y
+ 2, x
+ 1, y
+ 7);
135 g
.drawLine(x
+ 1, y
+ 9, x
+ 9, y
+ 9);
136 g
.drawLine(x
+ 9, y
+ 1, x
+ 9, y
+ 8);
138 // if the item is selected, we should draw a tick
139 if (item
.isSelected())
141 g
.setColor(MetalLookAndFeel
.getBlack());
142 g
.fillRect(x
+ 2, y
+ 2, 2, 5);
143 for (int i
= 0; i
< 6; i
++)
144 g
.drawLine(x
+ 8 - i
, y
+ i
, x
+ 9 - i
, y
+ i
);
151 * An icon used for the "detail view" button on a {@link JFileChooser} under
152 * the {@link MetalLookAndFeel}.
154 * @see MetalIconFactory#getFileChooserDetailViewIcon()
156 private static class FileChooserDetailViewIcon
implements Icon
, Serializable
160 * Creates a new icon.
162 public FileChooserDetailViewIcon()
164 // Nothing to do here.
168 * Returns the width of the icon, in pixels.
170 * @return The width of the icon.
172 public int getIconWidth()
178 * Returns the height of the icon, in pixels.
180 * @return The height of the icon.
182 public int getIconHeight()
188 * Paints the icon using colors from the {@link MetalLookAndFeel}.
190 * @param c the component (ignored).
191 * @param g the graphics device.
192 * @param x the x-coordinate for the top-left of the icon.
193 * @param y the y-coordinate for the top-left of the icon.
195 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
197 Color savedColor
= g
.getColor();
198 g
.setColor(MetalLookAndFeel
.getBlack());
201 g
.drawLine(x
+ 2, y
+ 2, x
+ 5, y
+ 2);
202 g
.drawLine(x
+ 6, y
+ 3, x
+ 6, y
+ 7);
203 g
.drawLine(x
+ 2, y
+ 7, x
+ 6, y
+ 7);
204 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 7);
207 g
.drawLine(x
+ 2, y
+ 10, x
+ 5, y
+ 10);
208 g
.drawLine(x
+ 6, y
+ 11, x
+ 6, y
+ 15);
209 g
.drawLine(x
+ 2, y
+ 15, x
+ 6, y
+ 15);
210 g
.drawLine(x
+ 2, y
+ 10, x
+ 2, y
+ 15);
213 g
.drawLine(x
+ 8, y
+ 5, x
+ 15, y
+ 5);
214 g
.drawLine(x
+ 8, y
+ 13, x
+ 15, y
+ 13);
217 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
218 g
.fillRect(x
+ 3, y
+ 3, 3, 4);
219 g
.fillRect(x
+ 3, y
+ 11, 3, 4);
222 g
.setColor(MetalLookAndFeel
.getPrimaryControlHighlight());
223 g
.drawLine(x
+ 4, y
+ 4, x
+ 4, y
+ 5);
224 g
.drawLine(x
+ 4, y
+ 12, x
+ 4, y
+ 13);
226 g
.setColor(savedColor
);
231 * An icon used for the "home folder" button on a {@link JFileChooser} under
232 * the {@link MetalLookAndFeel}.
234 * @see MetalIconFactory#getFileChooserHomeFolderIcon()
236 private static class FileChooserHomeFolderIcon
implements Icon
, Serializable
240 * Creates a new icon.
242 public FileChooserHomeFolderIcon()
244 // Nothing to do here.
248 * Returns the width of the icon, in pixels.
250 * @return The width of the icon.
252 public int getIconWidth()
258 * Returns the height of the icon, in pixels.
260 * @return The height of the icon.
262 public int getIconHeight()
268 * Paints the icon using colors from the {@link MetalLookAndFeel}.
270 * @param c the component (ignored).
271 * @param g the graphics device.
272 * @param x the x-coordinate for the top-left of the icon.
273 * @param y the y-coordinate for the top-left of the icon.
275 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
277 Color savedColor
= g
.getColor();
278 g
.setColor(MetalLookAndFeel
.getBlack());
281 g
.drawLine(x
+ 1, y
+ 8, x
+ 8, y
+ 1);
282 g
.drawLine(x
+ 8, y
+ 1, x
+ 15, y
+ 8);
285 g
.drawLine(x
+ 3, y
+ 6, x
+ 3, y
+ 15);
286 g
.drawLine(x
+ 3, y
+ 15, x
+ 13, y
+ 15);
287 g
.drawLine(x
+ 13, y
+ 6, x
+ 13, y
+ 15);
290 g
.drawLine(x
+ 6, y
+ 9, x
+ 6, y
+ 15);
291 g
.drawLine(x
+ 6, y
+ 9, x
+ 10, y
+ 9);
292 g
.drawLine(x
+ 10, y
+ 9, x
+ 10, y
+ 15);
295 g
.drawLine(x
+ 11, y
+ 2, x
+ 11, y
+ 4);
296 g
.drawLine(x
+ 12, y
+ 2, x
+ 12, y
+ 5);
298 g
.setColor(MetalLookAndFeel
.getControlDarkShadow());
302 for (int i
= 0; i
< 4; i
++)
303 g
.drawLine(xx
- i
, y
+ 2 + i
, xx
+ i
, y
+ 2 + i
);
304 g
.fillRect(x
+ 4, y
+ 6, 9, 2);
307 g
.drawLine(x
+ 9, y
+ 12, x
+ 9, y
+ 12);
310 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
311 g
.drawLine(x
+ 4, y
+ 8, x
+ 12, y
+ 8);
312 g
.fillRect(x
+ 4, y
+ 9, 2, 6);
313 g
.fillRect(x
+ 11, y
+ 9, 2, 6);
315 g
.setColor(savedColor
);
320 * An icon used for the "list view" button on a {@link JFileChooser} under
321 * the {@link MetalLookAndFeel}.
323 * @see MetalIconFactory#getFileChooserListViewIcon()
325 private static class FileChooserListViewIcon
implements Icon
, Serializable
328 * Creates a new icon.
330 public FileChooserListViewIcon()
332 // Nothing to do here.
336 * Returns the width of the icon, in pixels.
338 * @return The width of the icon.
340 public int getIconWidth()
346 * Returns the height of the icon, in pixels.
348 * @return The height of the icon.
350 public int getIconHeight()
356 * Paints the icon using colors from the {@link MetalLookAndFeel}.
358 * @param c the component (ignored).
359 * @param g the graphics device.
360 * @param x the x-coordinate for the top-left of the icon.
361 * @param y the y-coordinate for the top-left of the icon.
363 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
365 Color savedColor
= g
.getColor();
366 g
.setColor(MetalLookAndFeel
.getBlack());
369 g
.drawLine(x
+ 2, y
+ 2, x
+ 5, y
+ 2);
370 g
.drawLine(x
+ 6, y
+ 3, x
+ 6, y
+ 7);
371 g
.drawLine(x
+ 2, y
+ 7, x
+ 6, y
+ 7);
372 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 7);
375 g
.drawLine(x
+ 2, y
+ 10, x
+ 5, y
+ 10);
376 g
.drawLine(x
+ 6, y
+ 11, x
+ 6, y
+ 15);
377 g
.drawLine(x
+ 2, y
+ 15, x
+ 6, y
+ 15);
378 g
.drawLine(x
+ 2, y
+ 10, x
+ 2, y
+ 15);
381 g
.drawLine(x
+ 10, y
+ 2, x
+ 13, y
+ 2);
382 g
.drawLine(x
+ 14, y
+ 3, x
+ 14, y
+ 7);
383 g
.drawLine(x
+ 10, y
+ 7, x
+ 14, y
+ 7);
384 g
.drawLine(x
+ 10, y
+ 2, x
+ 10, y
+ 7);
387 g
.drawLine(x
+ 10, y
+ 10, x
+ 13, y
+ 10);
388 g
.drawLine(x
+ 14, y
+ 11, x
+ 14, y
+ 15);
389 g
.drawLine(x
+ 10, y
+ 15, x
+ 14, y
+ 15);
390 g
.drawLine(x
+ 10, y
+ 10, x
+ 10, y
+ 15);
392 g
.drawLine(x
+ 8, y
+ 5, x
+ 8, y
+ 5);
393 g
.drawLine(x
+ 8, y
+ 13, x
+ 8, y
+ 13);
394 g
.drawLine(x
+ 16, y
+ 5, x
+ 16, y
+ 5);
395 g
.drawLine(x
+ 16, y
+ 13, x
+ 16, y
+ 13);
398 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
399 g
.fillRect(x
+ 3, y
+ 3, 3, 4);
400 g
.fillRect(x
+ 3, y
+ 11, 3, 4);
401 g
.fillRect(x
+ 11, y
+ 3, 3, 4);
402 g
.fillRect(x
+ 11, y
+ 11, 3, 4);
405 g
.setColor(MetalLookAndFeel
.getPrimaryControlHighlight());
406 g
.drawLine(x
+ 4, y
+ 4, x
+ 4, y
+ 5);
407 g
.drawLine(x
+ 4, y
+ 12, x
+ 4, y
+ 13);
408 g
.drawLine(x
+ 12, y
+ 4, x
+ 12, y
+ 5);
409 g
.drawLine(x
+ 12, y
+ 12, x
+ 12, y
+ 13);
411 g
.setColor(savedColor
);
416 * An icon used for the "new folder" button on a {@link JFileChooser} under
417 * the {@link MetalLookAndFeel}.
419 * @see MetalIconFactory#getFileChooserNewFolderIcon()
421 private static class FileChooserNewFolderIcon
implements Icon
, Serializable
424 * Creates a new icon.
426 public FileChooserNewFolderIcon()
428 // Nothing to do here.
432 * Returns the width of the icon, in pixels.
434 * @return The width of the icon.
436 public int getIconWidth()
442 * Returns the height of the icon, in pixels.
444 * @return The height of the icon.
446 public int getIconHeight()
452 * Paints the icon using colors from the {@link MetalLookAndFeel}.
454 * @param c the component (ignored).
455 * @param g the graphics device.
456 * @param x the x-coordinate for the top-left of the icon.
457 * @param y the y-coordinate for the top-left of the icon.
459 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
461 Color savedColor
= g
.getColor();
462 g
.setColor(MetalLookAndFeel
.getBlack());
464 g
.drawLine(x
+ 2, y
+ 5, x
+ 9, y
+ 5);
465 g
.drawLine(x
+ 10, y
+ 6, x
+ 15, y
+ 6);
466 g
.drawLine(x
+ 15, y
+ 5, x
+ 15, y
+ 14);
467 g
.drawLine(x
+ 2, y
+ 14, x
+ 15, y
+ 14);
468 g
.drawLine(x
+ 1, y
+ 6, x
+ 1, y
+ 14);
470 g
.setColor(MetalLookAndFeel
.getPrimaryControlDarkShadow());
471 g
.drawLine(x
+ 11, y
+ 3, x
+ 15, y
+ 3);
472 g
.drawLine(x
+ 10, y
+ 4, x
+ 15, y
+ 4);
474 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
475 g
.fillRect(x
+ 3, y
+ 7, 7, 7);
476 g
.fillRect(x
+ 10, y
+ 8, 5, 6);
477 g
.drawLine(x
+ 10, y
+ 5, x
+ 14, y
+ 5);
479 g
.setColor(MetalLookAndFeel
.getPrimaryControlHighlight());
480 g
.drawLine(x
+ 10, y
+ 7, x
+ 14, y
+ 7);
481 g
.drawLine(x
+ 2, y
+ 6, x
+ 9, y
+ 6);
482 g
.drawLine(x
+ 2, y
+ 6, x
+ 2, y
+ 13);
483 g
.setColor(savedColor
);
488 * An icon used for the "up folder" button on a {@link JFileChooser} under
489 * the {@link MetalLookAndFeel}.
491 * @see MetalIconFactory#getFileChooserNewFolderIcon()
493 private static class FileChooserUpFolderIcon
extends FileChooserNewFolderIcon
494 implements Icon
, Serializable
497 * Creates a new icon.
499 public FileChooserUpFolderIcon()
501 // Nothing to do here.
505 * Paints the icon using colors from the {@link MetalLookAndFeel}.
507 * @param c the component (ignored).
508 * @param g the graphics device.
509 * @param x the x-coordinate for the top-left of the icon.
510 * @param y the y-coordinate for the top-left of the icon.
512 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
514 Color savedColor
= g
.getColor();
517 super.paintIcon(c
, g
, x
, y
);
519 // now draw the up arrow
520 g
.setColor(MetalLookAndFeel
.getBlack());
521 g
.drawLine(x
+ 8, y
+ 9, x
+ 8, y
+ 16);
523 for (int i
= 0; i
< 4; i
++)
524 g
.drawLine(xx
- i
, y
+ 9 + i
, xx
+ i
, y
+ 9 + i
);
525 g
.setColor(savedColor
);
530 * An icon representing a file (drawn as a piece of paper with the top-right
531 * corner turned down).
533 public static class FileIcon16
implements Icon
, Serializable
536 * Returns the width of the icon, in pixels.
538 * @return The width of the icon.
540 public int getIconWidth()
546 * Returns the height of the icon, in pixels. The height returned is
547 * <code>16</code> plus the value returned by
548 * {@link #getAdditionalHeight()}.
550 * @return The height of the icon.
552 public int getIconHeight()
554 return 16 + getAdditionalHeight();
558 * Paints the icon at the location (x, y).
560 * @param c the component.
561 * @param g the graphics context.
562 * @param x the x coordinate.
563 * @param y the y coordinate.
565 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
567 // TODO: pick up appropriate UI colors
568 g
.setColor(Color
.black
);
569 g
.drawLine(x
, y
, x
+ 9, y
);
570 g
.drawLine(x
, y
+ 1, x
, y
+ 15);
571 g
.drawLine(x
, y
+ 15, x
+ 12, y
+ 15);
572 g
.drawLine(x
+ 12, y
+ 15, x
+ 12, y
+ 6);
573 g
.drawLine(x
+ 12, y
+ 6, x
+ 9, y
);
575 g
.drawLine(x
+ 7, y
+ 2, x
+ 11, y
+ 6);
576 g
.drawLine(x
+ 8, y
+ 1, x
+ 9, y
+ 1);
578 g
.setColor(new Color(204, 204, 255));
579 g
.drawLine(x
+ 1, y
+ 1, x
+ 7, y
+ 1);
580 g
.drawLine(x
+ 1, y
+ 1, x
+ 1, y
+ 14);
581 g
.drawLine(x
+ 1, y
+ 14, x
+ 11, y
+ 14);
582 g
.drawLine(x
+ 11, y
+ 14, x
+ 11, y
+ 7);
583 g
.drawLine(x
+ 8, y
+ 2, x
+ 10, y
+ 4);
587 * Returns the additional height for the icon. The
588 * {@link #getIconHeight()} method adds this value to the icon height it
589 * returns. Subclasses can override this method to adjust the icon height.
591 * @return The additional height (<code>0</code> unless overridden).
593 public int getAdditionalHeight()
599 * Returns the shift (???).
603 public int getShift()
611 * An icon representing a folder.
613 public static class FolderIcon16
implements Icon
, Serializable
616 * Returns the width of the icon, in pixels.
618 * @return The width of the icon.
620 public int getIconWidth() {
625 * Returns the height of the icon, in pixels. The height returned is
626 * <code>16</code> plus the value returned by
627 * {@link #getAdditionalHeight()}.
629 * @return The height of the icon.
631 public int getIconHeight()
633 return 16 + getAdditionalHeight();
637 * Paints the icon at the location (x, y).
639 * @param c the component.
640 * @param g the graphics device.
641 * @param x the x coordinate.
642 * @param y the y coordinate.
644 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
646 // TODO: pick up appropriate UI colors
647 g
.setColor(Color
.black
);
648 g
.drawLine(x
, y
+ 3, x
, y
+ 12);
649 g
.drawLine(x
, y
+ 12, x
+ 15, y
+ 12);
650 g
.drawLine(x
+ 15, y
+ 12, x
+ 15, y
+ 2);
651 g
.drawLine(x
+ 14, y
+ 3, x
+ 9, y
+ 3);
652 g
.drawLine(x
+ 8, y
+ 2, x
+ 1, y
+ 2);
653 g
.setColor(new Color(204, 204, 255));
654 g
.fillRect(x
+ 2, y
+ 4, 7, 8);
655 g
.fillRect(x
+ 9, y
+ 5, 6, 7);
656 g
.setColor(new Color(102, 102, 153));
657 g
.drawLine(x
+ 9, y
+ 2, x
+ 14, y
+ 2);
658 g
.setColor(new Color(50, 50, 120));
659 g
.drawLine(x
+ 9, y
+ 1, x
+ 15, y
+ 1);
660 g
.drawLine(x
+ 10, y
, x
+ 15, y
);
664 * Returns the additional height for the icon. The
665 * {@link #getIconHeight()} method adds this value to the icon height it
666 * returns. Subclasses can override this method to adjust the icon height.
668 * @return The additional height (<code>0</code> unless overridden).
670 public int getAdditionalHeight()
676 * Returns the shift (???).
680 public int getShift()
688 * An icon used by the {@link MetalInternalFrameUI} class when the frame
689 * is displayed as a palette.
693 public static class PaletteCloseIcon
694 implements Icon
, Serializable
, UIResource
697 * Returns the width of the icon, in pixels.
699 * @return The width of the icon.
701 public int getIconWidth()
707 * Returns the height of the icon, in pixels.
709 * @return The height of the icon.
711 public int getIconHeight()
717 * Paints the icon using colors from the {@link MetalLookAndFeel}.
719 * @param c the component (ignored).
720 * @param g the graphics device.
721 * @param x the x-coordinate for the top-left of the icon.
722 * @param y the y-coordinate for the top-left of the icon.
724 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
726 Color savedColor
= g
.getColor();
727 AbstractButton button
= (AbstractButton
) c
;
728 if (button
.getModel().isPressed())
729 g
.setColor(MetalLookAndFeel
.getBlack());
731 g
.setColor(MetalLookAndFeel
.getControlDarkShadow());
732 g
.fillRect(x
+ 2, y
+ 2, 3, 3);
733 g
.drawLine(x
+ 1, y
, x
+ 1, y
+ 2);
734 g
.drawLine(x
, y
+ 1, x
+ 2, y
+ 1);
735 g
.drawLine(x
+ 5, y
, x
+ 5, y
+ 2);
736 g
.drawLine(x
+ 4, y
+ 1, x
+ 6, y
+ 1);
737 g
.drawLine(x
+ 1, y
+ 4, x
+ 1, y
+ 6);
738 g
.drawLine(x
, y
+ 5, x
+ 2, y
+ 5);
739 g
.drawLine(x
+ 5, y
+ 4, x
+ 5, y
+ 6);
740 g
.drawLine(x
+ 4, y
+ 5, x
+ 6, y
+ 5);
741 g
.setColor(MetalLookAndFeel
.getControlHighlight());
742 g
.drawLine(x
+ 2, y
+ 6, x
+ 3, y
+ 5);
743 g
.drawLine(x
+ 5, y
+ 3, x
+ 6, y
+ 2);
744 g
.drawLine(x
+ 6, y
+ 6, x
+ 6, y
+ 6);
745 g
.setColor(savedColor
);
750 * An {@link Icon} implementation for {@link JCheckBox}es in the
751 * Metal Look & Feel.
753 * @author Roman Kennke (roman@kennke.org)
755 static class RadioButtonIcon
implements Icon
, UIResource
, Serializable
759 * Returns the width of the icon in pixels.
761 * @return the width of the icon in pixels
763 public int getIconWidth()
769 * Returns the height of the icon in pixels.
771 * @return the height of the icon in pixels
773 public int getIconHeight()
779 * Paints the icon, taking into account whether or not the component is
780 * enabled, selected and/or armed.
782 * @param c the Component to draw on (must be an instance of
783 * {@link JRadioButton})
784 * @param g the Graphics context to draw with
785 * @param x the X position
786 * @param y the Y position
788 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
790 if (UIManager
.get("RadioButton.gradient") != null)
791 MetalUtils
.paintGradient(g
, x
, y
, getIconWidth(), getIconHeight(),
792 SwingConstants
.VERTICAL
, "RadioButton.gradient");
794 Color savedColor
= g
.getColor();
795 JRadioButton b
= (JRadioButton
) c
;
799 g
.setColor(MetalLookAndFeel
.getControlDarkShadow());
801 g
.setColor(MetalLookAndFeel
.getControlDisabled());
802 g
.drawLine(x
+ 2, y
+ 1, x
+ 3, y
+ 1);
803 g
.drawLine(x
+ 4, y
, x
+ 7, y
);
804 g
.drawLine(x
+ 8, y
+ 1, x
+ 9, y
+ 1);
805 g
.drawLine(x
+ 10, y
+ 2, x
+ 10, y
+ 3);
806 g
.drawLine(x
+ 11, y
+ 4, x
+ 11, y
+ 7);
807 g
.drawLine(x
+ 10, y
+ 8, x
+ 10, y
+ 9);
808 g
.drawLine(x
+ 8, y
+ 10, x
+ 9, y
+ 10);
809 g
.drawLine(x
+ 4, y
+ 11, x
+ 7, y
+ 11);
810 g
.drawLine(x
+ 2, y
+ 10, x
+ 3, y
+ 10);
811 g
.drawLine(x
+ 1, y
+ 9, x
+ 1, y
+ 8);
812 g
.drawLine(x
, y
+ 7, x
, y
+ 4);
813 g
.drawLine(x
+ 1, y
+ 2, x
+ 1, y
+ 3);
815 if (b
.getModel().isArmed())
817 g
.setColor(MetalLookAndFeel
.getControlShadow());
818 g
.drawLine(x
+ 4, y
+ 1, x
+ 7, y
+ 1);
819 g
.drawLine(x
+ 4, y
+ 10, x
+ 7, y
+ 10);
820 g
.drawLine(x
+ 1, y
+ 4, x
+ 1, y
+ 7);
821 g
.drawLine(x
+ 10, y
+ 4, x
+ 10, y
+ 7);
822 g
.fillRect(x
+ 2, y
+ 2, 8, 8);
826 // only draw inner highlight if not filled
829 g
.setColor(MetalLookAndFeel
.getWhite());
831 g
.drawLine(x
+ 2, y
+ 8, x
+ 2, y
+ 9);
832 g
.drawLine(x
+ 1, y
+ 4, x
+ 1, y
+ 7);
833 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 3);
834 g
.drawLine(x
+ 3, y
+ 2, x
+ 3, y
+ 2);
835 g
.drawLine(x
+ 4, y
+ 1, x
+ 7, y
+ 1);
836 g
.drawLine(x
+ 8, y
+ 2, x
+ 9, y
+ 2);
840 // draw outer highlight
843 g
.setColor(MetalLookAndFeel
.getWhite());
846 g
.drawLine(x
+ 10, y
+ 1, x
+ 10, y
+ 1);
847 g
.drawLine(x
+ 11, y
+ 2, x
+ 11, y
+ 3);
848 g
.drawLine(x
+ 12, y
+ 4, x
+ 12, y
+ 7);
849 g
.drawLine(x
+ 11, y
+ 8, x
+ 11, y
+ 9);
850 g
.drawLine(x
+ 10, y
+ 10, x
+ 10, y
+ 10);
851 g
.drawLine(x
+ 8, y
+ 11, x
+ 9, y
+ 11);
852 g
.drawLine(x
+ 4, y
+ 12, x
+ 7, y
+ 12);
853 g
.drawLine(x
+ 2, y
+ 11, x
+ 3, y
+ 11);
859 g
.setColor(MetalLookAndFeel
.getBlack());
861 g
.setColor(MetalLookAndFeel
.getControlDisabled());
862 g
.drawLine(x
+ 4, y
+ 3, x
+ 7, y
+ 3);
863 g
.fillRect(x
+ 3, y
+ 4, 6, 4);
864 g
.drawLine(x
+ 4, y
+ 8, x
+ 7, y
+ 8);
866 g
.setColor(savedColor
);
871 * An icon displayed for {@link JRadioButtonMenuItem} components.
873 private static class RadioButtonMenuItemIcon
implements Icon
, Serializable
876 * Creates a new icon instance.
878 public RadioButtonMenuItemIcon()
880 // Nothing to do here.
884 * Returns the width of the icon, in pixels.
886 * @return The width of the icon.
888 public int getIconWidth()
894 * Returns the height of the icon, in pixels.
896 * @return The height of the icon.
898 public int getIconHeight()
906 * @param c the component.
907 * @param g the graphics device.
908 * @param x the x-coordinate.
909 * @param y the y-coordinate.
911 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
913 Color savedColor
= g
.getColor();
914 JRadioButtonMenuItem item
= (JRadioButtonMenuItem
) c
;
915 g
.setColor(MetalLookAndFeel
.getBlack());
916 g
.drawLine(x
+ 2, y
, x
+ 6, y
);
917 g
.drawLine(x
+ 7, y
+ 1, x
+ 7, y
+ 1);
918 g
.drawLine(x
+ 8, y
+ 2, x
+ 8, y
+ 6);
919 g
.drawLine(x
+ 7, y
+ 7, x
+ 7, y
+ 7);
920 g
.drawLine(x
+ 2, y
+ 8, x
+ 6, y
+ 8);
921 g
.drawLine(x
+ 1, y
+ 7, x
+ 1, y
+ 7);
922 g
.drawLine(x
, y
+ 2, x
, y
+ 6);
923 g
.drawLine(x
+ 1, y
+ 1, x
+ 1, y
+ 1);
925 if (item
.isSelected())
927 g
.drawLine(x
+ 3, y
+ 2, x
+ 5, y
+ 2);
928 g
.fillRect(x
+ 2, y
+ 3, 5, 3);
929 g
.drawLine(x
+ 3, y
+ 6, x
+ 5, y
+ 6);
933 g
.setColor(MetalLookAndFeel
.getControlHighlight());
934 g
.drawLine(x
+ 3, y
+ 1, x
+ 6, y
+ 1);
935 g
.drawLine(x
+ 8, y
+ 1, x
+ 8, y
+ 1);
936 g
.drawLine(x
+ 9, y
+ 2, x
+ 9, y
+ 7);
937 g
.drawLine(x
+ 8, y
+ 8, x
+ 8, y
+ 8);
938 g
.drawLine(x
+ 2, y
+ 9, x
+ 7, y
+ 9);
939 g
.drawLine(x
+ 1, y
+ 8, x
+ 1, y
+ 8);
940 g
.drawLine(x
+ 1, y
+ 3, x
+ 1, y
+ 6);
941 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 2);
942 g
.setColor(savedColor
);
947 * The icon used to display the thumb control on a horizontally oriented
948 * {@link JSlider} component.
950 private static class HorizontalSliderThumbIcon
implements Icon
, Serializable
954 * Creates a new instance.
956 public HorizontalSliderThumbIcon()
958 // Nothing to do here.
962 * Returns the width of the icon, in pixels.
964 * @return The width of the icon.
966 public int getIconWidth()
972 * Returns the height of the icon, in pixels.
974 * @return The height of the icon.
976 public int getIconHeight()
982 * Paints the icon, taking into account whether or not the component has
985 * @param c the component.
986 * @param g the graphics device.
987 * @param x the x-coordinate.
988 * @param y the y-coordinate.
990 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
992 boolean enabled
= false;
993 boolean focus
= false;
996 enabled
= c
.isEnabled();
997 focus
= c
.hasFocus();
1002 g
.setColor(MetalLookAndFeel
.getBlack());
1004 g
.setColor(MetalLookAndFeel
.getControlDarkShadow());
1005 g
.drawLine(x
+ 1, y
, x
+ 13, y
);
1006 g
.drawLine(x
+ 14, y
+ 1, x
+ 14, y
+ 7);
1007 g
.drawLine(x
+ 14, y
+ 8, x
+ 7, y
+ 15);
1008 g
.drawLine(x
+ 6, y
+ 14, x
, y
+ 8);
1009 g
.drawLine(x
, y
+ 7, x
, y
+ 1);
1013 g
.setColor(MetalLookAndFeel
.getPrimaryControlShadow());
1015 g
.setColor(MetalLookAndFeel
.getControl());
1016 g
.fillRect(x
+ 1, y
+ 2, 13, 7);
1017 g
.drawLine(x
+ 2, y
+ 9, x
+ 12, y
+ 9);
1018 g
.drawLine(x
+ 3, y
+ 10, x
+ 11, y
+ 10);
1019 g
.drawLine(x
+ 4, y
+ 11, x
+ 10, y
+ 11);
1020 g
.drawLine(x
+ 5, y
+ 12, x
+ 9, y
+ 12);
1021 g
.drawLine(x
+ 6, y
+ 13, x
+ 8, y
+ 13);
1022 g
.drawLine(x
+ 7, y
+ 14, x
+ 7, y
+ 14);
1024 // if the slider is enabled, draw dots and highlights
1028 g
.setColor(MetalLookAndFeel
.getPrimaryControlDarkShadow());
1030 g
.setColor(MetalLookAndFeel
.getBlack());
1031 g
.drawLine(x
+ 3, y
+ 3, x
+ 3, y
+ 3);
1032 g
.drawLine(x
+ 7, y
+ 3, x
+ 7, y
+ 3);
1033 g
.drawLine(x
+ 11, y
+ 3, x
+ 11, y
+ 3);
1035 g
.drawLine(x
+ 5, y
+ 5, x
+ 5, y
+ 5);
1036 g
.drawLine(x
+ 9, y
+ 5, x
+ 9, y
+ 5);
1038 g
.drawLine(x
+ 3, y
+ 7, x
+ 3, y
+ 7);
1039 g
.drawLine(x
+ 7, y
+ 7, x
+ 7, y
+ 7);
1040 g
.drawLine(x
+ 11, y
+ 7, x
+ 11, y
+ 7);
1044 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
1046 g
.setColor(MetalLookAndFeel
.getWhite());
1047 g
.drawLine(x
+ 1, y
+ 1, x
+ 13, y
+ 1);
1048 g
.drawLine(x
+ 1, y
+ 2, x
+ 1, y
+ 8);
1049 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 2);
1050 g
.drawLine(x
+ 6, y
+ 2, x
+ 6, y
+ 2);
1051 g
.drawLine(x
+ 10, y
+ 2, x
+ 10, y
+ 2);
1053 g
.drawLine(x
+ 4, y
+ 4, x
+ 4, y
+ 4);
1054 g
.drawLine(x
+ 8, y
+ 4, x
+ 8, y
+ 4);
1056 g
.drawLine(x
+ 2, y
+ 6, x
+ 2, y
+ 6);
1057 g
.drawLine(x
+ 6, y
+ 6, x
+ 6, y
+ 6);
1058 g
.drawLine(x
+ 10, y
+ 6, x
+ 10, y
+ 6);
1065 * An icon used for the 'close' button in the title frame of a
1066 * {@link JInternalFrame}.
1068 private static class InternalFrameCloseIcon
implements Icon
, Serializable
1070 /** The icon size in pixels. */
1074 * Creates a new icon.
1076 * @param size the icon size (width and height) in pixels.
1078 public InternalFrameCloseIcon(int size
)
1084 * Returns the width of the icon, in pixels.
1086 * @return The width of the icon.
1088 public int getIconWidth()
1094 * Returns the height of the icon, in pixels.
1096 * @return The height of the icon.
1098 public int getIconHeight()
1106 * @param c the component (an {@link JInternalFrame} is expected).
1107 * @param g the graphics device.
1108 * @param x the x-coordinate.
1109 * @param y the y-coordinate.
1111 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1113 Color savedColor
= g
.getColor();
1114 AbstractButton b
= (AbstractButton
) c
;
1116 // fill the interior
1117 if (b
.getModel().isPressed())
1118 // FIXME: also need to take into account whether the internal frame is
1120 g
.setColor(MetalLookAndFeel
.getPrimaryControlShadow());
1122 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
1123 g
.fillRect(x
+ 2, y
+ 2, 10, 10);
1125 // draw the outline box and the cross
1126 if (b
.getModel().isPressed())
1127 g
.setColor(MetalLookAndFeel
.getBlack());
1130 // FIXME: also need to take into account whether the internal frame is
1132 boolean selected
= true;
1134 g
.setColor(MetalLookAndFeel
.getPrimaryControlDarkShadow());
1136 g
.setColor(MetalLookAndFeel
.getControlDarkShadow());
1138 g
.drawLine(x
+ 1, y
+ 1, x
+ 13, y
+ 1);
1139 g
.drawLine(x
+ 1, y
+ 2, x
+ 1, y
+ 12);
1140 g
.drawLine(x
+ 1, y
+ 13, x
+ 13, y
+ 13);
1141 g
.drawLine(x
+ 13, y
+ 2, x
+ 13, y
+ 12);
1142 g
.drawLine(x
+ 2, y
+ 12, x
+ 2, y
+ 12);
1143 g
.drawLine(x
+ 12, y
+ 2, x
+ 12, y
+ 2);
1145 g
.fillRect(x
+ 4, y
+ 4, 2, 2);
1146 g
.fillRect(x
+ 5, y
+ 5, 4, 4);
1147 g
.drawLine(x
+ 9, y
+ 4, x
+ 10, y
+ 4);
1148 g
.drawLine(x
+ 9, y
+ 4, x
+ 9, y
+ 5);
1149 g
.drawLine(x
+ 4, y
+ 9, x
+ 4, y
+ 10);
1150 g
.drawLine(x
+ 4, y
+ 9, x
+ 5, y
+ 9);
1151 g
.drawLine(x
+ 9, y
+ 8, x
+ 9, y
+ 10);
1152 g
.drawLine(x
+ 8, y
+ 9, x
+ 10, y
+ 9);
1154 g
.setColor(MetalLookAndFeel
.getBlack());
1155 g
.drawLine(x
, y
, x
+ 13, y
);
1156 g
.drawLine(x
, y
+ 1, x
, y
+ 13);
1157 g
.drawLine(x
+ 3, y
+ 4, x
+ 4, y
+ 3);
1158 g
.drawLine(x
+ 3, y
+ 9, x
+ 5, y
+ 7);
1159 g
.drawLine(x
+ 7, y
+ 5, x
+ 9, y
+ 3);
1161 g
.drawLine(x
+ 12, y
+ 3, x
+ 12, y
+ 11);
1162 g
.drawLine(x
+ 3, y
+ 12, x
+ 12, y
+ 12);
1164 g
.setColor(MetalLookAndFeel
.getWhite());
1165 g
.drawLine(x
+ 1, y
+ 14, x
+ 14, y
+ 14);
1166 g
.drawLine(x
+ 14, y
+ 1, x
+ 14, y
+ 14);
1168 if (!b
.getModel().isPressed())
1170 g
.drawLine(x
+ 5, y
+ 10, x
+ 5, y
+ 10);
1171 g
.drawLine(x
+ 6, y
+ 9, x
+ 7, y
+ 9);
1172 g
.drawLine(x
+ 10, y
+ 5, x
+ 10, y
+ 5);
1173 g
.drawLine(x
+ 9, y
+ 6, x
+ 9, y
+ 7);
1174 g
.drawLine(x
+ 10, y
+ 10, x
+ 11, y
+ 10);
1175 g
.drawLine(x
+ 10, y
+ 11, x
+ 10, y
+ 11);
1177 g
.setColor(savedColor
);
1182 * The icon displayed at the top-left corner of a {@link JInternalFrame}.
1184 private static class InternalFrameDefaultMenuIcon
1185 implements Icon
, Serializable
1189 * Creates a new instance.
1191 public InternalFrameDefaultMenuIcon()
1193 // Nothing to do here.
1197 * Returns the width of the icon, in pixels.
1199 * @return The width of the icon.
1201 public int getIconWidth()
1207 * Returns the height of the icon, in pixels.
1209 * @return The height of the icon.
1211 public int getIconHeight()
1217 * Paints the icon at the specified location.
1219 * @param c the component.
1220 * @param g the graphics device.
1221 * @param x the x coordinate.
1222 * @param y the y coordinate.
1224 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1226 g
.setColor(new Color(102, 102, 153));
1227 g
.fillRect(x
+ 1, y
, 14, 2);
1228 g
.fillRect(x
, y
+ 1, 2, 14);
1229 g
.fillRect(x
+ 1, y
+ 14, 14, 2);
1230 g
.fillRect(x
+ 14, y
+ 1, 2, 14);
1231 g
.drawLine(x
+ 2, y
+ 5, x
+ 14, y
+ 5);
1233 g
.setColor(new Color(204, 204, 255));
1234 g
.fillRect(x
+ 2, y
+ 2, 12, 3);
1236 g
.setColor(new Color(102, 102, 153));
1237 g
.drawLine(x
+ 3, y
+ 3, x
+ 3, y
+ 3);
1238 g
.drawLine(x
+ 6, y
+ 3, x
+ 6, y
+ 3);
1239 g
.drawLine(x
+ 9, y
+ 3, x
+ 9, y
+ 3);
1240 g
.drawLine(x
+ 12, y
+ 3, x
+ 12, y
+ 3);
1242 g
.setColor(Color
.white
);
1243 g
.fillRect(x
+ 2, y
+ 6, 12, 8);
1244 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 2);
1245 g
.drawLine(x
+ 5, y
+ 2, x
+ 5, y
+ 2);
1246 g
.drawLine(x
+ 8, y
+ 2, x
+ 8, y
+ 2);
1247 g
.drawLine(x
+ 11, y
+ 2, x
+ 11, y
+ 2);
1252 * An icon used in the title frame of a {@link JInternalFrame}. When you
1253 * maximise an internal frame, this icon will replace the 'maximise' icon to
1254 * provide a 'restore' option.
1256 private static class InternalFrameAltMaximizeIcon
1257 implements Icon
, Serializable
1259 /** The icon size in pixels. */
1263 * Creates a new icon.
1265 * @param size the icon size in pixels.
1267 public InternalFrameAltMaximizeIcon(int size
)
1273 * Returns the width of the icon, in pixels.
1275 * @return The width of the icon.
1277 public int getIconWidth()
1283 * Returns the height of the icon, in pixels.
1285 * @return The height of the icon.
1287 public int getIconHeight()
1293 * Paints the icon at the specified location.
1295 * @param c the component.
1296 * @param g the graphics device.
1297 * @param x the x coordinate.
1298 * @param y the y coordinate.
1300 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1302 Color savedColor
= g
.getColor();
1304 AbstractButton b
= (AbstractButton
) c
;
1306 // fill the small box interior
1307 if (b
.getModel().isPressed())
1308 g
.setColor(MetalLookAndFeel
.getPrimaryControlShadow());
1310 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
1311 g
.fillRect(x
+ 2, y
+ 6, 7, 7);
1314 if (b
.getModel().isPressed())
1315 g
.setColor(MetalLookAndFeel
.getBlack());
1317 g
.setColor(MetalLookAndFeel
.getPrimaryControlDarkShadow());
1319 g
.drawLine(x
+ 12, y
+ 1, x
+ 13, y
+ 1);
1320 g
.drawLine(x
+ 11, y
+ 2, x
+ 12, y
+ 2);
1321 g
.drawLine(x
+ 10, y
+ 3, x
+ 11, y
+ 3);
1322 g
.drawLine(x
+ 8, y
+ 2, x
+ 8, y
+ 3);
1323 g
.fillRect(x
+ 8, y
+ 4, 3, 3);
1324 g
.drawLine(x
+ 11, y
+ 6, x
+ 12, y
+ 6);
1326 g
.drawLine(x
+ 1, y
+ 5, x
+ 5, y
+ 5);
1327 g
.drawLine(x
+ 1, y
+ 6, x
+ 1, y
+ 12);
1328 g
.drawLine(x
+ 9, y
+ 9, x
+ 9, y
+ 12);
1329 g
.drawLine(x
+ 1, y
+ 13, x
+ 9, y
+ 13);
1331 g
.drawLine(x
+ 2, y
+ 12, x
+ 2, y
+ 12);
1333 g
.setColor(MetalLookAndFeel
.getBlack());
1334 g
.drawLine(x
+ 12, y
, x
+ 9, y
+ 3);
1335 g
.drawLine(x
+ 7, y
+ 1, x
+ 8, y
+ 1);
1336 g
.drawLine(x
+ 7, y
+ 2, x
+ 7, y
+ 6);
1337 g
.drawLine(x
+ 11, y
+ 5, x
+ 12, y
+ 5);
1338 g
.drawLine(x
, y
+ 4, x
+ 5, y
+ 4);
1339 g
.drawLine(x
, y
+ 5, x
, y
+ 13);
1340 g
.drawLine(x
+ 3, y
+ 12, x
+ 8, y
+ 12);
1341 g
.drawLine(x
+ 8, y
+ 8, x
+ 8, y
+ 11);
1342 g
.drawLine(x
+ 9, y
+ 8, x
+ 9, y
+ 8);
1344 g
.setColor(MetalLookAndFeel
.getWhite());
1345 g
.drawLine(x
+ 9, y
+ 2, x
+ 9, y
+ 2);
1346 g
.drawLine(x
+ 11, y
+ 4, x
+ 13, y
+ 2);
1347 g
.drawLine(x
+ 13, y
+ 6, x
+ 13, y
+ 6);
1348 g
.drawLine(x
+ 8, y
+ 7, x
+ 13, y
+ 7);
1349 g
.drawLine(x
+ 6, y
+ 5, x
+ 6, y
+ 5);
1350 g
.drawLine(x
+ 10, y
+ 8, x
+ 10, y
+ 13);
1351 g
.drawLine(x
+ 1, y
+ 14, x
+ 10, y
+ 14);
1353 if (!b
.getModel().isPressed())
1355 g
.drawLine(x
+ 2, y
+ 6, x
+ 6, y
+ 6);
1356 g
.drawLine(x
+ 2, y
+ 6, x
+ 2, y
+ 11);
1359 g
.setColor(savedColor
);
1364 * An icon used for the 'maximize' button in the title frame of a
1365 * {@link JInternalFrame}.
1367 private static class InternalFrameMaximizeIcon
implements Icon
, Serializable
1371 * Creates a new instance.
1373 public InternalFrameMaximizeIcon()
1375 // Nothing to do here.
1379 * Returns the width of the icon, in pixels.
1381 * @return The width of the icon.
1383 public int getIconWidth()
1389 * Returns the height of the icon, in pixels.
1391 * @return The height of the icon.
1393 public int getIconHeight()
1399 * Paints the icon at the specified location.
1401 * @param c the component.
1402 * @param g the graphics device.
1403 * @param x the x coordinate.
1404 * @param y the y coordinate.
1406 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1408 Color savedColor
= g
.getColor();
1410 AbstractButton b
= (AbstractButton
) c
;
1412 // fill the interior
1413 if (b
.getModel().isPressed())
1414 g
.setColor(MetalLookAndFeel
.getPrimaryControlShadow());
1416 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
1417 g
.fillRect(x
+ 2, y
+ 6, 7, 7);
1419 if (b
.getModel().isPressed())
1420 g
.setColor(MetalLookAndFeel
.getBlack());
1422 g
.setColor(MetalLookAndFeel
.getPrimaryControlDarkShadow());
1424 g
.drawLine(x
+ 9, y
+ 1, x
+ 10, y
+ 1);
1425 g
.fillRect(x
+ 11, y
+ 1, 3, 3);
1426 g
.fillRect(x
+ 12, y
+ 4, 2, 2);
1427 g
.drawLine(x
+ 10, y
+ 3, x
+ 10, y
+ 3);
1428 g
.drawLine(x
+ 9, y
+ 4, x
+ 10, y
+ 4);
1429 g
.drawLine(x
+ 1, y
+ 5, x
+ 9, y
+ 5);
1430 g
.drawLine(x
+ 1, y
+ 6, x
+ 1, y
+ 12);
1431 g
.drawLine(x
+ 9, y
+ 6, x
+ 9, y
+ 12);
1432 g
.drawLine(x
+ 1, y
+ 13, x
+ 9, y
+ 13);
1435 g
.drawLine(x
+ 7, y
+ 6, x
+ 8, y
+ 6);
1436 g
.drawLine(x
+ 6, y
+ 7, x
+ 8, y
+ 7);
1437 g
.drawLine(x
+ 5, y
+ 8, x
+ 6, y
+ 8);
1438 g
.drawLine(x
+ 4, y
+ 9, x
+ 5, y
+ 9);
1439 g
.drawLine(x
+ 3, y
+ 10, x
+ 4, y
+ 10);
1440 g
.drawLine(x
+ 2, y
+ 11, x
+ 3, y
+ 11);
1441 g
.drawLine(x
+ 2, y
+ 12, x
+ 4, y
+ 12);
1442 g
.drawLine(x
+ 8, y
+ 8, x
+ 8, y
+ 8);
1445 g
.setColor(MetalLookAndFeel
.getBlack());
1446 g
.drawLine(x
+ 8, y
, x
+ 13, y
);
1447 g
.drawLine(x
+ 8, y
+ 1, x
+ 8, y
+ 1);
1448 g
.drawLine(x
+ 10, y
+ 2, x
+ 9, y
+ 3);
1449 g
.drawLine(x
, y
+ 4, x
+ 8, y
+ 4);
1450 g
.drawLine(x
, y
+ 5, x
, y
+ 13);
1452 g
.drawLine(x
+ 2, y
+ 10, x
+ 6, y
+ 6);
1453 g
.drawLine(x
+ 8, y
+ 9, x
+ 8, y
+ 11);
1454 g
.drawLine(x
+ 5, y
+ 12, x
+ 8, y
+ 12);
1457 g
.setColor(MetalLookAndFeel
.getWhite());
1458 if (!b
.getModel().isPressed())
1460 g
.drawLine(x
+ 2, y
+ 6, x
+ 5, y
+ 6);
1461 g
.drawLine(x
+ 2, y
+ 7, x
+ 2, y
+ 9);
1462 g
.drawLine(x
+ 4, y
+ 11, x
+ 7, y
+ 8);
1465 g
.drawLine(x
+ 1, y
+ 14, x
+ 10, y
+ 14);
1466 g
.drawLine(x
+ 10, y
+ 5, x
+ 10, y
+ 13);
1468 g
.drawLine(x
+ 9, y
+ 2, x
+ 9, y
+ 2);
1469 g
.drawLine(x
+ 11, y
+ 4, x
+ 11, y
+ 5);
1470 g
.drawLine(x
+ 13, y
+ 6, x
+ 14, y
+ 6);
1471 g
.drawLine(x
+ 14, y
+ 1, x
+ 14, y
+ 5);
1472 g
.setColor(savedColor
);
1477 * An icon used in the title frame of a {@link JInternalFrame}.
1479 private static class InternalFrameMinimizeIcon
implements Icon
, Serializable
1483 * Creates a new instance.
1485 public InternalFrameMinimizeIcon()
1487 // Nothing to do here.
1491 * Returns the width of the icon, in pixels.
1493 * @return The width of the icon.
1495 public int getIconWidth()
1501 * Returns the height of the icon, in pixels.
1503 * @return The height of the icon.
1505 public int getIconHeight()
1511 * Paints the icon at the specified location.
1513 * @param c the component.
1514 * @param g the graphics device.
1515 * @param x the x coordinate.
1516 * @param y the y coordinate.
1518 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1520 Color savedColor
= g
.getColor();
1522 AbstractButton b
= (AbstractButton
) c
;
1524 if (b
.getModel().isPressed())
1525 g
.setColor(MetalLookAndFeel
.getBlack());
1527 // FIXME: here the color depends on whether or not the internal frame
1529 g
.setColor(MetalLookAndFeel
.getPrimaryControlDarkShadow());
1531 g
.drawLine(x
+ 12, y
+ 1, x
+ 13, y
+ 1);
1532 g
.drawLine(x
+ 11, y
+ 2, x
+ 12, y
+ 2);
1533 g
.drawLine(x
+ 10, y
+ 3, x
+ 11, y
+ 3);
1534 g
.drawLine(x
+ 8, y
+ 2, x
+ 8, y
+ 3);
1535 g
.fillRect(x
+ 8, y
+ 4, 3, 3);
1536 g
.drawLine(x
+ 11, y
+ 6, x
+ 12, y
+ 6);
1538 g
.drawLine(x
+ 1, y
+ 8, x
+ 6, y
+ 8);
1539 g
.drawLine(x
+ 1, y
+ 9, x
+ 1, y
+ 12);
1540 g
.drawLine(x
+ 6, y
+ 9, x
+ 6, y
+ 12);
1541 g
.drawLine(x
+ 1, y
+ 13, x
+ 6, y
+ 13);
1543 g
.drawLine(x
+ 5, y
+ 9, x
+ 5, y
+ 9);
1544 g
.drawLine(x
+ 2, y
+ 12, x
+ 2, y
+ 12);
1546 g
.setColor(MetalLookAndFeel
.getBlack());
1547 g
.drawLine(x
+ 12, y
, x
+ 9, y
+ 3);
1548 g
.drawLine(x
+ 7, y
+ 1, x
+ 8, y
+ 1);
1549 g
.drawLine(x
+ 7, y
+ 2, x
+ 7, y
+ 6);
1550 g
.drawLine(x
, y
+ 7, x
+ 6, y
+ 7);
1551 g
.drawLine(x
, y
+ 8, x
, y
+ 13);
1552 g
.drawLine(x
+ 3, y
+ 12, x
+ 5, y
+ 12);
1553 g
.drawLine(x
+ 5, y
+ 10, x
+ 5, y
+ 11);
1554 g
.drawLine(x
+ 11, y
+ 5, x
+ 12, y
+ 5);
1556 g
.setColor(MetalLookAndFeel
.getWhite());
1557 g
.drawLine(x
+ 9, y
+ 2, x
+ 9, y
+ 2);
1558 g
.drawLine(x
+ 11, y
+ 4, x
+ 13, y
+ 2);
1559 g
.drawLine(x
+ 13, y
+ 6, x
+ 13, y
+ 6);
1560 g
.drawLine(x
+ 8, y
+ 7, x
+ 13, y
+ 7);
1561 g
.drawLine(x
+ 7, y
+ 9, x
+ 7, y
+ 13);
1562 g
.drawLine(x
+ 1, y
+ 14, x
+ 7, y
+ 14);
1564 if (b
.getModel().isPressed())
1566 g
.setColor(MetalLookAndFeel
.getPrimaryControlShadow());
1567 g
.fillRect(x
+ 2, y
+ 9, 3, 3);
1571 g
.drawLine(x
+ 2, y
+ 9, x
+ 4, y
+ 9);
1572 g
.drawLine(x
+ 2, y
+ 10, x
+ 2, y
+ 11);
1575 g
.setColor(savedColor
);
1580 * The icon used to display the thumb control on a horizontally oriented
1581 * {@link JSlider} component.
1583 private static class VerticalSliderThumbIcon
implements Icon
, Serializable
1586 * Creates a new instance.
1588 public VerticalSliderThumbIcon()
1590 // Nothing to do here.
1594 * Returns the width of the icon, in pixels.
1596 * @return The width of the icon.
1598 public int getIconWidth()
1604 * Returns the height of the icon, in pixels.
1606 * @return The height of the icon.
1608 public int getIconHeight()
1614 * Paints the icon taking into account whether the slider control has the
1617 * @param c the slider (must be a non-<code>null</code> instance of
1619 * @param g the graphics device.
1620 * @param x the x-coordinate.
1621 * @param y the y-coordinate.
1623 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1625 boolean enabled
= false;
1626 boolean focus
= false;
1629 enabled
= c
.isEnabled();
1630 focus
= c
.hasFocus();
1635 g
.setColor(MetalLookAndFeel
.getBlack());
1637 g
.setColor(MetalLookAndFeel
.getControlDarkShadow());
1638 g
.drawLine(x
+ 1, y
, x
+ 7, y
);
1639 g
.drawLine(x
+ 8, y
, x
+ 15, y
+ 7);
1640 g
.drawLine(x
+ 14, y
+ 8, x
+ 8, y
+ 14);
1641 g
.drawLine(x
+ 8, y
+ 14, x
+ 1, y
+ 14);
1642 g
.drawLine(x
, y
+ 13, x
, y
+ 1);
1646 g
.setColor(MetalLookAndFeel
.getPrimaryControlShadow());
1648 g
.setColor(MetalLookAndFeel
.getControl());
1649 g
.fillRect(x
+ 2, y
+ 1, 7, 13);
1650 g
.drawLine(x
+ 9, y
+ 2, x
+ 9, y
+ 12);
1651 g
.drawLine(x
+ 10, y
+ 3, x
+ 10, y
+ 11);
1652 g
.drawLine(x
+ 11, y
+ 4, x
+ 11, y
+ 10);
1653 g
.drawLine(x
+ 12, y
+ 5, x
+ 12, y
+ 9);
1654 g
.drawLine(x
+ 13, y
+ 6, x
+ 13, y
+ 8);
1655 g
.drawLine(x
+ 14, y
+ 7, x
+ 14, y
+ 7);
1657 // if the slider is enabled, draw dots and highlights
1661 g
.setColor(MetalLookAndFeel
.getPrimaryControlDarkShadow());
1663 g
.setColor(MetalLookAndFeel
.getBlack());
1664 g
.drawLine(x
+ 3, y
+ 3, x
+ 3, y
+ 3);
1665 g
.drawLine(x
+ 3, y
+ 7, x
+ 3, y
+ 7);
1666 g
.drawLine(x
+ 3, y
+ 11, x
+ 3, y
+ 11);
1668 g
.drawLine(x
+ 5, y
+ 5, x
+ 5, y
+ 5);
1669 g
.drawLine(x
+ 5, y
+ 9, x
+ 5, y
+ 9);
1671 g
.drawLine(x
+ 7, y
+ 3, x
+ 7, y
+ 3);
1672 g
.drawLine(x
+ 7, y
+ 7, x
+ 7, y
+ 7);
1673 g
.drawLine(x
+ 7, y
+ 11, x
+ 7, y
+ 11);
1677 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
1679 g
.setColor(MetalLookAndFeel
.getWhite());
1680 g
.drawLine(x
+ 1, y
+ 1, x
+ 8, y
+ 1);
1681 g
.drawLine(x
+ 1, y
+ 2, x
+ 1, y
+ 13);
1682 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 2);
1683 g
.drawLine(x
+ 2, y
+ 6, x
+ 2, y
+ 6);
1684 g
.drawLine(x
+ 2, y
+ 10, x
+ 2, y
+ 10);
1686 g
.drawLine(x
+ 4, y
+ 4, x
+ 4, y
+ 4);
1687 g
.drawLine(x
+ 4, y
+ 8, x
+ 4, y
+ 8);
1689 g
.drawLine(x
+ 6, y
+ 2, x
+ 6, y
+ 2);
1690 g
.drawLine(x
+ 6, y
+ 6, x
+ 6, y
+ 6);
1691 g
.drawLine(x
+ 6, y
+ 10, x
+ 6, y
+ 10);
1698 * A tree control icon. This icon can be in one of two states: expanded and
1701 public static class TreeControlIcon
implements Icon
, Serializable
1705 protected boolean isLight
;
1707 /** A flag that controls whether or not the icon is collapsed. */
1708 private boolean collapsed
;
1711 * Creates a new icon.
1713 * @param isCollapsed a flag that controls whether the icon is in the
1714 * collapsed state or the expanded state.
1716 public TreeControlIcon(boolean isCollapsed
)
1718 collapsed
= isCollapsed
;
1722 * Returns the width of the icon, in pixels.
1724 * @return The width of the icon.
1726 public int getIconWidth()
1731 * Returns the height of the icon, in pixels.
1733 * @return The height of the icon.
1735 public int getIconHeight()
1741 * Paints the icon at the location (x, y).
1743 * @param c the component.
1744 * @param g the graphics device.
1745 * @param x the x coordinate.
1746 * @param y the y coordinate.
1748 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1754 // TODO: pick up appropriate UI colors
1755 g
.setColor(Color
.black
);
1756 g
.drawLine(x
+ 2, y
, x
+ 5, y
);
1757 g
.drawLine(x
+ 6, y
+ 1, x
+ 7, y
+ 2);
1758 g
.fillRect(x
+ 7, y
+ 3, 5, 2);
1759 g
.drawLine(x
+ 7, y
+ 5, x
+ 6, y
+ 6);
1760 g
.drawLine(x
+ 1, y
+ 1, x
+ 1, y
+ 1);
1761 g
.drawLine(x
, y
+ 2, x
, y
+ 5);
1762 g
.drawLine(x
+ 1, y
+ 6, x
+ 1, y
+ 6);
1763 g
.drawLine(x
+ 2, y
+ 7, x
+ 5, y
+ 7);
1764 g
.fillRect(x
+ 3, y
+ 3, 2, 2);
1766 g
.setColor(new Color(204, 204, 255));
1767 g
.drawLine(x
+ 3, y
+ 2, x
+ 4, y
+ 2);
1768 g
.drawLine(x
+ 2, y
+ 3, x
+ 2, y
+ 4);
1769 g
.drawLine(x
+ 3, y
+ 5, x
+ 3, y
+ 5);
1770 g
.drawLine(x
+ 5, y
+ 3, x
+ 5, y
+ 3);
1772 g
.setColor(new Color(153, 153, 204));
1773 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 2);
1774 g
.drawLine(x
+ 2, y
+ 5, x
+ 2, y
+ 5);
1775 g
.drawLine(x
+ 2, y
+ 6, x
+ 5, y
+ 6);
1776 g
.drawLine(x
+ 5, y
+ 2, x
+ 5, y
+ 2);
1777 g
.drawLine(x
+ 6, y
+ 2, x
+ 6, y
+ 5);
1779 g
.setColor(new Color(102, 102, 153));
1780 g
.drawLine(x
+ 2, y
+ 1, x
+ 5, y
+ 1);
1781 g
.drawLine(x
+ 1, y
+ 2, x
+ 1, y
+ 5);
1785 // TODO: pick up appropriate UI colors
1786 g
.setColor(Color
.black
);
1787 g
.drawLine(x
+ 2, y
, x
+ 5, y
);
1788 g
.drawLine(x
+ 6, y
+ 1, x
+ 7, y
+ 2);
1789 g
.drawLine(x
+ 7, y
+ 2, x
+ 7, y
+ 5);
1790 g
.fillRect(x
+ 3, y
+ 7, 2, 5);
1791 g
.drawLine(x
+ 7, y
+ 5, x
+ 6, y
+ 6);
1792 g
.drawLine(x
+ 1, y
+ 1, x
+ 1, y
+ 1);
1793 g
.drawLine(x
, y
+ 2, x
, y
+ 5);
1794 g
.drawLine(x
+ 1, y
+ 6, x
+ 1, y
+ 6);
1795 g
.drawLine(x
+ 2, y
+ 7, x
+ 5, y
+ 7);
1796 g
.fillRect(x
+ 3, y
+ 3, 2, 2);
1798 g
.setColor(new Color(204, 204, 255));
1799 g
.drawLine(x
+ 3, y
+ 2, x
+ 4, y
+ 2);
1800 g
.drawLine(x
+ 2, y
+ 3, x
+ 2, y
+ 4);
1801 g
.drawLine(x
+ 3, y
+ 5, x
+ 3, y
+ 5);
1802 g
.drawLine(x
+ 5, y
+ 3, x
+ 5, y
+ 3);
1804 g
.setColor(new Color(153, 153, 204));
1805 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 2);
1806 g
.drawLine(x
+ 2, y
+ 5, x
+ 2, y
+ 5);
1807 g
.drawLine(x
+ 2, y
+ 6, x
+ 5, y
+ 6);
1808 g
.drawLine(x
+ 5, y
+ 2, x
+ 5, y
+ 2);
1809 g
.drawLine(x
+ 6, y
+ 2, x
+ 6, y
+ 5);
1811 g
.setColor(new Color(102, 102, 153));
1812 g
.drawLine(x
+ 2, y
+ 1, x
+ 5, y
+ 1);
1813 g
.drawLine(x
+ 1, y
+ 2, x
+ 1, y
+ 5);
1818 * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
1820 * @param c the component.
1821 * @param g the graphics device.
1822 * @param x the x coordinate.
1823 * @param y the y coordinate.
1825 public void paintMe(Component c
, Graphics g
, int x
, int y
)
1827 paintIcon(c
, g
, x
, y
);
1832 * A tree folder icon.
1834 public static class TreeFolderIcon
extends FolderIcon16
1837 * Creates a new instance.
1839 public TreeFolderIcon()
1841 // Nothing to do here.
1845 * Returns the additional height for this icon, in this case <code>2</code>
1848 * @return <code>2</code>.
1850 public int getAdditionalHeight()
1856 * Returns the shift (???).
1858 * @return The shift.
1860 public int getShift()
1869 public static class TreeLeafIcon
extends FileIcon16
1872 * Creates a new instance.
1874 public TreeLeafIcon()
1876 // Nothing to do here.
1880 * Returns the additional height for this icon, in this case <code>4</code>
1883 * @return <code>4</code>.
1885 public int getAdditionalHeight()
1891 * Returns the shift (???).
1893 * @return The shift.
1895 public int getShift()
1902 * An icon representing a hard disk.
1904 * @see MetalIconFactory#getTreeHardDriveIcon()
1906 private static class TreeHardDriveIcon
implements Icon
, Serializable
1910 * Creates a new icon instance.
1912 public TreeHardDriveIcon()
1914 // Nothing to do here.
1918 * Returns the width of the icon, in pixels.
1920 * @return <code>16</code>.
1922 public int getIconWidth()
1928 * Returns the height of the icon, in pixels.
1930 * @return <code>16</code>.
1932 public int getIconHeight()
1938 * Paints the icon at the specified location, using colors from the
1941 * @param c the component (ignored).
1942 * @param g the graphics device.
1943 * @param x the x-coordinate for the top-left of the icon.
1944 * @param y the y-coordinate for the top-left of the icon.
1946 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
1948 Color saved
= g
.getColor();
1949 g
.setColor(MetalLookAndFeel
.getBlack());
1950 g
.drawLine(x
+ 1, y
+ 4, x
+ 1, y
+ 5);
1951 g
.drawLine(x
+ 14, y
+ 4, x
+ 14, y
+ 5);
1952 g
.drawLine(x
+ 1, y
+ 7, x
+ 1, y
+ 8);
1953 g
.drawLine(x
+ 14, y
+ 7, x
+ 14, y
+ 8);
1954 g
.drawLine(x
+ 1, y
+ 10, x
+ 1, y
+ 11);
1955 g
.drawLine(x
+ 14, y
+ 10, x
+ 14, y
+ 11);
1957 g
.drawLine(x
+ 2, y
+ 3, x
+ 3, y
+ 3);
1958 g
.drawLine(x
+ 12, y
+ 3, x
+ 13, y
+ 3);
1959 g
.drawLine(x
+ 2, y
+ 6, x
+ 3, y
+ 6);
1960 g
.drawLine(x
+ 12, y
+ 6, x
+ 13, y
+ 6);
1961 g
.drawLine(x
+ 2, y
+ 9, x
+ 3, y
+ 9);
1962 g
.drawLine(x
+ 12, y
+ 9, x
+ 13, y
+ 9);
1963 g
.drawLine(x
+ 2, y
+ 12, x
+ 3, y
+ 12);
1964 g
.drawLine(x
+ 12, y
+ 12, x
+ 13, y
+ 12);
1966 g
.drawLine(x
+ 4, y
+ 2, x
+ 11, y
+ 2);
1967 g
.drawLine(x
+ 4, y
+ 7, x
+ 11, y
+ 7);
1968 g
.drawLine(x
+ 4, y
+ 10, x
+ 11, y
+ 10);
1969 g
.drawLine(x
+ 4, y
+ 13, x
+ 11, y
+ 13);
1971 g
.setColor(MetalLookAndFeel
.getWhite());
1972 g
.fillRect(x
+ 4, y
+ 3, 2, 2);
1973 g
.drawLine(x
+ 6, y
+ 4, x
+ 6, y
+ 4);
1974 g
.drawLine(x
+ 7, y
+ 3, x
+ 9, y
+ 3);
1975 g
.drawLine(x
+ 8, y
+ 4, x
+ 8, y
+ 4);
1976 g
.drawLine(x
+ 11, y
+ 3, x
+ 11, y
+ 3);
1977 g
.fillRect(x
+ 2, y
+ 4, 2, 2);
1978 g
.fillRect(x
+ 2, y
+ 7, 2, 2);
1979 g
.fillRect(x
+ 2, y
+ 10, 2, 2);
1980 g
.drawLine(x
+ 4, y
+ 6, x
+ 4, y
+ 6);
1981 g
.drawLine(x
+ 4, y
+ 9, x
+ 4, y
+ 9);
1982 g
.drawLine(x
+ 4, y
+ 12, x
+ 4, y
+ 12);
1984 g
.setColor(MetalLookAndFeel
.getControlShadow());
1985 g
.drawLine(x
+ 13, y
+ 4, x
+ 13, y
+ 4);
1986 g
.drawLine(x
+ 12, y
+ 5, x
+ 13, y
+ 5);
1987 g
.drawLine(x
+ 13, y
+ 7, x
+ 13, y
+ 7);
1988 g
.drawLine(x
+ 12, y
+ 8, x
+ 13, y
+ 8);
1989 g
.drawLine(x
+ 13, y
+ 10, x
+ 13, y
+ 10);
1990 g
.drawLine(x
+ 12, y
+ 11, x
+ 13, y
+ 11);
1992 g
.drawLine(x
+ 10, y
+ 5, x
+ 10, y
+ 5);
1993 g
.drawLine(x
+ 7, y
+ 6, x
+ 7, y
+ 6);
1994 g
.drawLine(x
+ 9, y
+ 6, x
+ 9, y
+ 6);
1995 g
.drawLine(x
+ 11, y
+ 6, x
+ 11, y
+ 6);
1997 g
.drawLine(x
+ 10, y
+ 8, x
+ 10, y
+ 8);
1998 g
.drawLine(x
+ 7, y
+ 9, x
+ 7, y
+ 9);
1999 g
.drawLine(x
+ 9, y
+ 9, x
+ 9, y
+ 9);
2000 g
.drawLine(x
+ 11, y
+ 9, x
+ 11, y
+ 9);
2002 g
.drawLine(x
+ 10, y
+ 11, x
+ 10, y
+ 11);
2003 g
.drawLine(x
+ 7, y
+ 12, x
+ 7, y
+ 12);
2004 g
.drawLine(x
+ 9, y
+ 12, x
+ 9, y
+ 12);
2005 g
.drawLine(x
+ 11, y
+ 12, x
+ 11, y
+ 12);
2012 * An icon representing a floppy disk.
2014 * @see MetalIconFactory#getTreeFloppyDriveIcon()
2016 private static class TreeFloppyDriveIcon
implements Icon
, Serializable
2020 * Creates a new icon instance.
2022 public TreeFloppyDriveIcon()
2024 // Nothing to do here.
2028 * Returns the width of the icon, in pixels.
2030 * @return <code>16</code>.
2032 public int getIconWidth()
2038 * Returns the height of the icon, in pixels.
2040 * @return <code>16</code>.
2042 public int getIconHeight()
2048 * Paints the icon at the specified location, using colors from the
2051 * @param c the component (ignored).
2052 * @param g the graphics device.
2053 * @param x the x-coordinate for the top-left of the icon.
2054 * @param y the y-coordinate for the top-left of the icon.
2056 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
2058 Color saved
= g
.getColor();
2060 g
.setColor(MetalLookAndFeel
.getBlack());
2061 g
.drawLine(x
+ 1, y
+ 1, x
+ 13, y
+ 1);
2062 g
.drawLine(x
+ 1, y
+ 1, x
+ 1, y
+ 14);
2063 g
.drawLine(x
+ 1, y
+ 14, x
+ 14, y
+ 14);
2064 g
.drawLine(x
+ 14, y
+ 2, x
+ 14, y
+ 14);
2066 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
2067 g
.fillRect(x
+ 2, y
+ 2, 12, 12);
2069 g
.setColor(MetalLookAndFeel
.getControlShadow());
2070 g
.fillRect(x
+ 5, y
+ 2, 6, 5);
2071 g
.drawLine(x
+ 4, y
+ 8, x
+ 11, y
+ 8);
2072 g
.drawLine(x
+ 3, y
+ 9, x
+ 3, y
+ 13);
2073 g
.drawLine(x
+ 12, y
+ 9, x
+ 12, y
+ 13);
2075 g
.setColor(MetalLookAndFeel
.getWhite());
2076 g
.fillRect(x
+ 8, y
+ 3, 2, 3);
2077 g
.fillRect(x
+ 4, y
+ 9, 8, 5);
2079 g
.setColor(MetalLookAndFeel
.getPrimaryControlShadow());
2080 g
.drawLine(x
+ 5, y
+ 10, x
+ 9, y
+ 10);
2081 g
.drawLine(x
+ 5, y
+ 12, x
+ 8, y
+ 12);
2088 * An icon representing a computer.
2090 * @see MetalIconFactory#getTreeComputerIcon()
2092 private static class TreeComputerIcon
implements Icon
, Serializable
2096 * Creates a new icon instance.
2098 public TreeComputerIcon()
2100 // Nothing to do here.
2104 * Returns the width of the icon, in pixels.
2106 * @return <code>16</code>.
2108 public int getIconWidth()
2114 * Returns the height of the icon, in pixels.
2116 * @return <code>16</code>.
2118 public int getIconHeight()
2124 * Paints the icon at the specified location, using colors from the
2127 * @param c the component (ignored).
2128 * @param g the graphics device.
2129 * @param x the x-coordinate for the top-left of the icon.
2130 * @param y the y-coordinate for the top-left of the icon.
2132 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
2134 Color saved
= g
.getColor();
2136 g
.setColor(MetalLookAndFeel
.getBlack());
2137 g
.drawLine(x
+ 3, y
+ 1, x
+ 12, y
+ 1);
2138 g
.drawLine(x
+ 2, y
+ 2, x
+ 2, y
+ 8);
2139 g
.drawLine(x
+ 13, y
+ 2, x
+ 13, y
+ 8);
2140 g
.drawLine(x
+ 3, y
+ 9, x
+ 3, y
+ 9);
2141 g
.drawLine(x
+ 12, y
+ 9, x
+ 12, y
+ 9);
2142 g
.drawRect(x
+ 1, y
+ 10, 13, 4);
2143 g
.drawLine(x
+ 5, y
+ 3, x
+ 10, y
+ 3);
2144 g
.drawLine(x
+ 5, y
+ 8, x
+ 10, y
+ 8);
2145 g
.drawLine(x
+ 4, y
+ 4, x
+ 4, y
+ 7);
2146 g
.drawLine(x
+ 11, y
+ 4, x
+ 11, y
+ 7);
2148 g
.setColor(MetalLookAndFeel
.getPrimaryControl());
2149 g
.fillRect(x
+ 5, y
+ 4, 6, 4);
2151 g
.setColor(MetalLookAndFeel
.getControlShadow());
2152 g
.drawLine(x
+ 6, y
+ 12, x
+ 8, y
+ 12);
2153 g
.drawLine(x
+ 10, y
+ 12, x
+ 12, y
+ 12);
2158 /** The icon returned by {@link #getCheckBoxIcon()}. */
2159 private static Icon checkBoxIcon
;
2161 /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
2162 private static Icon checkBoxMenuItemIcon
;
2164 /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
2165 private static Icon fileChooserDetailViewIcon
;
2167 /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
2168 private static Icon fileChooserHomeFolderIcon
;
2170 /** The icon returned by {@link #getFileChooserListViewIcon()}. */
2171 private static Icon fileChooserListViewIcon
;
2173 /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
2174 private static Icon fileChooserNewFolderIcon
;
2176 /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
2177 private static Icon fileChooserUpFolderIcon
;
2179 /** The cached RadioButtonIcon instance. */
2180 private static RadioButtonIcon radioButtonIcon
;
2182 /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
2183 private static Icon radioButtonMenuItemIcon
;
2185 /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
2186 private static Icon internalFrameDefaultMenuIcon
;
2188 /** The icon returned by {@link #getTreeComputerIcon()}. */
2189 private static Icon treeComputerIcon
;
2191 /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
2192 private static Icon treeFloppyDriveIcon
;
2194 /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
2195 private static Icon treeHardDriveIcon
;
2198 * Creates a new instance. All the methods are static, so creating an
2199 * instance isn't necessary.
2201 public MetalIconFactory()
2203 // Nothing to do here.
2207 * Returns an icon for use when rendering the {@link JCheckBox} component.
2209 * @return A check box icon.
2213 public static Icon
getCheckBoxIcon()
2215 if (checkBoxIcon
== null)
2216 checkBoxIcon
= new MetalCheckBoxIcon();
2217 return checkBoxIcon
;
2221 * Returns an icon for use when rendering the {@link JCheckBoxMenuItem}
2226 public static Icon
getCheckBoxMenuItemIcon()
2228 if (checkBoxMenuItemIcon
== null)
2229 checkBoxMenuItemIcon
= new CheckBoxMenuItemIcon();
2230 return checkBoxMenuItemIcon
;
2234 * Returns an icon for use by the {@link JFileChooser} component.
2238 public static Icon
getFileChooserDetailViewIcon()
2240 if (fileChooserDetailViewIcon
== null)
2241 fileChooserDetailViewIcon
= new FileChooserDetailViewIcon();
2242 return fileChooserDetailViewIcon
;
2246 * Returns an icon for use by the {@link JFileChooser} component.
2250 public static Icon
getFileChooserHomeFolderIcon()
2252 if (fileChooserHomeFolderIcon
== null)
2253 fileChooserHomeFolderIcon
= new FileChooserHomeFolderIcon();
2254 return fileChooserHomeFolderIcon
;
2258 * Returns an icon for use by the {@link JFileChooser} component.
2262 public static Icon
getFileChooserListViewIcon()
2264 if (fileChooserListViewIcon
== null)
2265 fileChooserListViewIcon
= new FileChooserListViewIcon();
2266 return fileChooserListViewIcon
;
2270 * Returns an icon for use by the {@link JFileChooser} component.
2274 public static Icon
getFileChooserNewFolderIcon()
2276 if (fileChooserNewFolderIcon
== null)
2277 fileChooserNewFolderIcon
= new FileChooserNewFolderIcon();
2278 return fileChooserNewFolderIcon
;
2282 * Returns an icon for use by the {@link JFileChooser} component.
2286 public static Icon
getFileChooserUpFolderIcon()
2288 if (fileChooserUpFolderIcon
== null)
2289 fileChooserUpFolderIcon
= new FileChooserUpFolderIcon();
2290 return fileChooserUpFolderIcon
;
2294 * Returns an icon for RadioButtons in the Metal L&F.
2296 * @return an icon for RadioButtons in the Metal L&F
2298 public static Icon
getRadioButtonIcon()
2300 if (radioButtonIcon
== null)
2301 radioButtonIcon
= new RadioButtonIcon();
2302 return radioButtonIcon
;
2306 * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
2308 * @return A new icon instance.
2310 public static Icon
getRadioButtonMenuItemIcon()
2312 if (radioButtonMenuItemIcon
== null)
2313 radioButtonMenuItemIcon
= new RadioButtonMenuItemIcon();
2314 return radioButtonMenuItemIcon
;
2318 * Returns the icon used to display the thumb for a horizontally oriented
2323 public static Icon
getHorizontalSliderThumbIcon()
2325 return new HorizontalSliderThumbIcon();
2329 * Creates a new icon used to represent the 'close' button in the title
2330 * pane of a {@link JInternalFrame}.
2332 * @param size the icon size.
2334 * @return A close icon.
2336 public static Icon
getInternalFrameCloseIcon(int size
)
2338 return new InternalFrameCloseIcon(size
);
2342 * Creates a new icon for the menu in a {@link JInternalFrame}. This is the
2343 * icon displayed at the top left of the frame.
2345 * @return A menu icon.
2347 public static Icon
getInternalFrameDefaultMenuIcon()
2349 if (internalFrameDefaultMenuIcon
== null)
2350 internalFrameDefaultMenuIcon
= new InternalFrameDefaultMenuIcon();
2351 return internalFrameDefaultMenuIcon
;
2355 * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
2357 * @param size the icon size in pixels.
2361 * @see #getInternalFrameAltMaximizeIcon(int)
2363 public static Icon
getInternalFrameMaximizeIcon(int size
)
2365 return new InternalFrameMaximizeIcon();
2369 * Returns the icon used for the minimize button in the frame title for a
2370 * {@link JInternalFrame}.
2372 * @param size the icon size in pixels (ignored by this implementation).
2376 public static Icon
getInternalFrameMinimizeIcon(int size
)
2378 return new InternalFrameMinimizeIcon();
2382 * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
2383 * that has been maximised.
2385 * @param size the icon size in pixels.
2389 * @see #getInternalFrameMaximizeIcon(int)
2391 public static Icon
getInternalFrameAltMaximizeIcon(int size
)
2393 return new InternalFrameAltMaximizeIcon(size
);
2397 * Returns the icon used to display the thumb for a vertically oriented
2402 public static Icon
getVerticalSliderThumbIcon()
2404 return new VerticalSliderThumbIcon();
2408 * Creates and returns a new tree folder icon.
2410 * @return A new tree folder icon.
2412 public static Icon
getTreeFolderIcon()
2414 return new TreeFolderIcon();
2418 * Creates and returns a new tree leaf icon.
2420 * @return A new tree leaf icon.
2422 public static Icon
getTreeLeafIcon()
2424 return new TreeLeafIcon();
2428 * Creates and returns a tree control icon.
2430 * @param isCollapsed a flag that controls whether the icon is in the
2431 * collapsed or expanded state.
2433 * @return A tree control icon.
2435 public static Icon
getTreeControlIcon(boolean isCollapsed
)
2437 return new TreeControlIcon(isCollapsed
);
2441 * Returns a <code>16x16</code> icon representing a computer.
2445 public static Icon
getTreeComputerIcon()
2447 if (treeComputerIcon
== null)
2448 treeComputerIcon
= new TreeComputerIcon();
2449 return treeComputerIcon
;
2453 * Returns a <code>16x16</code> icon representing a floppy disk.
2457 public static Icon
getTreeFloppyDriveIcon()
2459 if (treeFloppyDriveIcon
== null)
2460 treeFloppyDriveIcon
= new TreeFloppyDriveIcon();
2461 return treeFloppyDriveIcon
;
2465 * Returns a <code>16x16</code> icon representing a hard disk.
2469 public static Icon
getTreeHardDriveIcon()
2471 if (treeHardDriveIcon
== null)
2472 treeHardDriveIcon
= new TreeHardDriveIcon();
2473 return treeHardDriveIcon
;
2477 * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2478 * points to the right. This is displayed in menu items that have a
2483 public static Icon
getMenuArrowIcon()
2485 if (menuArrow
== null)
2486 menuArrow
= new Icon()
2488 public int getIconHeight()
2493 public int getIconWidth()
2498 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
2500 Color saved
= g
.getColor();
2501 g
.setColor(Color
.BLACK
);
2502 for (int i
= 0; i
< 4; i
++)
2503 g
.drawLine(x
+ i
, y
+ i
, x
+ i
, y
+ 7 - i
);
2511 * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2512 * points to the right. This is displayed in menu items that have a sub menu.
2516 public static Icon
getMenuItemArrowIcon()
2518 if (menuItemArrow
== null)
2519 menuItemArrow
= new Icon()
2521 public int getIconHeight()
2526 public int getIconWidth()
2531 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
2533 Color saved
= g
.getColor();
2534 g
.setColor(Color
.BLACK
);
2535 for (int i
= 0; i
< 4; i
++)
2536 g
.drawLine(x
+ i
, y
+ i
, x
+ i
, y
+ 7 - i
);
2540 return menuItemArrow
;
2544 * Returns a new instance of a 13 x 13 icon showing a small black check mark.
2548 public static Icon
getMenuItemCheckIcon()
2552 public int getIconHeight()
2557 public int getIconWidth()
2562 public void paintIcon(Component c
, Graphics g
, int x
, int y
)
2564 Color saved
= g
.getColor();
2565 g
.setColor(Color
.BLACK
);
2566 g
.drawLine(3 + x
, 5 + y
, 3 + x
, 9 + y
);
2567 g
.drawLine(4 + x
, 5 + y
, 4 + x
, 9 + y
);
2568 g
.drawLine(5 + x
, 7 + y
, 9 + x
, 3 + y
);
2569 g
.drawLine(5 + x
, 8 + y
, 9 + x
, 4 + y
);