1419 if (fg.getRed() < 16) { 1420 rule.append('0'); 1421 } 1422 rule.append(Integer.toHexString(fg.getRed())); 1423 if (fg.getGreen() < 16) { 1424 rule.append('0'); 1425 } 1426 rule.append(Integer.toHexString(fg.getGreen())); 1427 if (fg.getBlue() < 16) { 1428 rule.append('0'); 1429 } 1430 rule.append(Integer.toHexString(fg.getBlue())); 1431 rule.append(" ; "); 1432 } 1433 rule.append(" }"); 1434 return rule.toString(); 1435 } 1436 1437 /** 1438 * Utility method that creates a {@code UIDefaults.LazyValue} that 1439 * creates an {@code ImageIcon} {@code UIResource} for the 1440 * specified image file name. The image is loaded using 1441 * {@code getResourceAsStream}, starting with a call to that method 1442 * on the base class parameter. If it cannot be found, searching will 1443 * continue through the base class' inheritance hierarchy, up to and 1444 * including {@code rootClass}. 1445 * 1446 * @param baseClass the first class to use in searching for the resource 1447 * @param rootClass an ancestor of {@code baseClass} to finish the 1448 * search at 1449 * @param imageFile the name of the file to be found 1450 * @return a lazy value that creates the {@code ImageIcon} 1451 * {@code UIResource} for the image, 1452 * or null if it cannot be found 1453 */ 1454 public static Object makeIcon(final Class<?> baseClass, 1455 final Class<?> rootClass, 1456 final String imageFile) { 1457 return makeIcon(baseClass, rootClass, imageFile, true); 1458 } 1459 1460 /** 1461 * Utility method that creates a {@code UIDefaults.LazyValue} that 1462 * creates an {@code ImageIcon} {@code UIResource} for the 1463 * specified image file name. The image is loaded using 1464 * {@code getResourceAsStream}, starting with a call to that method 1465 * on the base class parameter. If it cannot be found, searching will 1466 * continue through the base class' inheritance hierarchy, up to and 1467 * including {@code rootClass}. 1468 * 1469 * Finds an image with a given name without privileges enabled. 1470 * 1471 * @param baseClass the first class to use in searching for the resource 1472 * @param rootClass an ancestor of {@code baseClass} to finish the 1473 * search at 1474 * @param imageFile the name of the file to be found 1475 * @return a lazy value that creates the {@code ImageIcon} 1476 * {@code UIResource} for the image, 1477 * or null if it cannot be found 1478 */ 1479 public static Object makeIcon_Unprivileged(final Class<?> baseClass, 1480 final Class<?> rootClass, 1481 final String imageFile) { 1482 return makeIcon(baseClass, rootClass, imageFile, false); | 1419 if (fg.getRed() < 16) { 1420 rule.append('0'); 1421 } 1422 rule.append(Integer.toHexString(fg.getRed())); 1423 if (fg.getGreen() < 16) { 1424 rule.append('0'); 1425 } 1426 rule.append(Integer.toHexString(fg.getGreen())); 1427 if (fg.getBlue() < 16) { 1428 rule.append('0'); 1429 } 1430 rule.append(Integer.toHexString(fg.getBlue())); 1431 rule.append(" ; "); 1432 } 1433 rule.append(" }"); 1434 return rule.toString(); 1435 } 1436 1437 /** 1438 * Utility method that creates a {@code UIDefaults.LazyValue} that 1439 * creates an {@code ImageIcon UIResource} for the 1440 * specified image file name. The image is loaded using 1441 * {@code getResourceAsStream}, starting with a call to that method 1442 * on the base class parameter. If it cannot be found, searching will 1443 * continue through the base class' inheritance hierarchy, up to and 1444 * including {@code rootClass}. 1445 * 1446 * @param baseClass the first class to use in searching for the resource 1447 * @param rootClass an ancestor of {@code baseClass} to finish the 1448 * search at 1449 * @param imageFile the name of the file to be found 1450 * @return a lazy value that creates the {@code ImageIcon} 1451 * {@code UIResource} for the image, 1452 * or null if it cannot be found 1453 */ 1454 public static Object makeIcon(final Class<?> baseClass, 1455 final Class<?> rootClass, 1456 final String imageFile) { 1457 return makeIcon(baseClass, rootClass, imageFile, true); 1458 } 1459 1460 /** 1461 * Utility method that creates a {@code UIDefaults.LazyValue} that 1462 * creates an {@code ImageIcon UIResource} for the 1463 * specified image file name. The image is loaded using 1464 * {@code getResourceAsStream}, starting with a call to that method 1465 * on the base class parameter. If it cannot be found, searching will 1466 * continue through the base class' inheritance hierarchy, up to and 1467 * including {@code rootClass}. 1468 * 1469 * Finds an image with a given name without privileges enabled. 1470 * 1471 * @param baseClass the first class to use in searching for the resource 1472 * @param rootClass an ancestor of {@code baseClass} to finish the 1473 * search at 1474 * @param imageFile the name of the file to be found 1475 * @return a lazy value that creates the {@code ImageIcon} 1476 * {@code UIResource} for the image, 1477 * or null if it cannot be found 1478 */ 1479 public static Object makeIcon_Unprivileged(final Class<?> baseClass, 1480 final Class<?> rootClass, 1481 final String imageFile) { 1482 return makeIcon(baseClass, rootClass, imageFile, false); |