1 package javax
.swing
.plaf
.basic
;
8 public class BasicGraphicsUtils
10 public static Dimension
getPreferredSize(JComponent b
,
20 // this is a staight copy from BasicButtonUI.paint()
22 Rectangle tr
= new Rectangle();
23 Rectangle ir
= new Rectangle();
24 Rectangle vr
= new Rectangle();
28 FontMetrics fm
= SwingUtilities
.getFontMetrics(f
);
30 Insets i
= c
.getInsets();
34 vr
.width
= b
.getWidth() - (i
.right
+ i
.left
);
35 vr
.height
= b
.getHeight() - (i
.bottom
+ i
.top
);
37 // System.out.println(" VIEW-RECT-BUTTON="+vr+", insets="+i);
39 String tt
= SwingUtilities
.layoutCompoundLabel(b
,
52 Rectangle r
= ir
.union(tr
);
54 Insets insets
= b
.getInsets();
55 r
.width
+= insets
.left
+ insets
.right
;
56 r
.height
+= insets
.top
+ insets
.bottom
;
58 // System.out.println("COMPUTED SIZE FOR PREF_SIZE="+r);
63 public static void drawString(Graphics g
,
69 g
.drawString(text
, x
, y
);