javax.swing.JLabel.getHorizontalTextPosition()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(121)

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

JLabel.getHorizontalTextPosition介绍

暂无

代码示例

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

/**
 * Returns the horizontal position of the title's text,
 * relative to the icon.
 *
 * @return   One of the following constants
 *           defined in <code>SwingConstants</code>:
 *           <code>LEFT</code>,
 *           <code>CENTER</code>, 
 *           <code>RIGHT</code>,
 *           <code>LEADING</code> or
 *           <code>TRAILING</code>.
 *
 * @see SwingConstants
 */
public int getHorizontalTextPosition() {
  return label.getHorizontalTextPosition();
}

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

/**
 * Returns the horizontal position of the title's text,
 * relative to the icon.
 *
 * @return   One of the following constants
 *           defined in <code>SwingConstants</code>:
 *           <code>LEFT</code>,
 *           <code>CENTER</code>, 
 *           <code>RIGHT</code>,
 *           <code>LEADING</code> or
 *           <code>TRAILING</code>.
 *
 * @see SwingConstants
 */
public int getHorizontalTextPosition() {
  return label.getHorizontalTextPosition();
}

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

/**
 * Returns the horizontal position of the title's text,
 * relative to the icon.
 *
 * @return   One of the following constants
 *           defined in <code>SwingConstants</code>:
 *           <code>LEFT</code>,
 *           <code>CENTER</code>, 
 *           <code>RIGHT</code>,
 *           <code>LEADING</code> or
 *           <code>TRAILING</code>.
 *
 * @see SwingConstants
 */
public int getHorizontalTextPosition() {
  return label.getHorizontalTextPosition();
}

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

/**
 * Returns the horizontal position of the title's text,
 * relative to the icon.
 *
 * @return   One of the following constants
 *           defined in <code>SwingConstants</code>:
 *           <code>LEFT</code>,
 *           <code>CENTER</code>, 
 *           <code>RIGHT</code>,
 *           <code>LEADING</code> or
 *           <code>TRAILING</code>.
 *
 * @see SwingConstants
 */
public int getHorizontalTextPosition() {
  return label.getHorizontalTextPosition();
}

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

/**
 * Returns the horizontal position of the title's text,
 * relative to the icon.
 *
 * @return   One of the following constants
 *           defined in <code>SwingConstants</code>:
 *           <code>LEFT</code>,
 *           <code>CENTER</code>, 
 *           <code>RIGHT</code>,
 *           <code>LEADING</code> or
 *           <code>TRAILING</code>.
 *
 * @see SwingConstants
 */
public int getHorizontalTextPosition() {
  return label.getHorizontalTextPosition();
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = ""
    + "/**\n"
    + " * Horizontal position of the text relative to the icon.\n"
    + " */")
@Override
public int getHorizontalTextPosition() {
  return super.getHorizontalTextPosition();
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

public int getHorizontalTextPosition()
{
 if((delegate_==this)||(delegate_==null))
  return super.getHorizontalTextPosition();
 return delegate_.getHorizontalTextPosition();
}

代码示例来源:origin: info.aduna.commons/aduna-commons-swing

public void paint(Graphics g) {
    boolean selected = list.isSelectedIndex(row);
    if (bounds != null) {
      Object value = list.getModel().getElementAt(row);
      JComponent renderer = (JComponent) list.getCellRenderer().getListCellRendererComponent(list, value, row, selected,
          false);
      setFont(list.getFont());
      Rectangle paintBounds = SwingUtilities.convertRectangle(list, bounds, this);
      SwingUtilities.paintComponent(g, renderer, this, paintBounds);
      int spacing = 0;
      if (renderer instanceof JLabel) {
        JLabel label = (JLabel) renderer;
        if (label.getIcon() != null) {
          spacing = label.getHorizontalTextPosition() + label.getIconTextGap();
        }
      }
      g.setColor(Color.BLACK);
      g.drawRect(paintBounds.x + spacing, paintBounds.y, paintBounds.width - spacing, paintBounds.height);
    }
  }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

protected Vector layoutCL( Graphics g, JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR )
{
 return layoutCompoundLabel( g, (JComponent)label, fontMetrics, text, icon, label.getVerticalAlignment(), label.getHorizontalAlignment(), label.getVerticalTextPosition(), label.getHorizontalTextPosition(), viewR, iconR, textR, label.getIconTextGap() );
}

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                        boolean hasFocus, int row, int column) {
  final JLabel label = (JLabel) table.getTableHeader().getDefaultRenderer()
                    .getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  if (rendererInit) {
    originalHorizontalTextPosition = label.getHorizontalTextPosition();
    rendererInit = false;
  }
  int modelColumn = table.convertColumnIndexToModel(column);
  if (tableFilter.isFiltered(modelColumn)) {
    Icon originalIcon = label.getIcon();
    if (originalIcon == null) {
      label.setIcon(getFilterIcon());
    } else {
      label.setIcon(new CompoundIcon(getFilterIcon(), originalIcon));
    }
    label.setHorizontalTextPosition(JLabel.TRAILING);
  } else {
    label.setHorizontalTextPosition(originalHorizontalTextPosition);
  }
  return label;
}

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

private int getLabelBaseline(JLabel label, int height) {
  Icon icon = (label.isEnabled()) ? label.getIcon() :
            label.getDisabledIcon();
  FontMetrics fm = label.getFontMetrics(label.getFont());
  resetRects(label, height);
  SwingUtilities.layoutCompoundLabel(label, fm,
    "a", icon, label.getVerticalAlignment(),
    label.getHorizontalAlignment(), label.getVerticalTextPosition(),
    label.getHorizontalTextPosition(), viewRect, iconRect, textRect,
    label.getIconTextGap());
  return textRect.y + fm.getAscent();
}

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

private static int getLabelBaseline(JLabel label, int height) {
  Icon icon = (label.isEnabled()) ? label.getIcon() :
            label.getDisabledIcon();
  FontMetrics fm = label.getFontMetrics(label.getFont());
  resetRects(label, height);
  SwingUtilities.layoutCompoundLabel(label, fm,
    "a", icon, label.getVerticalAlignment(),
    label.getHorizontalAlignment(), label.getVerticalTextPosition(),
    label.getHorizontalTextPosition(), viewRect, iconRect, textRect,
    label.getIconTextGap());
  return textRect.y + fm.getAscent();
}

代码示例来源:origin: info.aduna.commons/aduna-commons-swing

public void paint(Graphics g) {
    boolean selected = tree.isRowSelected(row);
    TreePath path = TreeOverlay.this.path;
    if (path != null) {
      JComponent renderer = (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree,
          path.getLastPathComponent(), tree.isRowSelected(row), tree.isExpanded(row),
          tree.getModel().isLeaf(path.getLastPathComponent()), row, selected);
      setFont(tree.getFont());
      Rectangle paintBounds = SwingUtilities.convertRectangle(tree, bounds, this);
      SwingUtilities.paintComponent(g, renderer, this, paintBounds);
      int spacing = 0;
      if (renderer instanceof JLabel) {
        JLabel label = (JLabel) renderer;
        if (label.getIcon() != null) {
          spacing = label.getHorizontalTextPosition() + label.getIconTextGap();
        }
      }
      g.setColor(Color.BLACK);
      g.drawRect(paintBounds.x + spacing, paintBounds.y, paintBounds.width - spacing, paintBounds.height);
    }
  }
}

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

/**
 * {@inheritDoc} <p>
 * 
 *  Paints a diagonal cross over the text if the comp is of type JLabel, 
 *  does nothing otherwise.
 */
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
    int height) {
  if (!(comp instanceof JLabel)) return;
  JLabel label = (JLabel) comp;
  Insets insets = label.getInsets(insetss);
  paintViewR.x = insets.left;
  paintViewR.y = insets.top;
  paintViewR.width = width - (insets.left + insets.right);
  paintViewR.height = height - (insets.top + insets.bottom);
  paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
  paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
  SwingUtilities.layoutCompoundLabel(label, 
      label.getFontMetrics(label.getFont()), label.getText(), null,
      label.getVerticalAlignment(), label.getHorizontalAlignment(), 
      label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
      paintViewR, paintIconR, paintTextR, label.getIconTextGap());
  doPaint(g, paintTextR);
}

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

/**
 * {@inheritDoc} <p>
 * 
 *  Paints a diagonal cross over the text if the comp is of type JLabel, 
 *  does nothing otherwise.
 */
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
    int height) {
  if (!(comp instanceof JLabel)) return;
  JLabel label = (JLabel) comp;
  Insets insets = label.getInsets(insetss);
  paintViewR.x = insets.left;
  paintViewR.y = insets.top;
  paintViewR.width = width - (insets.left + insets.right);
  paintViewR.height = height - (insets.top + insets.bottom);
  paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
  paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
  SwingUtilities.layoutCompoundLabel(label, 
      label.getFontMetrics(label.getFont()), label.getText(), null,
      label.getVerticalAlignment(), label.getHorizontalAlignment(), 
      label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
      paintViewR, paintIconR, paintTextR, label.getIconTextGap());
  doPaint(g, paintTextR);
}

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

/**
 * {@inheritDoc} <p>
 * 
 *  Paints a diagonal cross over the text if the comp is of type JLabel, 
 *  does nothing otherwise.
 */
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
    int height) {
  if (!(comp instanceof JLabel)) return;
  JLabel label = (JLabel) comp;
  Insets insets = label.getInsets(insetss);
  paintViewR.x = insets.left;
  paintViewR.y = insets.top;
  paintViewR.width = width - (insets.left + insets.right);
  paintViewR.height = height - (insets.top + insets.bottom);
  paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
  paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
  SwingUtilities.layoutCompoundLabel(label, 
      label.getFontMetrics(label.getFont()), label.getText(), null,
      label.getVerticalAlignment(), label.getHorizontalAlignment(), 
      label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
      paintViewR, paintIconR, paintTextR, label.getIconTextGap());
  doPaint(g, paintTextR);
}

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

protected void paint(SeaGlassContext context, Graphics g) {
  JLabel label = (JLabel) context.getComponent();
  Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
  g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
  g.setFont(style.getFont(context));
  context.getStyle().getGraphicsUtils(context).paintText(context, g, label.getText(), icon, label.getHorizontalAlignment(),
    label.getVerticalAlignment(), label.getHorizontalTextPosition(), label.getVerticalTextPosition(),
    label.getIconTextGap(), label.getDisplayedMnemonicIndex(), 0);
}

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

public Dimension getMaximumSize(JComponent c) {
  JLabel label = (JLabel) c;
  Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
  SeaGlassContext context = getContext(c);
  Dimension size = context.getStyle().getGraphicsUtils(context).getMaximumSize(context, context.getStyle().getFont(context),
    label.getText(), icon, label.getHorizontalAlignment(), label.getVerticalAlignment(), label.getHorizontalTextPosition(),
    label.getVerticalTextPosition(), label.getIconTextGap(), label.getDisplayedMnemonicIndex());
  context.dispose();
  return size;
}

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

public Dimension getMinimumSize(JComponent c) {
  JLabel label = (JLabel) c;
  Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
  SeaGlassContext context = getContext(c);
  Dimension size = context.getStyle().getGraphicsUtils(context).getMinimumSize(context, context.getStyle().getFont(context),
    label.getText(), icon, label.getHorizontalAlignment(), label.getVerticalAlignment(), label.getHorizontalTextPosition(),
    label.getVerticalTextPosition(), label.getIconTextGap(), label.getDisplayedMnemonicIndex());
  context.dispose();
  return size;
}

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

public Dimension getPreferredSize(JComponent c) {
  JLabel label = (JLabel) c;
  Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
  SeaGlassContext context = getContext(c);
  Dimension size = context.getStyle().getGraphicsUtils(context).getPreferredSize(context,
    context.getStyle().getFont(context), label.getText(), icon, label.getHorizontalAlignment(),
    label.getVerticalAlignment(), label.getHorizontalTextPosition(), label.getVerticalTextPosition(),
    label.getIconTextGap(), label.getDisplayedMnemonicIndex());
  context.dispose();
  return size;
}

相关文章

JLabel类方法