< prev index next >
src/java.desktop/share/classes/javax/swing/colorchooser/DefaultPreviewPanel.java
Print this page
@@ -79,13 +79,13 @@
if (host == null) {
host = this;
}
FontMetrics fm = host.getFontMetrics(getFont());
- int ascent = fm.getAscent();
int height = fm.getHeight();
- int width = SwingUtilities2.stringWidth(host, fm, getSampleText());
+ int width = SwingUtilities2.getTextUIDrawing(host)
+ .getStringWidth(host, fm, getSampleText());
int y = height*3 + textGap*3;
int x = squareSize * 3 + squareGap*2 + swatchWidth + width + textGap*3;
return new Dimension( x,y );
}
@@ -126,28 +126,31 @@
}
FontMetrics fm = SwingUtilities2.getFontMetrics(host, g);
int ascent = fm.getAscent();
int height = fm.getHeight();
- int width = SwingUtilities2.stringWidth(host, fm, getSampleText());
+ int width = SwingUtilities2.getTextUIDrawing(host)
+ .getStringWidth(host, fm, getSampleText());
int textXOffset = offsetX + textGap;
Color color = getForeground();
g.setColor(color);
- SwingUtilities2.drawString(host, g, getSampleText(),textXOffset+(textGap/2),
+ SwingUtilities2.getTextUIDrawing(host)
+ .drawString(host, g, getSampleText(),textXOffset+(textGap/2),
ascent+2);
g.fillRect(textXOffset,
( height) + textGap,
width + (textGap),
height +2);
g.setColor(Color.black);
- SwingUtilities2.drawString(host, g, getSampleText(),
+ SwingUtilities2.getTextUIDrawing(host)
+ .drawString(host, g, getSampleText(),
textXOffset+(textGap/2),
height+ascent+textGap+2);
g.setColor(Color.white);
@@ -156,11 +159,12 @@
( height + textGap) * 2,
width + (textGap),
height +2);
g.setColor(color);
- SwingUtilities2.drawString(host, g, getSampleText(),
+ SwingUtilities2.getTextUIDrawing(host)
+ .drawString(host, g, getSampleText(),
textXOffset+(textGap/2),
((height+textGap) * 2)+ascent+2);
return width + textGap*3;
< prev index next >