Merge from mainline.
[official-gcc.git] / libjava / classpath / javax / swing / plaf / metal / MetalIconFactory.java
blobd24a0526232ad9f90b477d2d1adb69992a2b9636
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)
9 any later version.
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
19 02110-1301 USA.
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
24 combination.
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;
60 /**
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;
78 /**
79 * An icon displayed for {@link JCheckBoxMenuItem} components.
81 private static class CheckBoxMenuItemIcon implements Icon, Serializable
83 /**
84 * Creates a new icon instance.
86 public CheckBoxMenuItemIcon()
88 // Nothing to do here.
91 /**
92 * Returns the width of the icon, in pixels.
94 * @return The width of the icon (10 pixels).
96 public int getIconWidth()
98 return 10;
102 * Returns the height of the icon, in pixels.
104 * @return The height of the icon (10 pixels).
106 public int getIconHeight()
108 return 10;
112 * Paints the icon.
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;
123 if (item.isArmed())
124 g.setColor(MetalLookAndFeel.getBlack());
125 else
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()
174 return 18;
178 * Returns the height of the icon, in pixels.
180 * @return The height of the icon.
182 public int getIconHeight()
184 return 18;
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());
200 // file 1 outline
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);
206 // file 2 outline
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);
212 // detail lines
213 g.drawLine(x + 8, y + 5, x + 15, y + 5);
214 g.drawLine(x + 8, y + 13, x + 15, y + 13);
216 // fill files
217 g.setColor(MetalLookAndFeel.getPrimaryControl());
218 g.fillRect(x + 3, y + 3, 3, 4);
219 g.fillRect(x + 3, y + 11, 3, 4);
221 // highlight files
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()
254 return 18;
258 * Returns the height of the icon, in pixels.
260 * @return The height of the icon.
262 public int getIconHeight()
264 return 18;
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());
280 // roof
281 g.drawLine(x + 1, y + 8, x + 8, y + 1);
282 g.drawLine(x + 8, y + 1, x + 15, y + 8);
284 // base of house
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);
289 // door frame
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);
294 // chimney
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());
300 // roof paint
301 int xx = x + 8;
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);
306 // door knob
307 g.drawLine(x + 9, y + 12, x + 9, y + 12);
309 // house paint
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()
342 return 18;
346 * Returns the height of the icon, in pixels.
348 * @return The height of the icon.
350 public int getIconHeight()
352 return 18;
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());
368 // file 1 outline
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);
374 // file 2 outline
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);
380 // file 3 outline
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);
386 // file 4 outline
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);
397 // fill files
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);
404 // highlight files
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
423 /**
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()
438 return 18;
442 * Returns the height of the icon, in pixels.
444 * @return The height of the icon.
446 public int getIconHeight()
448 return 18;
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();
516 // draw the folder
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);
522 int xx = x + 8;
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()
542 return 16;
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()
595 return 0;
599 * Returns the shift (???).
601 * @return The shift.
603 public int getShift()
605 return 0;
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() {
621 return 16;
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()
672 return 0;
676 * Returns the shift (???).
678 * @return The shift.
680 public int getShift()
682 return 0;
688 * An icon used by the {@link MetalInternalFrameUI} class when the frame
689 * is displayed as a palette.
691 * @since 1.3
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()
703 return 7;
707 * Returns the height of the icon, in pixels.
709 * @return The height of the icon.
711 public int getIconHeight()
713 return 7;
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());
730 else
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 &amp; Feel.
753 * @author Roman Kennke (roman@kennke.org)
755 static class RadioButtonIcon implements Icon, UIResource, Serializable
759 * This is used as a mask when painting the gradient. See
760 * {@link MetalUtils#paintGradient(java.awt.Graphics, int, int, int, int,
761 * float, float, java.awt.Color, java.awt.Color, java.awt.Color, int,
762 * int[][])} for details.
764 private static int[][] gradientMask = new int[][] {{3, 7}, {1, 9}, {1, 9},
765 {0, 10}, {0, 10}, {0, 10},
766 {0, 10}, {1, 9}, {1, 9},
767 {3, 7}};
770 * Returns the width of the icon in pixels.
772 * @return the width of the icon in pixels
774 public int getIconWidth()
776 return 13;
780 * Returns the height of the icon in pixels.
782 * @return the height of the icon in pixels
784 public int getIconHeight()
786 return 13;
790 * Paints the icon, taking into account whether or not the component is
791 * enabled, selected and/or armed.
793 * @param c the Component to draw on (must be an instance of
794 * {@link JRadioButton})
795 * @param g the Graphics context to draw with
796 * @param x the X position
797 * @param y the Y position
799 public void paintIcon(Component c, Graphics g, int x, int y)
801 if (UIManager.get("RadioButton.gradient") != null)
802 MetalUtils.paintGradient(g, x + 2, y + 2, 8, 8,
803 SwingConstants.VERTICAL, "RadioButton.gradient",
804 gradientMask);
806 Color savedColor = g.getColor();
807 JRadioButton b = (JRadioButton) c;
809 // draw outer circle
810 if (b.isEnabled())
811 g.setColor(MetalLookAndFeel.getControlDarkShadow());
812 else
813 g.setColor(MetalLookAndFeel.getControlDisabled());
814 g.drawLine(x + 2, y + 1, x + 3, y + 1);
815 g.drawLine(x + 4, y, x + 7, y);
816 g.drawLine(x + 8, y + 1, x + 9, y + 1);
817 g.drawLine(x + 10, y + 2, x + 10, y + 3);
818 g.drawLine(x + 11, y + 4, x + 11, y + 7);
819 g.drawLine(x + 10, y + 8, x + 10, y + 9);
820 g.drawLine(x + 8, y + 10, x + 9, y + 10);
821 g.drawLine(x + 4, y + 11, x + 7, y + 11);
822 g.drawLine(x + 2, y + 10, x + 3, y + 10);
823 g.drawLine(x + 1, y + 9, x + 1, y + 8);
824 g.drawLine(x, y + 7, x, y + 4);
825 g.drawLine(x + 1, y + 2, x + 1, y + 3);
827 if (b.getModel().isArmed())
829 g.setColor(MetalLookAndFeel.getControlShadow());
830 g.drawLine(x + 4, y + 1, x + 7, y + 1);
831 g.drawLine(x + 4, y + 10, x + 7, y + 10);
832 g.drawLine(x + 1, y + 4, x + 1, y + 7);
833 g.drawLine(x + 10, y + 4, x + 10, y + 7);
834 g.fillRect(x + 2, y + 2, 8, 8);
836 else
838 // only draw inner highlight if not filled
839 if (b.isEnabled())
841 g.setColor(MetalLookAndFeel.getWhite());
843 g.drawLine(x + 2, y + 8, x + 2, y + 9);
844 g.drawLine(x + 1, y + 4, x + 1, y + 7);
845 g.drawLine(x + 2, y + 2, x + 2, y + 3);
846 g.drawLine(x + 3, y + 2, x + 3, y + 2);
847 g.drawLine(x + 4, y + 1, x + 7, y + 1);
848 g.drawLine(x + 8, y + 2, x + 9, y + 2);
852 // draw outer highlight
853 if (b.isEnabled())
855 g.setColor(MetalLookAndFeel.getWhite());
857 // outer
858 g.drawLine(x + 10, y + 1, x + 10, y + 1);
859 g.drawLine(x + 11, y + 2, x + 11, y + 3);
860 g.drawLine(x + 12, y + 4, x + 12, y + 7);
861 g.drawLine(x + 11, y + 8, x + 11, y + 9);
862 g.drawLine(x + 10, y + 10, x + 10, y + 10);
863 g.drawLine(x + 8, y + 11, x + 9, y + 11);
864 g.drawLine(x + 4, y + 12, x + 7, y + 12);
865 g.drawLine(x + 2, y + 11, x + 3, y + 11);
868 if (b.isSelected())
870 if (b.isEnabled())
871 g.setColor(MetalLookAndFeel.getBlack());
872 else
873 g.setColor(MetalLookAndFeel.getControlDisabled());
874 g.drawLine(x + 4, y + 3, x + 7, y + 3);
875 g.fillRect(x + 3, y + 4, 6, 4);
876 g.drawLine(x + 4, y + 8, x + 7, y + 8);
878 g.setColor(savedColor);
883 * An icon displayed for {@link JRadioButtonMenuItem} components.
885 private static class RadioButtonMenuItemIcon implements Icon, Serializable
888 * Creates a new icon instance.
890 public RadioButtonMenuItemIcon()
892 // Nothing to do here.
896 * Returns the width of the icon, in pixels.
898 * @return The width of the icon.
900 public int getIconWidth()
902 return 10;
906 * Returns the height of the icon, in pixels.
908 * @return The height of the icon.
910 public int getIconHeight()
912 return 10;
916 * Paints the icon.
918 * @param c the component.
919 * @param g the graphics device.
920 * @param x the x-coordinate.
921 * @param y the y-coordinate.
923 public void paintIcon(Component c, Graphics g, int x, int y)
925 Color savedColor = g.getColor();
926 JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
927 g.setColor(MetalLookAndFeel.getBlack());
928 g.drawLine(x + 2, y, x + 6, y);
929 g.drawLine(x + 7, y + 1, x + 7, y + 1);
930 g.drawLine(x + 8, y + 2, x + 8, y + 6);
931 g.drawLine(x + 7, y + 7, x + 7, y + 7);
932 g.drawLine(x + 2, y + 8, x + 6, y + 8);
933 g.drawLine(x + 1, y + 7, x + 1, y + 7);
934 g.drawLine(x, y + 2, x, y + 6);
935 g.drawLine(x + 1, y + 1, x + 1, y + 1);
937 if (item.isSelected())
939 g.drawLine(x + 3, y + 2, x + 5, y + 2);
940 g.fillRect(x + 2, y + 3, 5, 3);
941 g.drawLine(x + 3, y + 6, x + 5, y + 6);
944 // highlight
945 g.setColor(MetalLookAndFeel.getControlHighlight());
946 g.drawLine(x + 3, y + 1, x + 6, y + 1);
947 g.drawLine(x + 8, y + 1, x + 8, y + 1);
948 g.drawLine(x + 9, y + 2, x + 9, y + 7);
949 g.drawLine(x + 8, y + 8, x + 8, y + 8);
950 g.drawLine(x + 2, y + 9, x + 7, y + 9);
951 g.drawLine(x + 1, y + 8, x + 1, y + 8);
952 g.drawLine(x + 1, y + 3, x + 1, y + 6);
953 g.drawLine(x + 2, y + 2, x + 2, y + 2);
954 g.setColor(savedColor);
959 * The icon used to display the thumb control on a horizontally oriented
960 * {@link JSlider} component.
962 private static class HorizontalSliderThumbIcon implements Icon, Serializable
966 * This mask is used to paint the gradient in the shape of the thumb.
968 int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
969 {0, 12}, {0, 12}, {0, 12}, {1, 12},
970 {2, 10}, {3, 9}, {4, 8}, {5, 7},
971 {6, 6}};
974 * Creates a new instance.
976 public HorizontalSliderThumbIcon()
978 // Nothing to do here.
982 * Returns the width of the icon, in pixels.
984 * @return The width of the icon.
986 public int getIconWidth()
988 return 15;
992 * Returns the height of the icon, in pixels.
994 * @return The height of the icon.
996 public int getIconHeight()
998 return 16;
1002 * Paints the icon, taking into account whether or not the component has
1003 * the focus.
1005 * @param c the component.
1006 * @param g the graphics device.
1007 * @param x the x-coordinate.
1008 * @param y the y-coordinate.
1010 public void paintIcon(Component c, Graphics g, int x, int y)
1012 boolean enabled = false;
1013 boolean focus = false;
1014 if (c != null)
1016 enabled = c.isEnabled();
1017 focus = c.hasFocus();
1020 // draw the outline
1021 if (enabled)
1022 g.setColor(MetalLookAndFeel.getBlack());
1023 else
1024 g.setColor(MetalLookAndFeel.getControlDarkShadow());
1025 g.drawLine(x + 1, y, x + 13, y);
1026 g.drawLine(x + 14, y + 1, x + 14, y + 7);
1027 g.drawLine(x + 14, y + 8, x + 7, y + 15);
1028 g.drawLine(x + 6, y + 14, x, y + 8);
1029 g.drawLine(x, y + 7, x, y + 1);
1031 // Fill the icon.
1032 if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
1033 && enabled)
1035 String gradient;
1036 if (focus)
1037 gradient = "Slider.focusGradient";
1038 else
1039 gradient = "Slider.gradient";
1040 MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13,
1041 SwingConstants.VERTICAL, gradient,
1042 gradientMask);
1044 else
1046 if (focus)
1047 g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1048 else
1049 g.setColor(MetalLookAndFeel.getControl());
1050 g.fillRect(x + 1, y + 2, 13, 7);
1051 g.drawLine(x + 2, y + 9, x + 12, y + 9);
1052 g.drawLine(x + 3, y + 10, x + 11, y + 10);
1053 g.drawLine(x + 4, y + 11, x + 10, y + 11);
1054 g.drawLine(x + 5, y + 12, x + 9, y + 12);
1055 g.drawLine(x + 6, y + 13, x + 8, y + 13);
1056 g.drawLine(x + 7, y + 14, x + 7, y + 14);
1059 // If the slider is enabled, draw dots and highlights.
1060 if (c.isEnabled()
1061 && !(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
1063 if (focus)
1064 g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1065 else
1066 g.setColor(MetalLookAndFeel.getBlack());
1067 g.drawLine(x + 3, y + 3, x + 3, y + 3);
1068 g.drawLine(x + 7, y + 3, x + 7, y + 3);
1069 g.drawLine(x + 11, y + 3, x + 11, y + 3);
1071 g.drawLine(x + 5, y + 5, x + 5, y + 5);
1072 g.drawLine(x + 9, y + 5, x + 9, y + 5);
1074 g.drawLine(x + 3, y + 7, x + 3, y + 7);
1075 g.drawLine(x + 7, y + 7, x + 7, y + 7);
1076 g.drawLine(x + 11, y + 7, x + 11, y + 7);
1078 // Draw highlights
1079 if (focus)
1080 g.setColor(MetalLookAndFeel.getPrimaryControl());
1081 else
1082 g.setColor(MetalLookAndFeel.getWhite());
1083 g.drawLine(x + 1, y + 1, x + 13, y + 1);
1084 g.drawLine(x + 1, y + 2, x + 1, y + 8);
1085 g.drawLine(x + 2, y + 2, x + 2, y + 2);
1086 g.drawLine(x + 6, y + 2, x + 6, y + 2);
1087 g.drawLine(x + 10, y + 2, x + 10, y + 2);
1089 g.drawLine(x + 4, y + 4, x + 4, y + 4);
1090 g.drawLine(x + 8, y + 4, x + 8, y + 4);
1092 g.drawLine(x + 2, y + 6, x + 2, y + 6);
1093 g.drawLine(x + 6, y + 6, x + 6, y + 6);
1094 g.drawLine(x + 10, y + 6, x + 10, y + 6);
1101 * An icon used for the 'close' button in the title frame of a
1102 * {@link JInternalFrame}.
1104 private static class InternalFrameCloseIcon implements Icon, Serializable
1106 /** The icon size in pixels. */
1107 private int size;
1110 * Creates a new icon.
1112 * @param size the icon size (width and height) in pixels.
1114 public InternalFrameCloseIcon(int size)
1116 this.size = size;
1120 * Returns the width of the icon, in pixels.
1122 * @return The width of the icon.
1124 public int getIconWidth()
1126 return size;
1130 * Returns the height of the icon, in pixels.
1132 * @return The height of the icon.
1134 public int getIconHeight()
1136 return size;
1140 * Paints the icon.
1142 * @param c the component (an {@link JInternalFrame} is expected).
1143 * @param g the graphics device.
1144 * @param x the x-coordinate.
1145 * @param y the y-coordinate.
1147 public void paintIcon(Component c, Graphics g, int x, int y)
1149 Color savedColor = g.getColor();
1150 AbstractButton b = (AbstractButton) c;
1152 // fill the interior
1153 if (b.getModel().isPressed())
1154 // FIXME: also need to take into account whether the internal frame is
1155 // selected
1156 g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1157 else
1158 g.setColor(MetalLookAndFeel.getPrimaryControl());
1159 g.fillRect(x + 2, y + 2, 10, 10);
1161 // draw the outline box and the cross
1162 if (b.getModel().isPressed())
1163 g.setColor(MetalLookAndFeel.getBlack());
1164 else
1166 // FIXME: also need to take into account whether the internal frame is
1167 // selected
1168 boolean selected = true;
1169 if (selected)
1170 g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1171 else
1172 g.setColor(MetalLookAndFeel.getControlDarkShadow());
1174 g.drawLine(x + 1, y + 1, x + 13, y + 1);
1175 g.drawLine(x + 1, y + 2, x + 1, y + 12);
1176 g.drawLine(x + 1, y + 13, x + 13, y + 13);
1177 g.drawLine(x + 13, y + 2, x + 13, y + 12);
1178 g.drawLine(x + 2, y + 12, x + 2, y + 12);
1179 g.drawLine(x + 12, y + 2, x + 12, y + 2);
1181 g.fillRect(x + 4, y + 4, 2, 2);
1182 g.fillRect(x + 5, y + 5, 4, 4);
1183 g.drawLine(x + 9, y + 4, x + 10, y + 4);
1184 g.drawLine(x + 9, y + 4, x + 9, y + 5);
1185 g.drawLine(x + 4, y + 9, x + 4, y + 10);
1186 g.drawLine(x + 4, y + 9, x + 5, y + 9);
1187 g.drawLine(x + 9, y + 8, x + 9, y + 10);
1188 g.drawLine(x + 8, y + 9, x + 10, y + 9);
1190 g.setColor(MetalLookAndFeel.getBlack());
1191 g.drawLine(x, y, x + 13, y);
1192 g.drawLine(x, y + 1, x, y + 13);
1193 g.drawLine(x + 3, y + 4, x + 4, y + 3);
1194 g.drawLine(x + 3, y + 9, x + 5, y + 7);
1195 g.drawLine(x + 7, y + 5, x + 9, y + 3);
1197 g.drawLine(x + 12, y + 3, x + 12, y + 11);
1198 g.drawLine(x + 3, y + 12, x + 12, y + 12);
1200 g.setColor(MetalLookAndFeel.getWhite());
1201 g.drawLine(x + 1, y + 14, x + 14, y + 14);
1202 g.drawLine(x + 14, y + 1, x + 14, y + 14);
1204 if (!b.getModel().isPressed())
1206 g.drawLine(x + 5, y + 10, x + 5, y + 10);
1207 g.drawLine(x + 6, y + 9, x + 7, y + 9);
1208 g.drawLine(x + 10, y + 5, x + 10, y + 5);
1209 g.drawLine(x + 9, y + 6, x + 9, y + 7);
1210 g.drawLine(x + 10, y + 10, x + 11, y + 10);
1211 g.drawLine(x + 10, y + 11, x + 10, y + 11);
1213 g.setColor(savedColor);
1218 * The icon displayed at the top-left corner of a {@link JInternalFrame}.
1220 private static class InternalFrameDefaultMenuIcon
1221 implements Icon, Serializable
1225 * Creates a new instance.
1227 public InternalFrameDefaultMenuIcon()
1229 // Nothing to do here.
1233 * Returns the width of the icon, in pixels.
1235 * @return The width of the icon.
1237 public int getIconWidth()
1239 return 16;
1243 * Returns the height of the icon, in pixels.
1245 * @return The height of the icon.
1247 public int getIconHeight()
1249 return 16;
1253 * Paints the icon at the specified location.
1255 * @param c the component.
1256 * @param g the graphics device.
1257 * @param x the x coordinate.
1258 * @param y the y coordinate.
1260 public void paintIcon(Component c, Graphics g, int x, int y)
1262 g.setColor(new Color(102, 102, 153));
1263 g.fillRect(x + 1, y, 14, 2);
1264 g.fillRect(x, y + 1, 2, 14);
1265 g.fillRect(x + 1, y + 14, 14, 2);
1266 g.fillRect(x + 14, y + 1, 2, 14);
1267 g.drawLine(x + 2, y + 5, x + 14, y + 5);
1269 g.setColor(new Color(204, 204, 255));
1270 g.fillRect(x + 2, y + 2, 12, 3);
1272 g.setColor(new Color(102, 102, 153));
1273 g.drawLine(x + 3, y + 3, x + 3, y + 3);
1274 g.drawLine(x + 6, y + 3, x + 6, y + 3);
1275 g.drawLine(x + 9, y + 3, x + 9, y + 3);
1276 g.drawLine(x + 12, y + 3, x + 12, y + 3);
1278 g.setColor(Color.white);
1279 g.fillRect(x + 2, y + 6, 12, 8);
1280 g.drawLine(x + 2, y + 2, x + 2, y + 2);
1281 g.drawLine(x + 5, y + 2, x + 5, y + 2);
1282 g.drawLine(x + 8, y + 2, x + 8, y + 2);
1283 g.drawLine(x + 11, y + 2, x + 11, y + 2);
1288 * An icon used in the title frame of a {@link JInternalFrame}. When you
1289 * maximise an internal frame, this icon will replace the 'maximise' icon to
1290 * provide a 'restore' option.
1292 private static class InternalFrameAltMaximizeIcon
1293 implements Icon, Serializable
1295 /** The icon size in pixels. */
1296 private int size;
1299 * Creates a new icon.
1301 * @param size the icon size in pixels.
1303 public InternalFrameAltMaximizeIcon(int size)
1305 this.size = size;
1309 * Returns the width of the icon, in pixels.
1311 * @return The width of the icon.
1313 public int getIconWidth()
1315 return size;
1319 * Returns the height of the icon, in pixels.
1321 * @return The height of the icon.
1323 public int getIconHeight()
1325 return size;
1329 * Paints the icon at the specified location.
1331 * @param c the component.
1332 * @param g the graphics device.
1333 * @param x the x coordinate.
1334 * @param y the y coordinate.
1336 public void paintIcon(Component c, Graphics g, int x, int y)
1338 Color savedColor = g.getColor();
1340 AbstractButton b = (AbstractButton) c;
1342 // fill the small box interior
1343 if (b.getModel().isPressed())
1344 g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1345 else
1346 g.setColor(MetalLookAndFeel.getPrimaryControl());
1347 g.fillRect(x + 2, y + 6, 7, 7);
1350 if (b.getModel().isPressed())
1351 g.setColor(MetalLookAndFeel.getBlack());
1352 else
1353 g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1355 g.drawLine(x + 12, y + 1, x + 13, y + 1);
1356 g.drawLine(x + 11, y + 2, x + 12, y + 2);
1357 g.drawLine(x + 10, y + 3, x + 11, y + 3);
1358 g.drawLine(x + 8, y + 2, x + 8, y + 3);
1359 g.fillRect(x + 8, y + 4, 3, 3);
1360 g.drawLine(x + 11, y + 6, x + 12, y + 6);
1362 g.drawLine(x + 1, y + 5, x + 5, y + 5);
1363 g.drawLine(x + 1, y + 6, x + 1, y + 12);
1364 g.drawLine(x + 9, y + 9, x + 9, y + 12);
1365 g.drawLine(x + 1, y + 13, x + 9, y + 13);
1367 g.drawLine(x + 2, y + 12, x + 2, y + 12);
1369 g.setColor(MetalLookAndFeel.getBlack());
1370 g.drawLine(x + 12, y, x + 9, y + 3);
1371 g.drawLine(x + 7, y + 1, x + 8, y + 1);
1372 g.drawLine(x + 7, y + 2, x + 7, y + 6);
1373 g.drawLine(x + 11, y + 5, x + 12, y + 5);
1374 g.drawLine(x, y + 4, x + 5, y + 4);
1375 g.drawLine(x, y + 5, x, y + 13);
1376 g.drawLine(x + 3, y + 12, x + 8, y + 12);
1377 g.drawLine(x + 8, y + 8, x + 8, y + 11);
1378 g.drawLine(x + 9, y + 8, x + 9, y + 8);
1380 g.setColor(MetalLookAndFeel.getWhite());
1381 g.drawLine(x + 9, y + 2, x + 9, y + 2);
1382 g.drawLine(x + 11, y + 4, x + 13, y + 2);
1383 g.drawLine(x + 13, y + 6, x + 13, y + 6);
1384 g.drawLine(x + 8, y + 7, x + 13, y + 7);
1385 g.drawLine(x + 6, y + 5, x + 6, y + 5);
1386 g.drawLine(x + 10, y + 8, x + 10, y + 13);
1387 g.drawLine(x + 1, y + 14, x + 10, y + 14);
1389 if (!b.getModel().isPressed())
1391 g.drawLine(x + 2, y + 6, x + 6, y + 6);
1392 g.drawLine(x + 2, y + 6, x + 2, y + 11);
1395 g.setColor(savedColor);
1400 * An icon used for the 'maximize' button in the title frame of a
1401 * {@link JInternalFrame}.
1403 private static class InternalFrameMaximizeIcon implements Icon, Serializable
1407 * Creates a new instance.
1409 public InternalFrameMaximizeIcon()
1411 // Nothing to do here.
1415 * Returns the width of the icon, in pixels.
1417 * @return The width of the icon.
1419 public int getIconWidth()
1421 return 16;
1425 * Returns the height of the icon, in pixels.
1427 * @return The height of the icon.
1429 public int getIconHeight()
1431 return 16;
1435 * Paints the icon at the specified location.
1437 * @param c the component.
1438 * @param g the graphics device.
1439 * @param x the x coordinate.
1440 * @param y the y coordinate.
1442 public void paintIcon(Component c, Graphics g, int x, int y)
1444 Color savedColor = g.getColor();
1446 AbstractButton b = (AbstractButton) c;
1448 // fill the interior
1449 if (b.getModel().isPressed())
1450 g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1451 else
1452 g.setColor(MetalLookAndFeel.getPrimaryControl());
1453 g.fillRect(x + 2, y + 6, 7, 7);
1455 if (b.getModel().isPressed())
1456 g.setColor(MetalLookAndFeel.getBlack());
1457 else
1458 g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1460 g.drawLine(x + 9, y + 1, x + 10, y + 1);
1461 g.fillRect(x + 11, y + 1, 3, 3);
1462 g.fillRect(x + 12, y + 4, 2, 2);
1463 g.drawLine(x + 10, y + 3, x + 10, y + 3);
1464 g.drawLine(x + 9, y + 4, x + 10, y + 4);
1465 g.drawLine(x + 1, y + 5, x + 9, y + 5);
1466 g.drawLine(x + 1, y + 6, x + 1, y + 12);
1467 g.drawLine(x + 9, y + 6, x + 9, y + 12);
1468 g.drawLine(x + 1, y + 13, x + 9, y + 13);
1470 // fill
1471 g.drawLine(x + 7, y + 6, x + 8, y + 6);
1472 g.drawLine(x + 6, y + 7, x + 8, y + 7);
1473 g.drawLine(x + 5, y + 8, x + 6, y + 8);
1474 g.drawLine(x + 4, y + 9, x + 5, y + 9);
1475 g.drawLine(x + 3, y + 10, x + 4, y + 10);
1476 g.drawLine(x + 2, y + 11, x + 3, y + 11);
1477 g.drawLine(x + 2, y + 12, x + 4, y + 12);
1478 g.drawLine(x + 8, y + 8, x + 8, y + 8);
1480 // draw black
1481 g.setColor(MetalLookAndFeel.getBlack());
1482 g.drawLine(x + 8, y, x + 13, y);
1483 g.drawLine(x + 8, y + 1, x + 8, y + 1);
1484 g.drawLine(x + 10, y + 2, x + 9, y + 3);
1485 g.drawLine(x, y + 4, x + 8, y + 4);
1486 g.drawLine(x, y + 5, x, y + 13);
1488 g.drawLine(x + 2, y + 10, x + 6, y + 6);
1489 g.drawLine(x + 8, y + 9, x + 8, y + 11);
1490 g.drawLine(x + 5, y + 12, x + 8, y + 12);
1492 // draw white
1493 g.setColor(MetalLookAndFeel.getWhite());
1494 if (!b.getModel().isPressed())
1496 g.drawLine(x + 2, y + 6, x + 5, y + 6);
1497 g.drawLine(x + 2, y + 7, x + 2, y + 9);
1498 g.drawLine(x + 4, y + 11, x + 7, y + 8);
1501 g.drawLine(x + 1, y + 14, x + 10, y + 14);
1502 g.drawLine(x + 10, y + 5, x + 10, y + 13);
1504 g.drawLine(x + 9, y + 2, x + 9, y + 2);
1505 g.drawLine(x + 11, y + 4, x + 11, y + 5);
1506 g.drawLine(x + 13, y + 6, x + 14, y + 6);
1507 g.drawLine(x + 14, y + 1, x + 14, y + 5);
1508 g.setColor(savedColor);
1513 * An icon used in the title frame of a {@link JInternalFrame}.
1515 private static class InternalFrameMinimizeIcon implements Icon, Serializable
1519 * Creates a new instance.
1521 public InternalFrameMinimizeIcon()
1523 // Nothing to do here.
1527 * Returns the width of the icon, in pixels.
1529 * @return The width of the icon.
1531 public int getIconWidth()
1533 return 16;
1537 * Returns the height of the icon, in pixels.
1539 * @return The height of the icon.
1541 public int getIconHeight()
1543 return 16;
1547 * Paints the icon at the specified location.
1549 * @param c the component.
1550 * @param g the graphics device.
1551 * @param x the x coordinate.
1552 * @param y the y coordinate.
1554 public void paintIcon(Component c, Graphics g, int x, int y)
1556 Color savedColor = g.getColor();
1558 AbstractButton b = (AbstractButton) c;
1560 if (b.getModel().isPressed())
1561 g.setColor(MetalLookAndFeel.getBlack());
1562 else
1563 // FIXME: here the color depends on whether or not the internal frame
1564 // is selected
1565 g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1567 g.drawLine(x + 12, y + 1, x + 13, y + 1);
1568 g.drawLine(x + 11, y + 2, x + 12, y + 2);
1569 g.drawLine(x + 10, y + 3, x + 11, y + 3);
1570 g.drawLine(x + 8, y + 2, x + 8, y + 3);
1571 g.fillRect(x + 8, y + 4, 3, 3);
1572 g.drawLine(x + 11, y + 6, x + 12, y + 6);
1574 g.drawLine(x + 1, y + 8, x + 6, y + 8);
1575 g.drawLine(x + 1, y + 9, x + 1, y + 12);
1576 g.drawLine(x + 6, y + 9, x + 6, y + 12);
1577 g.drawLine(x + 1, y + 13, x + 6, y + 13);
1579 g.drawLine(x + 5, y + 9, x + 5, y + 9);
1580 g.drawLine(x + 2, y + 12, x + 2, y + 12);
1582 g.setColor(MetalLookAndFeel.getBlack());
1583 g.drawLine(x + 12, y, x + 9, y + 3);
1584 g.drawLine(x + 7, y + 1, x + 8, y + 1);
1585 g.drawLine(x + 7, y + 2, x + 7, y + 6);
1586 g.drawLine(x, y + 7, x + 6, y + 7);
1587 g.drawLine(x, y + 8, x, y + 13);
1588 g.drawLine(x + 3, y + 12, x + 5, y + 12);
1589 g.drawLine(x + 5, y + 10, x + 5, y + 11);
1590 g.drawLine(x + 11, y + 5, x + 12, y + 5);
1592 g.setColor(MetalLookAndFeel.getWhite());
1593 g.drawLine(x + 9, y + 2, x + 9, y + 2);
1594 g.drawLine(x + 11, y + 4, x + 13, y + 2);
1595 g.drawLine(x + 13, y + 6, x + 13, y + 6);
1596 g.drawLine(x + 8, y + 7, x + 13, y + 7);
1597 g.drawLine(x + 7, y + 9, x + 7, y + 13);
1598 g.drawLine(x + 1, y + 14, x + 7, y + 14);
1600 if (b.getModel().isPressed())
1602 g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1603 g.fillRect(x + 2, y + 9, 3, 3);
1605 else
1607 g.drawLine(x + 2, y + 9, x + 4, y + 9);
1608 g.drawLine(x + 2, y + 10, x + 2, y + 11);
1611 g.setColor(savedColor);
1616 * The icon used to display the thumb control on a horizontally oriented
1617 * {@link JSlider} component.
1619 private static class VerticalSliderThumbIcon implements Icon, Serializable
1622 * This mask is used to paint the gradient in the shape of the thumb.
1624 int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
1625 {0, 12}, {0, 12}, {0, 12}, {1, 12},
1626 {2, 10}, {3, 9}, {4, 8}, {5, 7},
1627 {6, 6}};
1630 * Creates a new instance.
1632 public VerticalSliderThumbIcon()
1634 // Nothing to do here.
1638 * Returns the width of the icon, in pixels.
1640 * @return The width of the icon.
1642 public int getIconWidth()
1644 return 16;
1648 * Returns the height of the icon, in pixels.
1650 * @return The height of the icon.
1652 public int getIconHeight()
1654 return 15;
1658 * Paints the icon taking into account whether the slider control has the
1659 * focus or not.
1661 * @param c the slider (must be a non-<code>null</code> instance of
1662 * {@link JSlider}.
1663 * @param g the graphics device.
1664 * @param x the x-coordinate.
1665 * @param y the y-coordinate.
1667 public void paintIcon(Component c, Graphics g, int x, int y)
1669 boolean enabled = false;
1670 boolean focus = false;
1671 if (c != null)
1673 enabled = c.isEnabled();
1674 focus = c.hasFocus();
1677 // draw the outline
1678 if (enabled)
1679 g.setColor(MetalLookAndFeel.getBlack());
1680 else
1681 g.setColor(MetalLookAndFeel.getControlDarkShadow());
1682 g.drawLine(x + 1, y, x + 7, y);
1683 g.drawLine(x + 8, y, x + 15, y + 7);
1684 g.drawLine(x + 14, y + 8, x + 8, y + 14);
1685 g.drawLine(x + 8, y + 14, x + 1, y + 14);
1686 g.drawLine(x, y + 13, x, y + 1);
1688 // Fill the icon.
1689 if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
1690 && enabled)
1692 String gradient;
1693 if (focus)
1694 gradient = "Slider.focusGradient";
1695 else
1696 gradient = "Slider.gradient";
1697 MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12,
1698 SwingConstants.HORIZONTAL, gradient,
1699 gradientMask);
1701 else
1703 if (focus)
1704 g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1705 else
1706 g.setColor(MetalLookAndFeel.getControl());
1707 g.fillRect(x + 2, y + 1, 7, 13);
1708 g.drawLine(x + 9, y + 2, x + 9, y + 12);
1709 g.drawLine(x + 10, y + 3, x + 10, y + 11);
1710 g.drawLine(x + 11, y + 4, x + 11, y + 10);
1711 g.drawLine(x + 12, y + 5, x + 12, y + 9);
1712 g.drawLine(x + 13, y + 6, x + 13, y + 8);
1713 g.drawLine(x + 14, y + 7, x + 14, y + 7);
1716 // if the slider is enabled, draw dots and highlights
1717 if (enabled
1718 && ! (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
1720 if (focus)
1721 g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1722 else
1723 g.setColor(MetalLookAndFeel.getBlack());
1724 g.drawLine(x + 3, y + 3, x + 3, y + 3);
1725 g.drawLine(x + 3, y + 7, x + 3, y + 7);
1726 g.drawLine(x + 3, y + 11, x + 3, y + 11);
1728 g.drawLine(x + 5, y + 5, x + 5, y + 5);
1729 g.drawLine(x + 5, y + 9, x + 5, y + 9);
1731 g.drawLine(x + 7, y + 3, x + 7, y + 3);
1732 g.drawLine(x + 7, y + 7, x + 7, y + 7);
1733 g.drawLine(x + 7, y + 11, x + 7, y + 11);
1735 // draw highlights
1736 if (focus)
1737 g.setColor(MetalLookAndFeel.getPrimaryControl());
1738 else
1739 g.setColor(MetalLookAndFeel.getWhite());
1740 g.drawLine(x + 1, y + 1, x + 8, y + 1);
1741 g.drawLine(x + 1, y + 2, x + 1, y + 13);
1742 g.drawLine(x + 2, y + 2, x + 2, y + 2);
1743 g.drawLine(x + 2, y + 6, x + 2, y + 6);
1744 g.drawLine(x + 2, y + 10, x + 2, y + 10);
1746 g.drawLine(x + 4, y + 4, x + 4, y + 4);
1747 g.drawLine(x + 4, y + 8, x + 4, y + 8);
1749 g.drawLine(x + 6, y + 2, x + 6, y + 2);
1750 g.drawLine(x + 6, y + 6, x + 6, y + 6);
1751 g.drawLine(x + 6, y + 10, x + 6, y + 10);
1758 * A tree control icon. This icon can be in one of two states: expanded and
1759 * collapsed.
1761 public static class TreeControlIcon implements Icon, Serializable
1764 /** ???. */
1765 protected boolean isLight;
1767 /** A flag that controls whether or not the icon is collapsed. */
1768 private boolean collapsed;
1771 * Creates a new icon.
1773 * @param isCollapsed a flag that controls whether the icon is in the
1774 * collapsed state or the expanded state.
1776 public TreeControlIcon(boolean isCollapsed)
1778 collapsed = isCollapsed;
1782 * Returns the width of the icon, in pixels.
1784 * @return The width of the icon.
1786 public int getIconWidth()
1788 return 18;
1791 * Returns the height of the icon, in pixels.
1793 * @return The height of the icon.
1795 public int getIconHeight()
1797 return 18;
1801 * Paints the icon at the location (x, y).
1803 * @param c the component.
1804 * @param g the graphics device.
1805 * @param x the x coordinate.
1806 * @param y the y coordinate.
1808 public void paintIcon(Component c, Graphics g, int x, int y)
1810 x = x + 5;
1811 y = y + 5;
1812 if (collapsed)
1814 // TODO: pick up appropriate UI colors
1815 g.setColor(Color.black);
1816 g.drawLine(x + 2, y, x + 5, y);
1817 g.drawLine(x + 6, y + 1, x + 7, y + 2);
1818 g.fillRect(x + 7, y + 3, 5, 2);
1819 g.drawLine(x + 7, y + 5, x + 6, y + 6);
1820 g.drawLine(x + 1, y + 1, x + 1, y + 1);
1821 g.drawLine(x, y + 2, x, y + 5);
1822 g.drawLine(x + 1, y + 6, x + 1, y + 6);
1823 g.drawLine(x + 2, y + 7, x + 5, y + 7);
1824 g.fillRect(x + 3, y + 3, 2, 2);
1826 g.setColor(new Color(204, 204, 255));
1827 g.drawLine(x + 3, y + 2, x + 4, y + 2);
1828 g.drawLine(x + 2, y + 3, x + 2, y + 4);
1829 g.drawLine(x + 3, y + 5, x + 3, y + 5);
1830 g.drawLine(x + 5, y + 3, x + 5, y + 3);
1832 g.setColor(new Color(153, 153, 204));
1833 g.drawLine(x + 2, y + 2, x + 2, y + 2);
1834 g.drawLine(x + 2, y + 5, x + 2, y + 5);
1835 g.drawLine(x + 2, y + 6, x + 5, y + 6);
1836 g.drawLine(x + 5, y + 2, x + 5, y + 2);
1837 g.drawLine(x + 6, y + 2, x + 6, y + 5);
1839 g.setColor(new Color(102, 102, 153));
1840 g.drawLine(x + 2, y + 1, x + 5, y + 1);
1841 g.drawLine(x + 1, y + 2, x + 1, y + 5);
1843 else
1845 // TODO: pick up appropriate UI colors
1846 g.setColor(Color.black);
1847 g.drawLine(x + 2, y, x + 5, y);
1848 g.drawLine(x + 6, y + 1, x + 7, y + 2);
1849 g.drawLine(x + 7, y + 2, x + 7, y + 5);
1850 g.fillRect(x + 3, y + 7, 2, 5);
1851 g.drawLine(x + 7, y + 5, x + 6, y + 6);
1852 g.drawLine(x + 1, y + 1, x + 1, y + 1);
1853 g.drawLine(x, y + 2, x, y + 5);
1854 g.drawLine(x + 1, y + 6, x + 1, y + 6);
1855 g.drawLine(x + 2, y + 7, x + 5, y + 7);
1856 g.fillRect(x + 3, y + 3, 2, 2);
1858 g.setColor(new Color(204, 204, 255));
1859 g.drawLine(x + 3, y + 2, x + 4, y + 2);
1860 g.drawLine(x + 2, y + 3, x + 2, y + 4);
1861 g.drawLine(x + 3, y + 5, x + 3, y + 5);
1862 g.drawLine(x + 5, y + 3, x + 5, y + 3);
1864 g.setColor(new Color(153, 153, 204));
1865 g.drawLine(x + 2, y + 2, x + 2, y + 2);
1866 g.drawLine(x + 2, y + 5, x + 2, y + 5);
1867 g.drawLine(x + 2, y + 6, x + 5, y + 6);
1868 g.drawLine(x + 5, y + 2, x + 5, y + 2);
1869 g.drawLine(x + 6, y + 2, x + 6, y + 5);
1871 g.setColor(new Color(102, 102, 153));
1872 g.drawLine(x + 2, y + 1, x + 5, y + 1);
1873 g.drawLine(x + 1, y + 2, x + 1, y + 5);
1878 * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
1880 * @param c the component.
1881 * @param g the graphics device.
1882 * @param x the x coordinate.
1883 * @param y the y coordinate.
1885 public void paintMe(Component c, Graphics g, int x, int y)
1887 paintIcon(c, g, x, y);
1892 * A tree folder icon.
1894 public static class TreeFolderIcon extends FolderIcon16
1897 * Creates a new instance.
1899 public TreeFolderIcon()
1901 // Nothing to do here.
1905 * Returns the additional height for this icon, in this case <code>2</code>
1906 * pixels.
1908 * @return <code>2</code>.
1910 public int getAdditionalHeight()
1912 return 2;
1916 * Returns the shift (???).
1918 * @return The shift.
1920 public int getShift()
1922 return -1;
1927 * A tree leaf icon.
1929 public static class TreeLeafIcon extends FileIcon16
1932 * Creates a new instance.
1934 public TreeLeafIcon()
1936 // Nothing to do here.
1940 * Returns the additional height for this icon, in this case <code>4</code>
1941 * pixels.
1943 * @return <code>4</code>.
1945 public int getAdditionalHeight()
1947 return 4;
1951 * Returns the shift (???).
1953 * @return The shift.
1955 public int getShift()
1957 return 2;
1962 * An icon representing a hard disk.
1964 * @see MetalIconFactory#getTreeHardDriveIcon()
1966 private static class TreeHardDriveIcon implements Icon, Serializable
1970 * Creates a new icon instance.
1972 public TreeHardDriveIcon()
1974 // Nothing to do here.
1978 * Returns the width of the icon, in pixels.
1980 * @return <code>16</code>.
1982 public int getIconWidth()
1984 return 16;
1988 * Returns the height of the icon, in pixels.
1990 * @return <code>16</code>.
1992 public int getIconHeight()
1994 return 16;
1998 * Paints the icon at the specified location, using colors from the
1999 * current theme.
2001 * @param c the component (ignored).
2002 * @param g the graphics device.
2003 * @param x the x-coordinate for the top-left of the icon.
2004 * @param y the y-coordinate for the top-left of the icon.
2006 public void paintIcon(Component c, Graphics g, int x, int y)
2008 Color saved = g.getColor();
2009 g.setColor(MetalLookAndFeel.getBlack());
2010 g.drawLine(x + 1, y + 4, x + 1, y + 5);
2011 g.drawLine(x + 14, y + 4, x + 14, y + 5);
2012 g.drawLine(x + 1, y + 7, x + 1, y + 8);
2013 g.drawLine(x + 14, y + 7, x + 14, y + 8);
2014 g.drawLine(x + 1, y + 10, x + 1, y + 11);
2015 g.drawLine(x + 14, y + 10, x + 14, y + 11);
2017 g.drawLine(x + 2, y + 3, x + 3, y + 3);
2018 g.drawLine(x + 12, y + 3, x + 13, y + 3);
2019 g.drawLine(x + 2, y + 6, x + 3, y + 6);
2020 g.drawLine(x + 12, y + 6, x + 13, y + 6);
2021 g.drawLine(x + 2, y + 9, x + 3, y + 9);
2022 g.drawLine(x + 12, y + 9, x + 13, y + 9);
2023 g.drawLine(x + 2, y + 12, x + 3, y + 12);
2024 g.drawLine(x + 12, y + 12, x + 13, y + 12);
2026 g.drawLine(x + 4, y + 2, x + 11, y + 2);
2027 g.drawLine(x + 4, y + 7, x + 11, y + 7);
2028 g.drawLine(x + 4, y + 10, x + 11, y + 10);
2029 g.drawLine(x + 4, y + 13, x + 11, y + 13);
2031 g.setColor(MetalLookAndFeel.getWhite());
2032 g.fillRect(x + 4, y + 3, 2, 2);
2033 g.drawLine(x + 6, y + 4, x + 6, y + 4);
2034 g.drawLine(x + 7, y + 3, x + 9, y + 3);
2035 g.drawLine(x + 8, y + 4, x + 8, y + 4);
2036 g.drawLine(x + 11, y + 3, x + 11, y + 3);
2037 g.fillRect(x + 2, y + 4, 2, 2);
2038 g.fillRect(x + 2, y + 7, 2, 2);
2039 g.fillRect(x + 2, y + 10, 2, 2);
2040 g.drawLine(x + 4, y + 6, x + 4, y + 6);
2041 g.drawLine(x + 4, y + 9, x + 4, y + 9);
2042 g.drawLine(x + 4, y + 12, x + 4, y + 12);
2044 g.setColor(MetalLookAndFeel.getControlShadow());
2045 g.drawLine(x + 13, y + 4, x + 13, y + 4);
2046 g.drawLine(x + 12, y + 5, x + 13, y + 5);
2047 g.drawLine(x + 13, y + 7, x + 13, y + 7);
2048 g.drawLine(x + 12, y + 8, x + 13, y + 8);
2049 g.drawLine(x + 13, y + 10, x + 13, y + 10);
2050 g.drawLine(x + 12, y + 11, x + 13, y + 11);
2052 g.drawLine(x + 10, y + 5, x + 10, y + 5);
2053 g.drawLine(x + 7, y + 6, x + 7, y + 6);
2054 g.drawLine(x + 9, y + 6, x + 9, y + 6);
2055 g.drawLine(x + 11, y + 6, x + 11, y + 6);
2057 g.drawLine(x + 10, y + 8, x + 10, y + 8);
2058 g.drawLine(x + 7, y + 9, x + 7, y + 9);
2059 g.drawLine(x + 9, y + 9, x + 9, y + 9);
2060 g.drawLine(x + 11, y + 9, x + 11, y + 9);
2062 g.drawLine(x + 10, y + 11, x + 10, y + 11);
2063 g.drawLine(x + 7, y + 12, x + 7, y + 12);
2064 g.drawLine(x + 9, y + 12, x + 9, y + 12);
2065 g.drawLine(x + 11, y + 12, x + 11, y + 12);
2067 g.setColor(saved);
2072 * An icon representing a floppy disk.
2074 * @see MetalIconFactory#getTreeFloppyDriveIcon()
2076 private static class TreeFloppyDriveIcon implements Icon, Serializable
2080 * Creates a new icon instance.
2082 public TreeFloppyDriveIcon()
2084 // Nothing to do here.
2088 * Returns the width of the icon, in pixels.
2090 * @return <code>16</code>.
2092 public int getIconWidth()
2094 return 16;
2098 * Returns the height of the icon, in pixels.
2100 * @return <code>16</code>.
2102 public int getIconHeight()
2104 return 16;
2108 * Paints the icon at the specified location, using colors from the
2109 * current theme.
2111 * @param c the component (ignored).
2112 * @param g the graphics device.
2113 * @param x the x-coordinate for the top-left of the icon.
2114 * @param y the y-coordinate for the top-left of the icon.
2116 public void paintIcon(Component c, Graphics g, int x, int y)
2118 Color saved = g.getColor();
2120 g.setColor(MetalLookAndFeel.getBlack());
2121 g.drawLine(x + 1, y + 1, x + 13, y + 1);
2122 g.drawLine(x + 1, y + 1, x + 1, y + 14);
2123 g.drawLine(x + 1, y + 14, x + 14, y + 14);
2124 g.drawLine(x + 14, y + 2, x + 14, y + 14);
2126 g.setColor(MetalLookAndFeel.getPrimaryControl());
2127 g.fillRect(x + 2, y + 2, 12, 12);
2129 g.setColor(MetalLookAndFeel.getControlShadow());
2130 g.fillRect(x + 5, y + 2, 6, 5);
2131 g.drawLine(x + 4, y + 8, x + 11, y + 8);
2132 g.drawLine(x + 3, y + 9, x + 3, y + 13);
2133 g.drawLine(x + 12, y + 9, x + 12, y + 13);
2135 g.setColor(MetalLookAndFeel.getWhite());
2136 g.fillRect(x + 8, y + 3, 2, 3);
2137 g.fillRect(x + 4, y + 9, 8, 5);
2139 g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
2140 g.drawLine(x + 5, y + 10, x + 9, y + 10);
2141 g.drawLine(x + 5, y + 12, x + 8, y + 12);
2143 g.setColor(saved);
2148 * An icon representing a computer.
2150 * @see MetalIconFactory#getTreeComputerIcon()
2152 private static class TreeComputerIcon implements Icon, Serializable
2156 * Creates a new icon instance.
2158 public TreeComputerIcon()
2160 // Nothing to do here.
2164 * Returns the width of the icon, in pixels.
2166 * @return <code>16</code>.
2168 public int getIconWidth()
2170 return 16;
2174 * Returns the height of the icon, in pixels.
2176 * @return <code>16</code>.
2178 public int getIconHeight()
2180 return 16;
2184 * Paints the icon at the specified location, using colors from the
2185 * current theme.
2187 * @param c the component (ignored).
2188 * @param g the graphics device.
2189 * @param x the x-coordinate for the top-left of the icon.
2190 * @param y the y-coordinate for the top-left of the icon.
2192 public void paintIcon(Component c, Graphics g, int x, int y)
2194 Color saved = g.getColor();
2196 g.setColor(MetalLookAndFeel.getBlack());
2197 g.drawLine(x + 3, y + 1, x + 12, y + 1);
2198 g.drawLine(x + 2, y + 2, x + 2, y + 8);
2199 g.drawLine(x + 13, y + 2, x + 13, y + 8);
2200 g.drawLine(x + 3, y + 9, x + 3, y + 9);
2201 g.drawLine(x + 12, y + 9, x + 12, y + 9);
2202 g.drawRect(x + 1, y + 10, 13, 4);
2203 g.drawLine(x + 5, y + 3, x + 10, y + 3);
2204 g.drawLine(x + 5, y + 8, x + 10, y + 8);
2205 g.drawLine(x + 4, y + 4, x + 4, y + 7);
2206 g.drawLine(x + 11, y + 4, x + 11, y + 7);
2208 g.setColor(MetalLookAndFeel.getPrimaryControl());
2209 g.fillRect(x + 5, y + 4, 6, 4);
2211 g.setColor(MetalLookAndFeel.getControlShadow());
2212 g.drawLine(x + 6, y + 12, x + 8, y + 12);
2213 g.drawLine(x + 10, y + 12, x + 12, y + 12);
2214 g.setColor(saved);
2218 /** The icon returned by {@link #getCheckBoxIcon()}. */
2219 private static Icon checkBoxIcon;
2221 /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
2222 private static Icon checkBoxMenuItemIcon;
2224 /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
2225 private static Icon fileChooserDetailViewIcon;
2227 /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
2228 private static Icon fileChooserHomeFolderIcon;
2230 /** The icon returned by {@link #getFileChooserListViewIcon()}. */
2231 private static Icon fileChooserListViewIcon;
2233 /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
2234 private static Icon fileChooserNewFolderIcon;
2236 /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
2237 private static Icon fileChooserUpFolderIcon;
2239 /** The cached RadioButtonIcon instance. */
2240 private static RadioButtonIcon radioButtonIcon;
2242 /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
2243 private static Icon radioButtonMenuItemIcon;
2245 /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
2246 private static Icon internalFrameDefaultMenuIcon;
2248 /** The icon returned by {@link #getTreeComputerIcon()}. */
2249 private static Icon treeComputerIcon;
2251 /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
2252 private static Icon treeFloppyDriveIcon;
2254 /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
2255 private static Icon treeHardDriveIcon;
2258 * Creates a new instance. All the methods are static, so creating an
2259 * instance isn't necessary.
2261 public MetalIconFactory()
2263 // Nothing to do here.
2267 * Returns an icon for use when rendering the {@link JCheckBox} component.
2269 * @return A check box icon.
2271 * @since 1.3
2273 public static Icon getCheckBoxIcon()
2275 if (checkBoxIcon == null)
2276 checkBoxIcon = new MetalCheckBoxIcon();
2277 return checkBoxIcon;
2281 * Returns an icon for use when rendering the {@link JCheckBoxMenuItem}
2282 * component.
2284 * @return An icon.
2286 public static Icon getCheckBoxMenuItemIcon()
2288 if (checkBoxMenuItemIcon == null)
2289 checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
2290 return checkBoxMenuItemIcon;
2294 * Returns an icon for use by the {@link JFileChooser} component.
2296 * @return An icon.
2298 public static Icon getFileChooserDetailViewIcon()
2300 if (fileChooserDetailViewIcon == null)
2301 fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
2302 return fileChooserDetailViewIcon;
2306 * Returns an icon for use by the {@link JFileChooser} component.
2308 * @return An icon.
2310 public static Icon getFileChooserHomeFolderIcon()
2312 if (fileChooserHomeFolderIcon == null)
2313 fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
2314 return fileChooserHomeFolderIcon;
2318 * Returns an icon for use by the {@link JFileChooser} component.
2320 * @return An icon.
2322 public static Icon getFileChooserListViewIcon()
2324 if (fileChooserListViewIcon == null)
2325 fileChooserListViewIcon = new FileChooserListViewIcon();
2326 return fileChooserListViewIcon;
2330 * Returns an icon for use by the {@link JFileChooser} component.
2332 * @return An icon.
2334 public static Icon getFileChooserNewFolderIcon()
2336 if (fileChooserNewFolderIcon == null)
2337 fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
2338 return fileChooserNewFolderIcon;
2342 * Returns an icon for use by the {@link JFileChooser} component.
2344 * @return An icon.
2346 public static Icon getFileChooserUpFolderIcon()
2348 if (fileChooserUpFolderIcon == null)
2349 fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
2350 return fileChooserUpFolderIcon;
2354 * Returns an icon for RadioButtons in the Metal L&amp;F.
2356 * @return an icon for RadioButtons in the Metal L&amp;F
2358 public static Icon getRadioButtonIcon()
2360 if (radioButtonIcon == null)
2361 radioButtonIcon = new RadioButtonIcon();
2362 return radioButtonIcon;
2366 * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
2368 * @return A new icon instance.
2370 public static Icon getRadioButtonMenuItemIcon()
2372 if (radioButtonMenuItemIcon == null)
2373 radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
2374 return radioButtonMenuItemIcon;
2378 * Returns the icon used to display the thumb for a horizontally oriented
2379 * {@link JSlider}.
2381 * @return The icon.
2383 public static Icon getHorizontalSliderThumbIcon()
2385 return new HorizontalSliderThumbIcon();
2389 * Creates a new icon used to represent the 'close' button in the title
2390 * pane of a {@link JInternalFrame}.
2392 * @param size the icon size.
2394 * @return A close icon.
2396 public static Icon getInternalFrameCloseIcon(int size)
2398 return new InternalFrameCloseIcon(size);
2402 * Creates a new icon for the menu in a {@link JInternalFrame}. This is the
2403 * icon displayed at the top left of the frame.
2405 * @return A menu icon.
2407 public static Icon getInternalFrameDefaultMenuIcon()
2409 if (internalFrameDefaultMenuIcon == null)
2410 internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
2411 return internalFrameDefaultMenuIcon;
2415 * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
2417 * @param size the icon size in pixels.
2419 * @return The icon.
2421 * @see #getInternalFrameAltMaximizeIcon(int)
2423 public static Icon getInternalFrameMaximizeIcon(int size)
2425 return new InternalFrameMaximizeIcon();
2429 * Returns the icon used for the minimize button in the frame title for a
2430 * {@link JInternalFrame}.
2432 * @param size the icon size in pixels (ignored by this implementation).
2434 * @return The icon.
2436 public static Icon getInternalFrameMinimizeIcon(int size)
2438 return new InternalFrameMinimizeIcon();
2442 * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
2443 * that has been maximised.
2445 * @param size the icon size in pixels.
2447 * @return The icon.
2449 * @see #getInternalFrameMaximizeIcon(int)
2451 public static Icon getInternalFrameAltMaximizeIcon(int size)
2453 return new InternalFrameAltMaximizeIcon(size);
2457 * Returns the icon used to display the thumb for a vertically oriented
2458 * {@link JSlider}.
2460 * @return The icon.
2462 public static Icon getVerticalSliderThumbIcon()
2464 return new VerticalSliderThumbIcon();
2468 * Creates and returns a new tree folder icon.
2470 * @return A new tree folder icon.
2472 public static Icon getTreeFolderIcon()
2474 return new TreeFolderIcon();
2478 * Creates and returns a new tree leaf icon.
2480 * @return A new tree leaf icon.
2482 public static Icon getTreeLeafIcon()
2484 return new TreeLeafIcon();
2488 * Creates and returns a tree control icon.
2490 * @param isCollapsed a flag that controls whether the icon is in the
2491 * collapsed or expanded state.
2493 * @return A tree control icon.
2495 public static Icon getTreeControlIcon(boolean isCollapsed)
2497 return new TreeControlIcon(isCollapsed);
2501 * Returns a <code>16x16</code> icon representing a computer.
2503 * @return The icon.
2505 public static Icon getTreeComputerIcon()
2507 if (treeComputerIcon == null)
2508 treeComputerIcon = new TreeComputerIcon();
2509 return treeComputerIcon;
2513 * Returns a <code>16x16</code> icon representing a floppy disk.
2515 * @return The icon.
2517 public static Icon getTreeFloppyDriveIcon()
2519 if (treeFloppyDriveIcon == null)
2520 treeFloppyDriveIcon = new TreeFloppyDriveIcon();
2521 return treeFloppyDriveIcon;
2525 * Returns a <code>16x16</code> icon representing a hard disk.
2527 * @return The icon.
2529 public static Icon getTreeHardDriveIcon()
2531 if (treeHardDriveIcon == null)
2532 treeHardDriveIcon = new TreeHardDriveIcon();
2533 return treeHardDriveIcon;
2537 * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2538 * points to the right. This is displayed in menu items that have a
2539 * sub menu.
2541 * @return The icon.
2543 public static Icon getMenuArrowIcon()
2545 if (menuArrow == null)
2546 menuArrow = new Icon()
2548 public int getIconHeight()
2550 return 8;
2553 public int getIconWidth()
2555 return 4;
2558 public void paintIcon(Component c, Graphics g, int x, int y)
2560 Color saved = g.getColor();
2561 g.setColor(Color.BLACK);
2562 for (int i = 0; i < 4; i++)
2563 g.drawLine(x + i, y + i, x + i, y + 7 - i);
2564 g.setColor(saved);
2567 return menuArrow;
2571 * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2572 * points to the right. This is displayed in menu items that have a sub menu.
2574 * @return The icon.
2576 public static Icon getMenuItemArrowIcon()
2578 if (menuItemArrow == null)
2579 menuItemArrow = new Icon()
2581 public int getIconHeight()
2583 return 8;
2586 public int getIconWidth()
2588 return 4;
2591 public void paintIcon(Component c, Graphics g, int x, int y)
2593 Color saved = g.getColor();
2594 g.setColor(Color.BLACK);
2595 for (int i = 0; i < 4; i++)
2596 g.drawLine(x + i, y + i, x + i, y + 7 - i);
2597 g.setColor(saved);
2600 return menuItemArrow;
2604 * Returns a new instance of a 13 x 13 icon showing a small black check mark.
2606 * @return The icon.
2608 public static Icon getMenuItemCheckIcon()
2610 return new Icon()
2612 public int getIconHeight()
2614 return 13;
2617 public int getIconWidth()
2619 return 13;
2622 public void paintIcon(Component c, Graphics g, int x, int y)
2624 Color saved = g.getColor();
2625 g.setColor(Color.BLACK);
2626 g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
2627 g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
2628 g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
2629 g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
2630 g.setColor(saved);