< prev index next >
src/java.desktop/share/classes/javax/swing/colorchooser/DefaultPreviewPanel.java
Print this page
*** 79,91 ****
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 y = height*3 + textGap*3;
int x = squareSize * 3 + squareGap*2 + swatchWidth + width + textGap*3;
return new Dimension( x,y );
}
--- 79,91 ----
if (host == null) {
host = this;
}
FontMetrics fm = host.getFontMetrics(getFont());
int height = fm.getHeight();
! 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,153 ****
}
FontMetrics fm = SwingUtilities2.getFontMetrics(host, g);
int ascent = fm.getAscent();
int height = fm.getHeight();
! int width = SwingUtilities2.stringWidth(host, fm, getSampleText());
int textXOffset = offsetX + textGap;
Color color = getForeground();
g.setColor(color);
! SwingUtilities2.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(),
textXOffset+(textGap/2),
height+ascent+textGap+2);
g.setColor(Color.white);
--- 126,156 ----
}
FontMetrics fm = SwingUtilities2.getFontMetrics(host, g);
int ascent = fm.getAscent();
int height = fm.getHeight();
! int width = SwingUtilities2.getTextUIDrawing(host)
! .getStringWidth(host, fm, getSampleText());
int textXOffset = offsetX + textGap;
Color color = getForeground();
g.setColor(color);
! 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.getTextUIDrawing(host)
! .drawString(host, g, getSampleText(),
textXOffset+(textGap/2),
height+ascent+textGap+2);
g.setColor(Color.white);
*** 156,166 ****
( height + textGap) * 2,
width + (textGap),
height +2);
g.setColor(color);
! SwingUtilities2.drawString(host, g, getSampleText(),
textXOffset+(textGap/2),
((height+textGap) * 2)+ascent+2);
return width + textGap*3;
--- 159,170 ----
( height + textGap) * 2,
width + (textGap),
height +2);
g.setColor(color);
! SwingUtilities2.getTextUIDrawing(host)
! .drawString(host, g, getSampleText(),
textXOffset+(textGap/2),
((height+textGap) * 2)+ascent+2);
return width + textGap*3;
< prev index next >