Source for javax.swing.plaf.metal.MetalIconFactory

   1: /* MetalIconFactory.java --
   2:    Copyright (C) 2005 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   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.
  10: 
  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.
  15: 
  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.
  20: 
  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.
  25: 
  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. */
  37: 
  38: 
  39: package javax.swing.plaf.metal;
  40: 
  41: import java.awt.Color;
  42: import java.awt.Component;
  43: import java.awt.Graphics;
  44: import java.io.Serializable;
  45: 
  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;
  58: 
  59: 
  60: /**
  61:  * Creates icons for the {@link MetalLookAndFeel}.
  62:  */
  63: public class MetalIconFactory implements Serializable 
  64: {
  65: 
  66:   /** A constant representing "dark". */
  67:   public static final boolean DARK = false;
  68:     
  69:   /** A constant representing "light". */
  70:   public static final boolean LIGHT = true;
  71:   
  72:   /** A shared instance of the MenuArrowIcon. */
  73:   private static Icon menuArrow;
  74:   
  75:   /** A shared instance of the MenuItemArrowIcon. */
  76:   private static Icon menuItemArrow;
  77:     
  78:   /**
  79:    * An icon displayed for {@link JCheckBoxMenuItem} components.
  80:    */
  81:   private static class CheckBoxMenuItemIcon implements Icon, Serializable 
  82:   {
  83:     /**
  84:      * Creates a new icon instance.
  85:      */
  86:     public CheckBoxMenuItemIcon() 
  87:     {
  88:       // Nothing to do here.
  89:     }
  90:       
  91:     /**
  92:      * Returns the width of the icon, in pixels.
  93:      * 
  94:      * @return The width of the icon (10 pixels).
  95:      */
  96:     public int getIconWidth() 
  97:     {
  98:       return 10;
  99:     }
 100:     
 101:     /**
 102:      * Returns the height of the icon, in pixels.
 103:      * 
 104:      * @return The height of the icon (10 pixels).
 105:      */
 106:     public int getIconHeight() 
 107:     {
 108:       return 10;
 109:     }
 110:     
 111:     /**
 112:      * Paints the icon.
 113:      * 
 114:      * @param c  the component.
 115:      * @param g  the graphics device.
 116:      * @param x  the x-coordinate.
 117:      * @param y  the y-coordinate.
 118:      */
 119:     public void paintIcon(Component c, Graphics g, int x, int y) 
 120:     {
 121:       JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;
 122:         
 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);
 131:       
 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);
 137: 
 138:       // if the item is selected, we should draw a tick
 139:       if (item.isSelected())
 140:       {
 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);
 145:       }
 146: 
 147:     }        
 148:   }
 149: 
 150:   /**
 151:    * An icon used for the "detail view" button on a {@link JFileChooser} under
 152:    * the {@link MetalLookAndFeel}.
 153:    * 
 154:    * @see MetalIconFactory#getFileChooserDetailViewIcon()
 155:    */
 156:   private static class FileChooserDetailViewIcon implements Icon, Serializable
 157:   {
 158: 
 159:     /**
 160:      * Creates a new icon.
 161:      */
 162:     public FileChooserDetailViewIcon() 
 163:     {
 164:       // Nothing to do here.
 165:     }
 166:       
 167:     /**
 168:      * Returns the width of the icon, in pixels.
 169:      * 
 170:      * @return The width of the icon.
 171:      */
 172:     public int getIconWidth() 
 173:     {
 174:       return 18;
 175:     }
 176:     
 177:     /**
 178:      * Returns the height of the icon, in pixels.
 179:      * 
 180:      * @return The height of the icon.
 181:      */
 182:     public int getIconHeight() 
 183:     {
 184:       return 18;
 185:     }
 186:     
 187:     /**
 188:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 189:      * 
 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.
 194:      */
 195:     public void paintIcon(Component c, Graphics g, int x, int y) 
 196:     {
 197:       Color savedColor = g.getColor();
 198:       g.setColor(MetalLookAndFeel.getBlack());
 199: 
 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);
 205:       
 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);
 211: 
 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);
 215:       
 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);
 220:       
 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);
 225:       
 226:       g.setColor(savedColor);
 227:     }        
 228:   }
 229: 
 230:   /**
 231:    * An icon used for the "home folder" button on a {@link JFileChooser} under
 232:    * the {@link MetalLookAndFeel}.
 233:    * 
 234:    * @see MetalIconFactory#getFileChooserHomeFolderIcon()
 235:    */
 236:   private static class FileChooserHomeFolderIcon implements Icon, Serializable
 237:   {
 238: 
 239:     /**
 240:      * Creates a new icon.
 241:      */
 242:     public FileChooserHomeFolderIcon() 
 243:     {
 244:       // Nothing to do here.
 245:     }
 246: 
 247:     /**
 248:      * Returns the width of the icon, in pixels.
 249:      * 
 250:      * @return The width of the icon.
 251:      */
 252:     public int getIconWidth() 
 253:     {
 254:       return 18;
 255:     }
 256:     
 257:     /**
 258:      * Returns the height of the icon, in pixels.
 259:      * 
 260:      * @return The height of the icon.
 261:      */
 262:     public int getIconHeight() 
 263:     {
 264:       return 18;
 265:     }
 266:     
 267:     /**
 268:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 269:      * 
 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.
 274:      */
 275:     public void paintIcon(Component c, Graphics g, int x, int y) 
 276:     {   
 277:       Color savedColor = g.getColor();
 278:       g.setColor(MetalLookAndFeel.getBlack());
 279:       
 280:       // roof
 281:       g.drawLine(x + 1, y + 8, x + 8, y + 1);
 282:       g.drawLine(x + 8, y + 1, x + 15, y + 8);
 283:       
 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);
 288:       
 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);
 293:       
 294:       // chimney
 295:       g.drawLine(x + 11, y + 2, x + 11, y + 4);
 296:       g.drawLine(x + 12, y + 2, x + 12, y + 5);
 297:       
 298:       g.setColor(MetalLookAndFeel.getControlDarkShadow());
 299:       
 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);
 305:       
 306:       // door knob
 307:       g.drawLine(x + 9, y + 12, x + 9, y + 12);
 308:       
 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);
 314:       
 315:       g.setColor(savedColor);
 316:     }        
 317:   }
 318:     
 319:   /**
 320:    * An icon used for the "list view" button on a {@link JFileChooser} under
 321:    * the {@link MetalLookAndFeel}.
 322:    * 
 323:    * @see MetalIconFactory#getFileChooserListViewIcon()
 324:    */
 325:   private static class FileChooserListViewIcon implements Icon, Serializable 
 326:   {
 327:     /**
 328:      * Creates a new icon.
 329:      */
 330:     public FileChooserListViewIcon() 
 331:     {
 332:       // Nothing to do here.
 333:     }
 334:     
 335:     /**
 336:      * Returns the width of the icon, in pixels.
 337:      * 
 338:      * @return The width of the icon.
 339:      */
 340:     public int getIconWidth() 
 341:     {
 342:       return 18;
 343:     }
 344:     
 345:     /**
 346:      * Returns the height of the icon, in pixels.
 347:      * 
 348:      * @return The height of the icon.
 349:      */
 350:     public int getIconHeight() 
 351:     {
 352:       return 18;
 353:     }
 354:     
 355:     /**
 356:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 357:      * 
 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.
 362:      */
 363:     public void paintIcon(Component c, Graphics g, int x, int y) 
 364:     {
 365:       Color savedColor = g.getColor();
 366:       g.setColor(MetalLookAndFeel.getBlack());
 367: 
 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);
 373:       
 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);
 379:       
 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);
 385:       
 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);
 391:       
 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);
 396:       
 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);
 403:       
 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);
 410: 
 411:       g.setColor(savedColor);
 412:     }        
 413:   }
 414:     
 415:   /**
 416:    * An icon used for the "new folder" button on a {@link JFileChooser} under
 417:    * the {@link MetalLookAndFeel}.
 418:    * 
 419:    * @see MetalIconFactory#getFileChooserNewFolderIcon()
 420:    */
 421:   private static class FileChooserNewFolderIcon  implements Icon, Serializable
 422:   {
 423:     /** 
 424:      * Creates a new icon.
 425:      */
 426:     public FileChooserNewFolderIcon() 
 427:     {
 428:       // Nothing to do here.
 429:     }
 430:     
 431:     /**
 432:      * Returns the width of the icon, in pixels.
 433:      * 
 434:      * @return The width of the icon.
 435:      */
 436:     public int getIconWidth() 
 437:     {
 438:       return 18;
 439:     }
 440:     
 441:     /**
 442:      * Returns the height of the icon, in pixels.
 443:      * 
 444:      * @return The height of the icon.
 445:      */
 446:     public int getIconHeight() 
 447:     {
 448:       return 18;
 449:     }
 450:     
 451:     /**
 452:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 453:      * 
 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.
 458:      */
 459:     public void paintIcon(Component c, Graphics g, int x, int y) 
 460:     {      
 461:       Color savedColor = g.getColor();
 462:       g.setColor(MetalLookAndFeel.getBlack());
 463:       
 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);
 469:       
 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);
 473:       
 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);
 478:       
 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);
 484:     }        
 485:   }
 486: 
 487:   /**
 488:    * An icon used for the "up folder" button on a {@link JFileChooser} under
 489:    * the {@link MetalLookAndFeel}.
 490:    * 
 491:    * @see MetalIconFactory#getFileChooserNewFolderIcon()
 492:    */
 493:   private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon
 494:     implements Icon, Serializable 
 495:   {
 496:     /**
 497:      * Creates a new icon.
 498:      */
 499:     public FileChooserUpFolderIcon() 
 500:     {
 501:       // Nothing to do here.
 502:     }
 503:     
 504:     /**
 505:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 506:      * 
 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.
 511:      */
 512:     public void paintIcon(Component c, Graphics g, int x, int y) 
 513:     {
 514:       Color savedColor = g.getColor();
 515: 
 516:       // draw the folder
 517:       super.paintIcon(c, g, x, y);
 518:       
 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);
 526:     }        
 527:   }
 528: 
 529:   /**
 530:    * An icon representing a file (drawn as a piece of paper with the top-right
 531:    * corner turned down).
 532:    */
 533:   public static class FileIcon16 implements Icon, Serializable 
 534:   {
 535:     /**
 536:      * Returns the width of the icon, in pixels.
 537:      * 
 538:      * @return The width of the icon.
 539:      */
 540:     public int getIconWidth() 
 541:     {
 542:       return 16;
 543:     }
 544: 
 545:     /**
 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()}.
 549:      * 
 550:      * @return The height of the icon.
 551:      */
 552:     public int getIconHeight() 
 553:     {
 554:       return 16 + getAdditionalHeight();
 555:     }
 556:     
 557:     /**
 558:      * Paints the icon at the location (x, y).
 559:      * 
 560:      * @param c  the component.
 561:      * @param g  the graphics context.
 562:      * @param x  the x coordinate.
 563:      * @param y  the y coordinate.
 564:      */
 565:     public void paintIcon(Component c, Graphics g, int x, int y) 
 566:     {
 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);           
 574: 
 575:       g.drawLine(x + 7, y + 2, x + 11, y + 6);
 576:       g.drawLine(x + 8, y + 1, x + 9, y + 1);
 577: 
 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);
 584:     }
 585:     
 586:     /**
 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.
 590:      * 
 591:      * @return The additional height (<code>0</code> unless overridden).
 592:      */
 593:     public int getAdditionalHeight() 
 594:     {
 595:       return 0;
 596:     }
 597:         
 598:     /**
 599:      * Returns the shift (???).
 600:      * 
 601:      * @return The shift.
 602:      */
 603:     public int getShift() 
 604:     {
 605:       return 0;
 606:     }
 607:         
 608:   }
 609:     
 610:   /**
 611:    * An icon representing a folder.
 612:    */
 613:   public static class FolderIcon16 implements Icon, Serializable 
 614:   {
 615:     /**
 616:      * Returns the width of the icon, in pixels.
 617:      * 
 618:      * @return The width of the icon.
 619:      */
 620:     public int getIconWidth() {
 621:       return 16;
 622:     }
 623:     
 624:     /**
 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()}.
 628:      * 
 629:      * @return The height of the icon.
 630:      */
 631:     public int getIconHeight() 
 632:     {
 633:       return 16 + getAdditionalHeight();
 634:     }
 635: 
 636:     /**
 637:      * Paints the icon at the location (x, y).
 638:      * 
 639:      * @param c  the component.
 640:      * @param g  the graphics device.
 641:      * @param x  the x coordinate.
 642:      * @param y  the y coordinate.
 643:      */
 644:     public void paintIcon(Component c, Graphics g, int x, int y) 
 645:     {
 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);
 661:     }
 662:     
 663:     /**
 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.
 667:      * 
 668:      * @return The additional height (<code>0</code> unless overridden).
 669:      */
 670:     public int getAdditionalHeight() 
 671:     {
 672:       return 0;
 673:     }
 674:     
 675:     /**
 676:      * Returns the shift (???).
 677:      * 
 678:      * @return The shift.
 679:      */
 680:     public int getShift() 
 681:     {
 682:       return 0;
 683:     }
 684:         
 685:   }
 686: 
 687:   /**
 688:    * An icon used by the {@link MetalInternalFrameUI} class when the frame
 689:    * is displayed as a palette.
 690:    * 
 691:    * @since 1.3
 692:    */
 693:   public static class PaletteCloseIcon
 694:     implements Icon, Serializable, UIResource
 695:   {
 696:     /**
 697:      * Returns the width of the icon, in pixels.
 698:      * 
 699:      * @return The width of the icon.
 700:      */
 701:     public int getIconWidth() 
 702:     {
 703:       return 7;
 704:     }
 705:     
 706:     /**
 707:      * Returns the height of the icon, in pixels.
 708:      * 
 709:      * @return The height of the icon.
 710:      */
 711:     public int getIconHeight() 
 712:     {
 713:       return 7;
 714:     }
 715:     
 716:     /**
 717:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 718:      * 
 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.
 723:      */
 724:     public void paintIcon(Component c, Graphics g, int x, int y) 
 725:     {
 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);
 746:     }        
 747:   }
 748:   
 749:   /**
 750:    * An {@link Icon} implementation for {@link JCheckBox}es in the
 751:    * Metal Look &amp; Feel.
 752:    *
 753:    * @author Roman Kennke (roman@kennke.org)
 754:    */
 755:   static class RadioButtonIcon implements Icon, UIResource, Serializable
 756:   {
 757: 
 758:     /**
 759:      * Returns the width of the icon in pixels.
 760:      *
 761:      * @return the width of the icon in pixels
 762:      */
 763:     public int getIconWidth()
 764:     {
 765:       return 13;
 766:     }
 767: 
 768:     /**
 769:      * Returns the height of the icon in pixels.
 770:      *
 771:      * @return the height of the icon in pixels
 772:      */
 773:     public int getIconHeight()
 774:     {
 775:       return 13;
 776:     }
 777: 
 778:     /**
 779:      * Paints the icon, taking into account whether or not the component is
 780:      * enabled, selected and/or armed.
 781:      *
 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
 787:      */
 788:     public void paintIcon(Component c, Graphics g, int x, int y) 
 789:     {
 790:       if (UIManager.get("RadioButton.gradient") != null)
 791:         MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
 792:                               SwingConstants.VERTICAL, "RadioButton.gradient");
 793: 
 794:       Color savedColor = g.getColor();
 795:       JRadioButton b = (JRadioButton) c;
 796:       
 797:       // draw outer circle
 798:       if (b.isEnabled())
 799:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
 800:       else
 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);
 814: 
 815:       if (b.getModel().isArmed())
 816:         {
 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);
 823:         }
 824:       else 
 825:         {
 826:           // only draw inner highlight if not filled
 827:           if (b.isEnabled())
 828:             {
 829:               g.setColor(MetalLookAndFeel.getWhite());
 830:           
 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);
 837:             }
 838:         }
 839: 
 840:       // draw outer highlight
 841:       if (b.isEnabled())
 842:         {
 843:           g.setColor(MetalLookAndFeel.getWhite());
 844:           
 845:           // outer
 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);
 854:         }
 855:       
 856:       if (b.isSelected())
 857:         {
 858:           if (b.isEnabled())
 859:             g.setColor(MetalLookAndFeel.getBlack());
 860:           else
 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);
 865:         }
 866:       g.setColor(savedColor);
 867:     }        
 868:   }
 869: 
 870:   /**
 871:    * An icon displayed for {@link JRadioButtonMenuItem} components.
 872:    */
 873:   private static class RadioButtonMenuItemIcon implements Icon, Serializable 
 874:   {
 875:     /**
 876:      * Creates a new icon instance.
 877:      */
 878:     public RadioButtonMenuItemIcon() 
 879:     {
 880:       // Nothing to do here.
 881:     }
 882: 
 883:     /**
 884:      * Returns the width of the icon, in pixels.
 885:      * 
 886:      * @return The width of the icon.
 887:      */
 888:     public int getIconWidth() 
 889:     {
 890:       return 10;
 891:     }
 892: 
 893:     /**
 894:      * Returns the height of the icon, in pixels.
 895:      * 
 896:      * @return The height of the icon.
 897:      */
 898:     public int getIconHeight()   
 899:     {
 900:       return 10;
 901:     }
 902: 
 903:     /**
 904:      * Paints the icon.
 905:      * 
 906:      * @param c  the component.
 907:      * @param g  the graphics device.
 908:      * @param x  the x-coordinate.
 909:      * @param y  the y-coordinate.
 910:      */
 911:     public void paintIcon(Component c, Graphics g, int x, int y) 
 912:     {
 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);
 924:       
 925:       if (item.isSelected())
 926:         {
 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);
 930:         }
 931: 
 932:       // highlight
 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);
 943:     }        
 944:   }
 945: 
 946:   /**
 947:    * The icon used to display the thumb control on a horizontally oriented
 948:    * {@link JSlider} component.
 949:    */
 950:   private static class HorizontalSliderThumbIcon  implements Icon, Serializable
 951:   {
 952: 
 953:     /**
 954:      * Creates a new instance.
 955:      */
 956:     public HorizontalSliderThumbIcon() 
 957:     {
 958:       // Nothing to do here.
 959:     }
 960:     
 961:     /**
 962:      * Returns the width of the icon, in pixels.
 963:      * 
 964:      * @return The width of the icon.
 965:      */
 966:     public int getIconWidth() 
 967:     {
 968:       return 15;
 969:     }
 970:     
 971:     /**
 972:      * Returns the height of the icon, in pixels.
 973:      * 
 974:      * @return The height of the icon.
 975:      */
 976:     public int getIconHeight() 
 977:     {
 978:       return 16;
 979:     }
 980:     
 981:     /**
 982:      * Paints the icon, taking into account whether or not the component has 
 983:      * the focus.
 984:      * 
 985:      * @param c  the component.
 986:      * @param g  the graphics device.
 987:      * @param x  the x-coordinate.
 988:      * @param y  the y-coordinate.
 989:      */
 990:     public void paintIcon(Component c, Graphics g, int x, int y) 
 991:     {
 992:       boolean enabled = false;
 993:       boolean focus = false;
 994:       if (c != null)
 995:         {
 996:           enabled = c.isEnabled();
 997:           focus = c.hasFocus();    
 998:         }
 999:       
1000:       // draw the outline
1001:       if (enabled) 
1002:         g.setColor(MetalLookAndFeel.getBlack());
1003:       else
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);
1010:       
1011:       // fill the icon
1012:       if (focus)
1013:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1014:       else
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);
1023:       
1024:       // if the slider is enabled, draw dots and highlights
1025:       if (c.isEnabled())
1026:         {
1027:           if (focus)
1028:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1029:           else
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);
1034: 
1035:           g.drawLine(x + 5, y + 5, x + 5, y + 5);
1036:           g.drawLine(x + 9, y + 5, x + 9, y + 5);
1037: 
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);
1041: 
1042:           // draw highlights
1043:           if (focus)
1044:             g.setColor(MetalLookAndFeel.getPrimaryControl());
1045:           else
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);
1052:           
1053:           g.drawLine(x + 4, y + 4, x + 4, y + 4);
1054:           g.drawLine(x + 8, y + 4, x + 8, y + 4);
1055: 
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);
1059:         }
1060: 
1061:     }        
1062:   }
1063:   
1064:   /**
1065:    * An icon used for the 'close' button in the title frame of a 
1066:    * {@link JInternalFrame}.
1067:    */
1068:   private static class InternalFrameCloseIcon implements Icon, Serializable
1069:   {
1070:     /** The icon size in pixels. */
1071:     private int size;
1072:     
1073:     /**
1074:      * Creates a new icon.
1075:      * 
1076:      * @param size  the icon size (width and height) in pixels.
1077:      */
1078:     public InternalFrameCloseIcon(int size) 
1079:     {
1080:       this.size = size;
1081:     }
1082:     
1083:     /**
1084:      * Returns the width of the icon, in pixels.
1085:      * 
1086:      * @return The width of the icon.
1087:      */
1088:     public int getIconWidth() 
1089:     {
1090:       return size;
1091:     }
1092:     
1093:     /**
1094:      * Returns the height of the icon, in pixels.
1095:      * 
1096:      * @return The height of the icon.
1097:      */
1098:     public int getIconHeight() 
1099:     {
1100:       return size;
1101:     }
1102:     
1103:     /**
1104:      * Paints the icon.
1105:      * 
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.
1110:      */
1111:     public void paintIcon(Component c, Graphics g, int x, int y) 
1112:     {
1113:       Color savedColor = g.getColor();
1114:       AbstractButton b = (AbstractButton) c;
1115:       
1116:       // fill the interior
1117:       if (b.getModel().isPressed())
1118:         // FIXME: also need to take into account whether the internal frame is
1119:         // selected
1120:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1121:       else
1122:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1123:       g.fillRect(x + 2, y + 2, 10, 10);
1124:       
1125:       // draw the outline box and the cross
1126:       if (b.getModel().isPressed())
1127:         g.setColor(MetalLookAndFeel.getBlack());
1128:       else
1129:         {
1130:           // FIXME: also need to take into account whether the internal frame is
1131:           // selected
1132:           boolean selected = true;
1133:           if (selected)
1134:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1135:           else
1136:             g.setColor(MetalLookAndFeel.getControlDarkShadow());
1137:         }
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);
1144:       
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);
1153:       
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);
1160:       
1161:       g.drawLine(x + 12, y + 3, x + 12, y + 11);
1162:       g.drawLine(x + 3, y + 12, x + 12, y + 12);
1163:       
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);
1167:       
1168:       if (!b.getModel().isPressed())
1169:         {
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);
1176:         }
1177:       g.setColor(savedColor);
1178:     }        
1179:   }
1180: 
1181:   /**
1182:    * The icon displayed at the top-left corner of a {@link JInternalFrame}.
1183:    */
1184:   private static class InternalFrameDefaultMenuIcon
1185:     implements Icon, Serializable 
1186:   {
1187:        
1188:     /**
1189:      * Creates a new instance.
1190:      */
1191:     public InternalFrameDefaultMenuIcon() 
1192:     {
1193:       // Nothing to do here.
1194:     }
1195:     
1196:     /**
1197:      * Returns the width of the icon, in pixels.
1198:      * 
1199:      * @return The width of the icon.
1200:      */
1201:     public int getIconWidth() 
1202:     {
1203:       return 16;
1204:     }
1205:     
1206:     /**
1207:      * Returns the height of the icon, in pixels.
1208:      * 
1209:      * @return The height of the icon.
1210:      */
1211:     public int getIconHeight() 
1212:     {
1213:       return 16;
1214:     }
1215:     
1216:     /**
1217:      * Paints the icon at the specified location.
1218:      * 
1219:      * @param c  the component.
1220:      * @param g  the graphics device.
1221:      * @param x  the x coordinate.
1222:      * @param y  the y coordinate.
1223:      */
1224:     public void paintIcon(Component c, Graphics g, int x, int y) 
1225:     {
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);
1232:       
1233:       g.setColor(new Color(204, 204, 255));
1234:       g.fillRect(x + 2, y + 2, 12, 3);
1235:       
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);
1241: 
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);
1248:     }        
1249:   }
1250: 
1251:   /**
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.
1255:    */
1256:   private static class InternalFrameAltMaximizeIcon
1257:     implements Icon, Serializable 
1258:   {
1259:     /** The icon size in pixels. */
1260:     private int size;
1261:     
1262:     /**
1263:      * Creates a new icon.
1264:      * 
1265:      * @param size  the icon size in pixels.
1266:      */
1267:     public InternalFrameAltMaximizeIcon(int size) 
1268:     {
1269:       this.size = size;
1270:     }
1271:     
1272:     /**
1273:      * Returns the width of the icon, in pixels.
1274:      * 
1275:      * @return The width of the icon.
1276:      */
1277:     public int getIconWidth() 
1278:     {
1279:       return size;
1280:     }
1281:     
1282:     /**
1283:      * Returns the height of the icon, in pixels.
1284:      * 
1285:      * @return The height of the icon.
1286:      */
1287:     public int getIconHeight() 
1288:     {
1289:       return size;
1290:     }
1291:     
1292:     /**
1293:      * Paints the icon at the specified location.
1294:      * 
1295:      * @param c  the component.
1296:      * @param g  the graphics device.
1297:      * @param x  the x coordinate.
1298:      * @param y  the y coordinate.
1299:      */
1300:     public void paintIcon(Component c, Graphics g, int x, int y) 
1301:     {
1302:       Color savedColor = g.getColor();
1303: 
1304:       AbstractButton b = (AbstractButton) c;
1305: 
1306:       // fill the small box interior
1307:       if (b.getModel().isPressed())
1308:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1309:       else
1310:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1311:       g.fillRect(x + 2, y + 6, 7, 7);
1312:       
1313:       
1314:       if (b.getModel().isPressed())
1315:         g.setColor(MetalLookAndFeel.getBlack());
1316:       else
1317:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1318:         
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);
1325:       
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);
1330:       
1331:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1332:       
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);
1343:       
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);
1352:       
1353:       if (!b.getModel().isPressed())
1354:         {
1355:           g.drawLine(x + 2, y + 6, x + 6, y + 6);
1356:           g.drawLine(x + 2, y + 6, x + 2, y + 11);
1357:         }
1358:       
1359:       g.setColor(savedColor);
1360:     }        
1361:   }
1362:   
1363:   /**
1364:    * An icon used for the 'maximize' button in the title frame of a 
1365:    * {@link JInternalFrame}.
1366:    */
1367:   private static class InternalFrameMaximizeIcon implements Icon, Serializable
1368:   {
1369:     
1370:     /**
1371:      * Creates a new instance.
1372:      */
1373:     public InternalFrameMaximizeIcon() 
1374:     {
1375:       // Nothing to do here.
1376:     }
1377:     
1378:     /**
1379:      * Returns the width of the icon, in pixels.
1380:      * 
1381:      * @return The width of the icon.
1382:      */
1383:     public int getIconWidth() 
1384:     {
1385:       return 16;
1386:     }
1387:     
1388:     /**
1389:      * Returns the height of the icon, in pixels.
1390:      * 
1391:      * @return The height of the icon.
1392:      */
1393:     public int getIconHeight() 
1394:     {
1395:       return 16;
1396:     }
1397:     
1398:     /**
1399:      * Paints the icon at the specified location.
1400:      * 
1401:      * @param c  the component.
1402:      * @param g  the graphics device.
1403:      * @param x  the x coordinate.
1404:      * @param y  the y coordinate.
1405:      */
1406:     public void paintIcon(Component c, Graphics g, int x, int y) 
1407:     {
1408:       Color savedColor = g.getColor();
1409:       
1410:       AbstractButton b = (AbstractButton) c;
1411:       
1412:       // fill the interior
1413:       if (b.getModel().isPressed())
1414:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1415:       else
1416:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1417:       g.fillRect(x + 2, y + 6, 7, 7);
1418: 
1419:       if (b.getModel().isPressed())
1420:         g.setColor(MetalLookAndFeel.getBlack());
1421:       else
1422:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1423:           
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);
1433:       
1434:       // fill
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);
1443:       
1444:       // draw black
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);
1451:       
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);
1455:       
1456:       // draw white
1457:       g.setColor(MetalLookAndFeel.getWhite());
1458:       if (!b.getModel().isPressed())
1459:         {
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);
1463:         }
1464:       
1465:       g.drawLine(x + 1, y + 14, x + 10, y + 14);
1466:       g.drawLine(x + 10, y + 5, x + 10, y + 13);
1467:       
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);
1473:     }        
1474:   }
1475: 
1476:   /**
1477:    * An icon used in the title frame of a {@link JInternalFrame}.
1478:    */
1479:   private static class InternalFrameMinimizeIcon implements Icon, Serializable
1480:   {
1481:   
1482:     /**
1483:      * Creates a new instance.
1484:      */
1485:     public InternalFrameMinimizeIcon() 
1486:     {
1487:       // Nothing to do here.
1488:     }
1489:     
1490:     /**
1491:      * Returns the width of the icon, in pixels.
1492:      * 
1493:      * @return The width of the icon.
1494:      */
1495:     public int getIconWidth() 
1496:     {
1497:       return 16;
1498:     }
1499:     
1500:     /**
1501:      * Returns the height of the icon, in pixels.
1502:      * 
1503:      * @return The height of the icon.
1504:      */
1505:     public int getIconHeight() 
1506:     {
1507:       return 16;
1508:     }
1509:     
1510:     /**
1511:      * Paints the icon at the specified location.
1512:      * 
1513:      * @param c  the component.
1514:      * @param g  the graphics device.
1515:      * @param x  the x coordinate.
1516:      * @param y  the y coordinate.
1517:      */
1518:     public void paintIcon(Component c, Graphics g, int x, int y) 
1519:     {
1520:       Color savedColor = g.getColor();
1521:       
1522:       AbstractButton b = (AbstractButton) c;
1523:       
1524:       if (b.getModel().isPressed())
1525:         g.setColor(MetalLookAndFeel.getBlack());
1526:       else
1527:         // FIXME: here the color depends on whether or not the internal frame 
1528:         // is selected 
1529:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1530:       
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);
1537:       
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);
1542:       
1543:       g.drawLine(x + 5, y + 9, x + 5, y + 9);
1544:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1545:       
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);
1555:       
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);
1563: 
1564:       if (b.getModel().isPressed())
1565:         {
1566:           g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1567:           g.fillRect(x + 2, y + 9, 3, 3);
1568:         }
1569:       else
1570:         {
1571:           g.drawLine(x + 2, y + 9, x + 4, y + 9);
1572:           g.drawLine(x + 2, y + 10, x + 2, y + 11);
1573:         }
1574: 
1575:       g.setColor(savedColor);
1576:     }        
1577:   }
1578: 
1579:   /**
1580:    * The icon used to display the thumb control on a horizontally oriented
1581:    * {@link JSlider} component.
1582:    */
1583:   private static class VerticalSliderThumbIcon implements Icon, Serializable
1584:   {
1585:     /**
1586:      * Creates a new instance.
1587:      */
1588:     public VerticalSliderThumbIcon() 
1589:     {
1590:       // Nothing to do here.
1591:     }
1592:     
1593:     /**
1594:      * Returns the width of the icon, in pixels.
1595:      * 
1596:      * @return The width of the icon.
1597:      */
1598:     public int getIconWidth() 
1599:     {
1600:       return 16;
1601:     }
1602:     
1603:     /**
1604:      * Returns the height of the icon, in pixels.
1605:      * 
1606:      * @return The height of the icon.
1607:      */
1608:     public int getIconHeight() 
1609:     {
1610:       return 15;
1611:     }
1612:     
1613:     /**
1614:      * Paints the icon taking into account whether the slider control has the
1615:      * focus or not.
1616:      * 
1617:      * @param c  the slider (must be a non-<code>null</code> instance of
1618:      *           {@link JSlider}.
1619:      * @param g  the graphics device.
1620:      * @param x  the x-coordinate.
1621:      * @param y  the y-coordinate.
1622:      */
1623:     public void paintIcon(Component c, Graphics g, int x, int y) 
1624:     {
1625:       boolean enabled = false;
1626:       boolean focus = false;
1627:       if (c != null)
1628:         {
1629:           enabled = c.isEnabled();
1630:           focus = c.hasFocus();    
1631:         }
1632:       
1633:       // draw the outline
1634:       if (enabled) 
1635:         g.setColor(MetalLookAndFeel.getBlack());
1636:       else
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);
1643:       
1644:       // fill the icon
1645:       if (focus)
1646:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1647:       else
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);
1656:       
1657:       // if the slider is enabled, draw dots and highlights
1658:       if (enabled)
1659:         {
1660:           if (focus)
1661:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1662:           else
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);
1667: 
1668:           g.drawLine(x + 5, y + 5, x + 5, y + 5);
1669:           g.drawLine(x + 5, y + 9, x + 5, y + 9);
1670: 
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);
1674: 
1675:           // draw highlights
1676:           if (focus)
1677:             g.setColor(MetalLookAndFeel.getPrimaryControl());
1678:           else
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);
1685: 
1686:           g.drawLine(x + 4, y + 4, x + 4, y + 4);
1687:           g.drawLine(x + 4, y + 8, x + 4, y + 8);
1688: 
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);
1692:         
1693:         }
1694:     }        
1695:   }
1696:     
1697:   /**
1698:    * A tree control icon.  This icon can be in one of two states: expanded and
1699:    * collapsed.
1700:    */
1701:   public static class TreeControlIcon implements Icon, Serializable
1702:   {
1703:     
1704:     /** ???. */
1705:     protected boolean isLight;
1706:     
1707:     /** A flag that controls whether or not the icon is collapsed. */
1708:     private boolean collapsed;
1709:     
1710:     /**
1711:      * Creates a new icon.
1712:      * 
1713:      * @param isCollapsed  a flag that controls whether the icon is in the
1714:      *                     collapsed state or the expanded state.
1715:      */
1716:     public TreeControlIcon(boolean isCollapsed) 
1717:     {
1718:       collapsed = isCollapsed;
1719:     }
1720:     
1721:     /**
1722:      * Returns the width of the icon, in pixels.
1723:      * 
1724:      * @return The width of the icon.
1725:      */
1726:     public int getIconWidth() 
1727:     {
1728:       return 18;
1729:     }
1730:     /**
1731:      * Returns the height of the icon, in pixels.
1732:      * 
1733:      * @return The height of the icon.
1734:      */
1735:     public int getIconHeight() 
1736:     {
1737:       return 18;
1738:     }
1739:     
1740:     /**
1741:      * Paints the icon at the location (x, y).
1742:      * 
1743:      * @param c  the component.
1744:      * @param g  the graphics device.
1745:      * @param x  the x coordinate.
1746:      * @param y  the y coordinate.
1747:      */
1748:     public void paintIcon(Component c, Graphics g, int x, int y) 
1749:     {
1750:       x = x + 5;
1751:       y = y + 5;
1752:       if (collapsed) 
1753:       {
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);
1765: 
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);
1771:         
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);
1778:         
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);
1782:       }
1783:       else
1784:       {
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);
1797: 
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);
1803:         
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);
1810:         
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);
1814:       }
1815:     } 
1816:     
1817:     /**
1818:      * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
1819:      * 
1820:      * @param c  the component.
1821:      * @param g  the graphics device.
1822:      * @param x  the x coordinate.
1823:      * @param y  the y coordinate.
1824:      */
1825:     public void paintMe(Component c, Graphics g, int x, int y) 
1826:     {
1827:       paintIcon(c, g, x, y);  
1828:     }
1829:   }
1830:     
1831:   /**
1832:    * A tree folder icon.
1833:    */
1834:   public static class TreeFolderIcon extends FolderIcon16
1835:   {
1836:     /**
1837:      * Creates a new instance.
1838:      */
1839:     public TreeFolderIcon() 
1840:     {
1841:       // Nothing to do here.
1842:     }
1843:     
1844:     /**
1845:      * Returns the additional height for this icon, in this case <code>2</code>
1846:      * pixels.
1847:      * 
1848:      * @return <code>2</code>.
1849:      */
1850:     public int getAdditionalHeight() 
1851:     {
1852:       return 2;
1853:     }
1854:     
1855:     /**
1856:      * Returns the shift (???).
1857:      * 
1858:      * @return The shift.
1859:      */
1860:     public int getShift() 
1861:     {
1862:       return -1;
1863:     }
1864:   }
1865:     
1866:   /**
1867:    * A tree leaf icon.
1868:    */
1869:   public static class TreeLeafIcon extends FileIcon16
1870:   {
1871:     /**
1872:      * Creates a new instance.
1873:      */
1874:     public TreeLeafIcon() 
1875:     {
1876:       // Nothing to do here.
1877:     }
1878:     
1879:     /**
1880:      * Returns the additional height for this icon, in this case <code>4</code>
1881:      * pixels.
1882:      * 
1883:      * @return <code>4</code>.
1884:      */
1885:     public int getAdditionalHeight() 
1886:     {
1887:       return 4;
1888:     }
1889:     
1890:     /**
1891:      * Returns the shift (???).
1892:      * 
1893:      * @return The shift.
1894:      */
1895:     public int getShift() 
1896:     {
1897:       return 2;
1898:     }
1899:   }
1900: 
1901:   /**
1902:    * An icon representing a hard disk.
1903:    * 
1904:    * @see MetalIconFactory#getTreeHardDriveIcon()
1905:    */
1906:   private static class TreeHardDriveIcon implements Icon, Serializable
1907:   {
1908: 
1909:     /**
1910:      * Creates a new icon instance.
1911:      */
1912:     public TreeHardDriveIcon() 
1913:     {
1914:       // Nothing to do here.
1915:     }
1916: 
1917:     /**
1918:      * Returns the width of the icon, in pixels.
1919:      * 
1920:      * @return <code>16</code>.
1921:      */
1922:     public int getIconWidth() 
1923:     { 
1924:       return 16;
1925:     }
1926: 
1927:     /**
1928:      * Returns the height of the icon, in pixels.
1929:      * 
1930:      * @return <code>16</code>.
1931:      */
1932:     public int getIconHeight()   
1933:     {
1934:       return 16;
1935:     }
1936: 
1937:     /**
1938:      * Paints the icon at the specified location, using colors from the 
1939:      * current theme.
1940:      * 
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.
1945:      */
1946:     public void paintIcon(Component c, Graphics g, int x, int y) 
1947:     {
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);
1956:       
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);
1965:       
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);
1970:       
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);
1983:       
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);
1991:       
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);
1996: 
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);
2001: 
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);
2006: 
2007:       g.setColor(saved);
2008:     }        
2009:   }  
2010:   
2011:   /**
2012:    * An icon representing a floppy disk.
2013:    * 
2014:    * @see MetalIconFactory#getTreeFloppyDriveIcon()
2015:    */
2016:   private static class TreeFloppyDriveIcon implements Icon, Serializable
2017:   {
2018: 
2019:     /**
2020:      * Creates a new icon instance.
2021:      */
2022:     public TreeFloppyDriveIcon() 
2023:     {
2024:       // Nothing to do here.
2025:     }
2026: 
2027:     /**
2028:      * Returns the width of the icon, in pixels.
2029:      * 
2030:      * @return <code>16</code>.
2031:      */
2032:     public int getIconWidth() 
2033:     { 
2034:       return 16;
2035:     }
2036: 
2037:     /**
2038:      * Returns the height of the icon, in pixels.
2039:      * 
2040:      * @return <code>16</code>.
2041:      */
2042:     public int getIconHeight()   
2043:     {
2044:       return 16;
2045:     }
2046: 
2047:     /**
2048:      * Paints the icon at the specified location, using colors from the 
2049:      * current theme.
2050:      * 
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.
2055:      */
2056:     public void paintIcon(Component c, Graphics g, int x, int y) 
2057:     {
2058:       Color saved = g.getColor();
2059:       
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);
2065:       
2066:       g.setColor(MetalLookAndFeel.getPrimaryControl());
2067:       g.fillRect(x + 2, y + 2, 12, 12);
2068:       
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);
2074:       
2075:       g.setColor(MetalLookAndFeel.getWhite());
2076:       g.fillRect(x + 8, y + 3, 2, 3);
2077:       g.fillRect(x + 4, y + 9, 8, 5);
2078:       
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);
2082: 
2083:       g.setColor(saved);
2084:     }        
2085:   }  
2086: 
2087:   /**
2088:    * An icon representing a computer.
2089:    * 
2090:    * @see MetalIconFactory#getTreeComputerIcon()
2091:    */
2092:   private static class TreeComputerIcon implements Icon, Serializable
2093:   {
2094: 
2095:     /**
2096:      * Creates a new icon instance.
2097:      */
2098:     public TreeComputerIcon() 
2099:     {
2100:       // Nothing to do here.
2101:     }
2102: 
2103:     /**
2104:      * Returns the width of the icon, in pixels.
2105:      * 
2106:      * @return <code>16</code>.
2107:      */
2108:     public int getIconWidth() 
2109:     { 
2110:       return 16;
2111:     }
2112: 
2113:     /**
2114:      * Returns the height of the icon, in pixels.
2115:      * 
2116:      * @return <code>16</code>.
2117:      */
2118:     public int getIconHeight()   
2119:     {
2120:       return 16;
2121:     }
2122: 
2123:     /**
2124:      * Paints the icon at the specified location, using colors from the 
2125:      * current theme.
2126:      * 
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.
2131:      */
2132:     public void paintIcon(Component c, Graphics g, int x, int y) 
2133:     {
2134:       Color saved = g.getColor();
2135:       
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);
2147: 
2148:       g.setColor(MetalLookAndFeel.getPrimaryControl());
2149:       g.fillRect(x + 5, y + 4, 6, 4);
2150:       
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);
2154:       g.setColor(saved);
2155:     }        
2156:   }  
2157:     
2158:   /** The icon returned by {@link #getCheckBoxIcon()}. */
2159:   private static Icon checkBoxIcon;
2160:   
2161:   /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
2162:   private static Icon checkBoxMenuItemIcon;
2163:   
2164:   /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
2165:   private static Icon fileChooserDetailViewIcon;
2166: 
2167:   /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
2168:   private static Icon fileChooserHomeFolderIcon;
2169: 
2170:   /** The icon returned by {@link #getFileChooserListViewIcon()}. */
2171:   private static Icon fileChooserListViewIcon;
2172: 
2173:   /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
2174:   private static Icon fileChooserNewFolderIcon;
2175: 
2176:   /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
2177:   private static Icon fileChooserUpFolderIcon;
2178: 
2179:   /** The cached RadioButtonIcon instance. */
2180:   private static RadioButtonIcon radioButtonIcon;
2181: 
2182:   /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
2183:   private static Icon radioButtonMenuItemIcon;
2184: 
2185:   /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
2186:   private static Icon internalFrameDefaultMenuIcon;
2187: 
2188:   /** The icon returned by {@link #getTreeComputerIcon()}. */
2189:   private static Icon treeComputerIcon;
2190:   
2191:   /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
2192:   private static Icon treeFloppyDriveIcon;
2193:   
2194:   /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
2195:   private static Icon treeHardDriveIcon;
2196:   
2197:   /**
2198:    * Creates a new instance.  All the methods are static, so creating an 
2199:    * instance isn't necessary.
2200:    */
2201:   public MetalIconFactory() 
2202:   {
2203:     // Nothing to do here.
2204:   }
2205: 
2206:   /**
2207:    * Returns an icon for use when rendering the {@link JCheckBox} component.
2208:    * 
2209:    * @return A check box icon.
2210:    * 
2211:    * @since 1.3
2212:    */
2213:   public static Icon getCheckBoxIcon() 
2214:   {
2215:     if (checkBoxIcon == null)
2216:       checkBoxIcon = new MetalCheckBoxIcon();
2217:     return checkBoxIcon;
2218:   }
2219:   
2220:   /**
2221:    * Returns an icon for use when rendering the {@link JCheckBoxMenuItem} 
2222:    * component.
2223:    * 
2224:    * @return An icon.
2225:    */
2226:   public static Icon getCheckBoxMenuItemIcon() 
2227:   {
2228:     if (checkBoxMenuItemIcon == null)
2229:       checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
2230:     return checkBoxMenuItemIcon;
2231:   }
2232: 
2233:   /**
2234:    * Returns an icon for use by the {@link JFileChooser} component.
2235:    * 
2236:    * @return An icon.
2237:    */
2238:   public static Icon getFileChooserDetailViewIcon() 
2239:   {
2240:     if (fileChooserDetailViewIcon == null)
2241:       fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
2242:     return fileChooserDetailViewIcon;
2243:   }
2244:     
2245:   /**
2246:    * Returns an icon for use by the {@link JFileChooser} component.
2247:    * 
2248:    * @return An icon.
2249:    */
2250:   public static Icon getFileChooserHomeFolderIcon() 
2251:   {
2252:     if (fileChooserHomeFolderIcon == null)
2253:       fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
2254:     return fileChooserHomeFolderIcon;        
2255:   }
2256:     
2257:   /**
2258:    * Returns an icon for use by the {@link JFileChooser} component.
2259:    * 
2260:    * @return An icon.
2261:    */
2262:   public static Icon getFileChooserListViewIcon() 
2263:   {
2264:     if (fileChooserListViewIcon == null)
2265:       fileChooserListViewIcon = new FileChooserListViewIcon();
2266:     return fileChooserListViewIcon;
2267:   }
2268:     
2269:   /**
2270:    * Returns an icon for use by the {@link JFileChooser} component.
2271:    * 
2272:    * @return An icon.
2273:    */
2274:   public static Icon getFileChooserNewFolderIcon() 
2275:   {
2276:     if (fileChooserNewFolderIcon == null)
2277:       fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
2278:     return fileChooserNewFolderIcon;
2279:   }
2280:     
2281:   /**
2282:    * Returns an icon for use by the {@link JFileChooser} component.
2283:    * 
2284:    * @return An icon.
2285:    */
2286:   public static Icon getFileChooserUpFolderIcon() 
2287:   {
2288:     if (fileChooserUpFolderIcon == null)
2289:       fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
2290:     return fileChooserUpFolderIcon;
2291:   }
2292: 
2293:   /**
2294:    * Returns an icon for RadioButtons in the Metal L&amp;F.
2295:    *
2296:    * @return an icon for RadioButtons in the Metal L&amp;F
2297:    */
2298:   public static Icon getRadioButtonIcon()
2299:   {
2300:     if (radioButtonIcon == null)
2301:       radioButtonIcon = new RadioButtonIcon();
2302:     return radioButtonIcon;
2303:   }
2304: 
2305:   /**
2306:    * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
2307:    * 
2308:    * @return A new icon instance.
2309:    */
2310:   public static Icon getRadioButtonMenuItemIcon() 
2311:   {
2312:     if (radioButtonMenuItemIcon == null)
2313:       radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
2314:     return radioButtonMenuItemIcon;
2315:   }
2316: 
2317:   /**
2318:    * Returns the icon used to display the thumb for a horizontally oriented
2319:    * {@link JSlider}.
2320:    * 
2321:    * @return The icon.
2322:    */
2323:   public static Icon getHorizontalSliderThumbIcon() 
2324:   {
2325:     return new HorizontalSliderThumbIcon();
2326:   }
2327:     
2328:   /**
2329:    * Creates a new icon used to represent the 'close' button in the title
2330:    * pane of a {@link JInternalFrame}.
2331:    * 
2332:    * @param size  the icon size.
2333:    * 
2334:    * @return A close icon.
2335:    */
2336:   public static Icon getInternalFrameCloseIcon(int size) 
2337:   {
2338:     return new InternalFrameCloseIcon(size);
2339:   }
2340: 
2341:   /**
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.
2344:    * 
2345:    * @return A menu icon.
2346:    */
2347:   public static Icon getInternalFrameDefaultMenuIcon() 
2348:   {
2349:     if (internalFrameDefaultMenuIcon == null)
2350:       internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
2351:     return internalFrameDefaultMenuIcon;
2352:   }
2353:   
2354:   /**
2355:    * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
2356:    * 
2357:    * @param size  the icon size in pixels.
2358:    * 
2359:    * @return The icon.
2360:    * 
2361:    * @see #getInternalFrameAltMaximizeIcon(int)
2362:    */
2363:   public static Icon getInternalFrameMaximizeIcon(int size) 
2364:   {
2365:     return new InternalFrameMaximizeIcon();
2366:   }
2367:     
2368:   /**
2369:    * Returns the icon used for the minimize button in the frame title for a
2370:    * {@link JInternalFrame}.
2371:    * 
2372:    * @param size  the icon size in pixels (ignored by this implementation).
2373:    * 
2374:    * @return The icon.
2375:    */
2376:   public static Icon getInternalFrameMinimizeIcon(int size) 
2377:   {
2378:     return new InternalFrameMinimizeIcon();
2379:   }
2380: 
2381:   /**
2382:    * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
2383:    * that has been maximised.
2384:    * 
2385:    * @param size  the icon size in pixels.
2386:    * 
2387:    * @return The icon.
2388:    * 
2389:    * @see #getInternalFrameMaximizeIcon(int)
2390:    */
2391:   public static Icon getInternalFrameAltMaximizeIcon(int size) 
2392:   {
2393:     return new InternalFrameAltMaximizeIcon(size);
2394:   }
2395:   
2396:   /**
2397:    * Returns the icon used to display the thumb for a vertically oriented
2398:    * {@link JSlider}.
2399:    * 
2400:    * @return The icon.
2401:    */
2402:   public static Icon getVerticalSliderThumbIcon() 
2403:   {
2404:     return new VerticalSliderThumbIcon();
2405:   }
2406:     
2407:   /**
2408:    * Creates and returns a new tree folder icon.
2409:    * 
2410:    * @return A new tree folder icon.
2411:    */  
2412:   public static Icon getTreeFolderIcon() 
2413:   {
2414:     return new TreeFolderIcon();
2415:   }
2416:     
2417:   /**
2418:    * Creates and returns a new tree leaf icon.
2419:    * 
2420:    * @return A new tree leaf icon.
2421:    */
2422:   public static Icon getTreeLeafIcon() 
2423:   {
2424:     return new TreeLeafIcon();
2425:   }
2426:   
2427:   /**
2428:    * Creates and returns a tree control icon.
2429:    * 
2430:    * @param isCollapsed  a flag that controls whether the icon is in the 
2431:    *                     collapsed or expanded state.
2432:    * 
2433:    * @return A tree control icon.
2434:    */
2435:   public static Icon getTreeControlIcon(boolean isCollapsed) 
2436:   {
2437:     return new TreeControlIcon(isCollapsed);
2438:   }
2439: 
2440:   /**
2441:    * Returns a <code>16x16</code> icon representing a computer.
2442:    * 
2443:    * @return The icon.
2444:    */
2445:   public static Icon getTreeComputerIcon() 
2446:   {
2447:     if (treeComputerIcon == null)
2448:       treeComputerIcon = new TreeComputerIcon();
2449:     return treeComputerIcon;        
2450:   }
2451:     
2452:   /**
2453:    * Returns a <code>16x16</code> icon representing a floppy disk.
2454:    * 
2455:    * @return The icon.
2456:    */
2457:   public static Icon getTreeFloppyDriveIcon() 
2458:   {
2459:     if (treeFloppyDriveIcon == null)
2460:       treeFloppyDriveIcon = new TreeFloppyDriveIcon();
2461:     return treeFloppyDriveIcon;
2462:   }
2463:     
2464:   /**
2465:    * Returns a <code>16x16</code> icon representing a hard disk.
2466:    * 
2467:    * @return The icon.
2468:    */
2469:   public static Icon getTreeHardDriveIcon() 
2470:   {
2471:     if (treeHardDriveIcon == null)
2472:       treeHardDriveIcon = new TreeHardDriveIcon();
2473:     return treeHardDriveIcon;
2474:   }
2475: 
2476:   /**
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 
2479:    * sub menu.
2480:    * 
2481:    * @return The icon.
2482:    */
2483:   public static Icon getMenuArrowIcon()
2484:   {
2485:     if (menuArrow == null)
2486:       menuArrow = new Icon()
2487:       {
2488:         public int getIconHeight()
2489:         {
2490:           return 8;
2491:         }
2492: 
2493:         public int getIconWidth()
2494:         {
2495:           return 4;
2496:         }
2497: 
2498:         public void paintIcon(Component c, Graphics g, int x, int y)
2499:         {
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);
2504:           g.setColor(saved);
2505:         }
2506:       };
2507:     return menuArrow;
2508:   }
2509:   
2510:   /**
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.
2513:    * 
2514:    * @return The icon.
2515:    */
2516:   public static Icon getMenuItemArrowIcon()
2517:   {
2518:     if (menuItemArrow == null)
2519:       menuItemArrow = new Icon()
2520:       {
2521:         public int getIconHeight()
2522:         {
2523:           return 8;
2524:         }
2525: 
2526:         public int getIconWidth()
2527:         {
2528:           return 4;
2529:         }
2530: 
2531:         public void paintIcon(Component c, Graphics g, int x, int y)
2532:         {
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);
2537:           g.setColor(saved);
2538:         }
2539:       };
2540:     return menuItemArrow;
2541:   }
2542:   
2543:   /**
2544:    * Returns a new instance of a 13 x 13 icon showing a small black check mark.
2545:    * 
2546:    * @return The icon.
2547:    */
2548:   public static Icon getMenuItemCheckIcon()
2549:   {
2550:     return new Icon()
2551:     {
2552:       public int getIconHeight()
2553:       {
2554:         return 13;
2555:       }
2556: 
2557:       public int getIconWidth()
2558:       {
2559:         return 13;
2560:       }
2561: 
2562:       public void paintIcon(Component c, Graphics g, int x, int y)
2563:       {
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);
2570:         g.setColor(saved);
2571:       }
2572:     };
2573:   }
2574: }