javax.swing.AbstractButton.getVerticalTextPosition()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(77)

本文整理了Java中javax.swing.AbstractButton.getVerticalTextPosition()方法的一些代码示例,展示了AbstractButton.getVerticalTextPosition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractButton.getVerticalTextPosition()方法的具体详情如下:
包路径:javax.swing.AbstractButton
类名称:AbstractButton
方法名:getVerticalTextPosition

AbstractButton.getVerticalTextPosition介绍

暂无

代码示例

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

/**
 * Returns the baseline for buttons.
 */
private static int getButtonBaseline(AbstractButton button, int height) {
  FontMetrics fm = button.getFontMetrics(button.getFont());
  resetRects(button, height);
  String text = button.getText();
  if (text != null && text.startsWith("<html>")) {
    return -1;
  }
  // NOTE: that we use "a" here to make sure we get a valid value, if
  // we were to pass in an empty string or null we would not get
  // back the right thing.
  SwingUtilities.layoutCompoundLabel(
    button, fm, "a", button.getIcon(), 
    button.getVerticalAlignment(), button.getHorizontalAlignment(),
    button.getVerticalTextPosition(),
    button.getHorizontalTextPosition(),
    viewRect, iconRect, textRect, 
    text == null ? 0 : button.getIconTextGap());
  if (isAqua()) {
    return textRect.y + fm.getAscent() + 1;
  }
  return textRect.y + fm.getAscent();
}

代码示例来源:origin: com.jidesoft/jide-oss

public static Dimension getPreferredButtonSize(AbstractButton b, int textIconGap, boolean isHorizontal) {
  if (b.getComponentCount() > 0) {
    return null;
  }
  Icon icon = b.getIcon();
  String text = b.getText();
  Font font = b.getFont();
  FontMetrics fm = b.getFontMetrics(font);
  Rectangle iconR = new Rectangle();
  Rectangle textR = new Rectangle();
  Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);
  layoutCompoundLabel(b, fm, text, icon, isHorizontal,
      b.getVerticalAlignment(), b.getHorizontalAlignment(),
      b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
      viewR, iconR, textR, (text == null ? 0 : textIconGap));
  /* The preferred size of the button is the size of
   * the text and icon rectangles plus the buttons insets.
   */
  Rectangle r = iconR.union(textR);
  Insets insets = b.getInsets();
  r.width += insets.left + insets.right;
  r.height += insets.top + insets.bottom;
  return r.getSize();
}

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

/**
 * Returns the baseline for buttons.
 */
private int getButtonBaseline(AbstractButton button, int height) {
  FontMetrics fm = button.getFontMetrics(button.getFont());
  resetRects(button, height);
  // NOTE: that we use "a" here to make sure we get a valid value, if
  // we were to pass in an empty string or null we would not get
  // back the right thing.
  SwingUtilities.layoutCompoundLabel(
    button, fm, "a", button.getIcon(), 
    button.getVerticalAlignment(), button.getHorizontalAlignment(),
    button.getVerticalTextPosition(),
    button.getHorizontalTextPosition(),
    viewRect, iconRect, textRect, 
  button.getText() == null ? 0 : button.getIconTextGap());
  return textRect.y + fm.getAscent() + 1;
}

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

/**
 * Returns the baseline for buttons.
 */
private int getCheckBoxBaseline(AbstractButton button, int height) {
  FontMetrics fm = button.getFontMetrics(button.getFont());
  resetRects(button, height);
  // NOTE: that we use "a" here to make sure we get a valid value, if
  // we were to pass in an empty string or null we would not get
  // back the right thing.
  SwingUtilities.layoutCompoundLabel(
    button, fm, "a", button.getIcon(), 
    button.getVerticalAlignment(), button.getHorizontalAlignment(),
    button.getVerticalTextPosition(),
    button.getHorizontalTextPosition(),
    viewRect, iconRect, textRect, 
  button.getText() == null ? 0 : button.getIconTextGap());
  return textRect.y + fm.getAscent();
  }
/**

代码示例来源:origin: khuxtable/seaglass

b.getVerticalTextPosition(), viewRect, iconRect, textRect,
                            b.getIconTextGap());
View view     = (View) b.getClientProperty(BasicHTML.propertyKey);

代码示例来源:origin: khuxtable/seaglass

/**
 * Paint the button.
 *
 * @param context the Synth context.
 * @param g       the Graphics context.
 */
protected void paint(SeaGlassContext context, Graphics g) {
  AbstractButton b = (AbstractButton) context.getComponent();
  g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
  g.setFont(style.getFont(context));
  context.getStyle().getGraphicsUtils(context).paintText(context, g, b.getText(), getIcon(b), b.getHorizontalAlignment(),
                              b.getVerticalAlignment(), b.getHorizontalTextPosition(),
                              b.getVerticalTextPosition(), b.getIconTextGap(),
                              b.getDisplayedMnemonicIndex(), getTextShiftOffset(context));
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

.getVerticalTextPosition(), b
    .getHorizontalTextPosition(), viewR, iconR, textR,
(text == null ? 0 : b.getIconTextGap()));

代码示例来源:origin: org.swinglabs.swingx/swingx-core

.getVerticalTextPosition(), b
    .getHorizontalTextPosition(), viewR, iconR, textR,
(text == null ? 0 : b.getIconTextGap()));

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

.getVerticalTextPosition(), b
    .getHorizontalTextPosition(), viewR, iconR, textR,
(text == null ? 0 : b.getIconTextGap()));

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

.getVerticalTextPosition(), b
    .getHorizontalTextPosition(), viewR, iconR, textR,
(text == null ? 0 : b.getIconTextGap()));

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

.getVerticalTextPosition(), b
    .getHorizontalTextPosition(), viewR, iconR, textR,
(text == null ? 0 : b.getIconTextGap()));

代码示例来源:origin: com.synaptix/SynaptixSwing

private String layout(AbstractButton b, FontMetrics fm, int width,
    int height) {
  Insets i = b.getInsets();
  viewRect.x = i.left;
  viewRect.y = i.top;
  viewRect.width = width - (i.right + viewRect.x);
  viewRect.height = height - (i.bottom + viewRect.y);
  textRect.x = textRect.y = textRect.width = textRect.height = 0;
  iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
  // layout the text and icon
  return SwingUtilities.layoutCompoundLabel(b, fm, b.getText(), b
      .getIcon(), b.getVerticalAlignment(), b
      .getHorizontalAlignment(), b.getVerticalTextPosition(), b
      .getHorizontalTextPosition(), viewRect, iconRect, textRect, b
      .getText() == null ? 0 : b.getIconTextGap());
}

代码示例来源:origin: com.jidesoft/jide-oss

isHorizontal,
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,

代码示例来源:origin: com.github.insubstantial/substance

.getHorizontalAlignment(), b.getVerticalTextPosition(), b
.getHorizontalTextPosition(), viewRect, iconRect, textRect, b
.getText() == null ? 0 : b.getIconTextGap());

代码示例来源:origin: org.java.net.substance/substance

.getHorizontalAlignment(), b.getVerticalTextPosition(), b
.getHorizontalTextPosition(), viewRect, iconRect, textRect, b
.getText() == null ? 0 : b.getIconTextGap());

代码示例来源:origin: khuxtable/seaglass

/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getMaximumSize(javax.swing.JComponent)
 */
public Dimension getMaximumSize(JComponent c) {
  if (c.getComponentCount() > 0 && c.getLayout() != null) {
    return null;
  }
  AbstractButton   b      = (AbstractButton) c;
  SeaGlassContext  ss     = getContext(c);
  final SynthStyle style2 = ss.getStyle();
  Dimension        size   = style2.getGraphicsUtils(ss).getMaximumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
                                     b.getHorizontalAlignment(), b.getVerticalAlignment(),
                                     b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
                                     b.getIconTextGap(), b.getDisplayedMnemonicIndex());
  ss.dispose();
  return size;
}

代码示例来源:origin: khuxtable/seaglass

/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getMinimumSize(javax.swing.JComponent)
 */
public Dimension getMinimumSize(JComponent c) {
  if (c.getComponentCount() > 0 && c.getLayout() != null) {
    return null;
  }
  AbstractButton   b      = (AbstractButton) c;
  SeaGlassContext  ss     = getContext(c);
  final SynthStyle style2 = ss.getStyle();
  Dimension        size   = style2.getGraphicsUtils(ss).getMinimumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
                                     b.getHorizontalAlignment(), b.getVerticalAlignment(),
                                     b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
                                     b.getIconTextGap(), b.getDisplayedMnemonicIndex());
  ss.dispose();
  return size;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

.getHorizontalAlignment(), b.getVerticalTextPosition(), b
.getHorizontalTextPosition(), viewRect, iconRect, textRect, b
.getText() == null ? 0 : b.getIconTextGap());

代码示例来源:origin: khuxtable/seaglass

/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getPreferredSize(javax.swing.JComponent)
 */
public Dimension getPreferredSize(JComponent c) {
  if (c.getComponentCount() > 0 && c.getLayout() != null) {
    return null;
  }
  AbstractButton     b             = (AbstractButton) c;
  SeaGlassContext    ss            = getContext(c);
  SynthStyle         style2        = ss.getStyle();
  SynthGraphicsUtils graphicsUtils = style2.getGraphicsUtils(ss);
  Dimension          size          = graphicsUtils.getPreferredSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
                                   b.getHorizontalAlignment(),
                                   b.getVerticalAlignment(), b.getHorizontalTextPosition(),
                                   b.getVerticalTextPosition(), b.getIconTextGap(),
                                   b.getDisplayedMnemonicIndex());
  ss.dispose();
  // Make height odd.
  size.height &= ~1;
  return size;
}

代码示例来源:origin: com.jtattoo/JTattoo

b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getVerticalTextPosition(),
b.getHorizontalTextPosition(),
viewRect,

相关文章

微信公众号

最新文章

更多

AbstractButton类方法