本文整理汇总了Java中javax.swing.JTextPane.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java JTextPane.setSize方法的具体用法?Java JTextPane.setSize怎么用?Java JTextPane.setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextPane
的用法示例。
在下文中一共展示了JTextPane.setSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import javax.swing.JTextPane; //导入方法依赖的package包/类
public void draw(Graphics g, GamePieceImage defn) {
TextBoxItemInstance tbi = null;
if (defn != null) {
tbi = defn.getTextBoxInstance(getConfigureName());
}
if (tbi == null) {
tbi = new TextBoxItemInstance();
}
Color fg = tbi.getFgColor().getColor();
Color bg = tbi.getBgColor().getColor();
Point origin = layout.getPosition(this);
Rectangle r = new Rectangle(origin.x, origin.y, getWidth(), getHeight());
String s = null;
if (textSource.equals(SRC_FIXED)) {
s = text;
}
else {
if (defn != null) {
if (tbi != null) {
s = tbi.getValue();
}
}
}
Graphics2D g2d = ((Graphics2D) g);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, isAntialias() ?
RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
AffineTransform saveXForm = null;
if (getRotation() != 0) {
saveXForm = g2d.getTransform();
AffineTransform newXForm =
AffineTransform.getRotateInstance(Math.toRadians(getRotation()), getLayout().getVisualizerWidth()/2, getLayout().getVisualizerHeight()/2);
g2d.transform(newXForm);
}
if (bg != null) {
g.setColor(bg);
g.fillRect(r.x, r.y, r.width, r.height);
}
JTextPane l = new JTextPane();
if (isHTML) l.setContentType("text/html"); //$NON-NLS-1$
l.setText(s);
l.setSize(width-2, height-2);
l.setBackground(bg != null ? bg : new Color(0,true));
l.setForeground(fg != null ? fg : new Color(0,true));
FontStyle fs = FontManager.getFontManager().getFontStyle(fontStyleName);
Font f = fs.getFont();
l.setFont(f);
final BufferedImage img = ImageUtils.createCompatibleTranslucentImage(
Math.max(l.getWidth(), 1),
Math.max(l.getHeight(), 1)
);
final Graphics2D big = img.createGraphics();
l.paint(big);
big.dispose();
g2d.drawImage(img, origin.x+1, origin.y+1, null);
if (saveXForm != null) {
g2d.setTransform(saveXForm);
}
}