365 * the text and icon rectangles plus the buttons insets. 366 */ 367 368 Rectangle r = iconR.union(textR); 369 370 Insets insets = b.getInsets(); 371 r.width += insets.left + insets.right; 372 r.height += insets.top + insets.bottom; 373 374 return r.getSize(); 375 } 376 377 /* 378 * Convenience function for determining ComponentOrientation. Helps us 379 * avoid having Munge directives throughout the code. 380 */ 381 static boolean isLeftToRight( Component c ) { 382 return c.getComponentOrientation().isLeftToRight(); 383 } 384 385 @SuppressWarnings("deprecation") 386 static boolean isMenuShortcutKeyDown(InputEvent event) { 387 return (event.getModifiers() & 388 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0; 389 } 390 391 /** 392 * Draws the given string at the specified location using text properties 393 * and anti-aliasing hints from the provided component. 394 * Nothing is drawn for the null string. 395 * 396 * @param c the component that will display the string, may be null 397 * @param g the graphics context, must not be null 398 * @param string the string to display, may be null 399 * @param x the x coordinate to draw the text at 400 * @param y the y coordinate to draw the text at 401 * @throws NullPointerException if the specified {@code g} is {@code null} 402 * 403 * @since 9 404 */ 405 public static void drawString(JComponent c, Graphics2D g, String string, 406 float x, float y) { 407 SwingUtilities2.drawString(c, g, string, x, y, true); 408 } | 365 * the text and icon rectangles plus the buttons insets. 366 */ 367 368 Rectangle r = iconR.union(textR); 369 370 Insets insets = b.getInsets(); 371 r.width += insets.left + insets.right; 372 r.height += insets.top + insets.bottom; 373 374 return r.getSize(); 375 } 376 377 /* 378 * Convenience function for determining ComponentOrientation. Helps us 379 * avoid having Munge directives throughout the code. 380 */ 381 static boolean isLeftToRight( Component c ) { 382 return c.getComponentOrientation().isLeftToRight(); 383 } 384 385 static boolean isMenuShortcutKeyDown(InputEvent event) { 386 return (event.getModifiersEx() & 387 Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()) != 0; 388 } 389 390 /** 391 * Draws the given string at the specified location using text properties 392 * and anti-aliasing hints from the provided component. 393 * Nothing is drawn for the null string. 394 * 395 * @param c the component that will display the string, may be null 396 * @param g the graphics context, must not be null 397 * @param string the string to display, may be null 398 * @param x the x coordinate to draw the text at 399 * @param y the y coordinate to draw the text at 400 * @throws NullPointerException if the specified {@code g} is {@code null} 401 * 402 * @since 9 403 */ 404 public static void drawString(JComponent c, Graphics2D g, String string, 405 float x, float y) { 406 SwingUtilities2.drawString(c, g, string, x, y, true); 407 } |