int offset = 0; if(icon != null && getText() != null) offset = (icon.getIconWidth() + getIconTextGap()); g.fillRect(offset, 0, getWidth() - 1 - offset, getHeight() - 1);
public Dimension getPreferredSize() { Dimension size = label1.getPreferredSize(); if ("".equals(label1.getText())) size.width += label1.getIconTextGap(); // NOI18N size.width += label2.getPreferredSize().width; size.width += label3.getPreferredSize().width; return size; }
/** * @param treeComponent */ private void updateIconWidth(Component treeComponent) { iconWidth = 0; if (!(treeComponent instanceof JLabel)) return; Icon icon = ((JLabel) treeComponent).getIcon(); if (icon != null) { iconWidth = icon.getIconWidth() + ((JLabel) treeComponent).getIconTextGap(); } }
public int getIconTextGap() { if((delegate_==this)||(delegate_==null)) return super.getIconTextGap(); return delegate_.getIconTextGap(); }
/** * @param treeComponent */ private void updateIconWidth(Component treeComponent) { iconWidth = 0; if (!(treeComponent instanceof JLabel)) return; Icon icon = ((JLabel) treeComponent).getIcon(); if (icon != null) { iconWidth = icon.getIconWidth() + ((JLabel) treeComponent).getIconTextGap(); } }
/** * @param treeComponent */ private void updateIconWidth(Component treeComponent) { iconWidth = 0; if (!(treeComponent instanceof JLabel)) return; Icon icon = ((JLabel) treeComponent).getIcon(); if (icon != null) { iconWidth = icon.getIconWidth() + ((JLabel) treeComponent).getIconTextGap(); } }
@ScriptFunction(jsDoc = "" + "/**\n" + " * The amount of space between the text and the icon displayed in this label.\n" + " */") @Override public int getIconTextGap() { return super.getIconTextGap(); }
/** * @param treeComponent */ private void updateIconWidth(Component treeComponent) { iconWidth = 0; if (!(treeComponent instanceof JLabel)) return; Icon icon = ((JLabel) treeComponent).getIcon(); if (icon != null) { iconWidth = icon.getIconWidth() + ((JLabel) treeComponent).getIconTextGap(); } }
public void doLayout() { Dimension size = getSize(); Dimension size1 = label1.getPreferredSize(); Dimension size2 = label2.getPreferredSize(); Dimension size3 = label3.getPreferredSize(); size.height = Math.max(size.height, size1.height); size.height = Math.max(size.height, size2.height); size.height = Math.max(size.height, size3.height); int x = 0; if ("".equals(label1.getText())) size1.width += label1.getIconTextGap(); // NOI18N label1.setBounds(x, 0, size1.width, size.height); x += size1.width; label2.setBounds(x, 0, size2.width, size.height); x += size2.width; label3.setBounds(x, 0, size3.width, size.height); }
/** * Instantiates and configures a WrappingIconPanel with the dropHack * property set as indicated by the boolean. * * @param dropHackEnabled a boolean indicating whether the drop hack should * be enabled. * * @see #isVisible() */ public WrappingIconPanel(boolean dropHackEnabled) { setOpaque(false); iconLabel = new JRendererLabel(); iconLabelGap = iconLabel.getIconTextGap(); iconLabel.setOpaque(false); updateIconBorder(); setBorder(null); setLayout(new BorderLayout()); add(iconLabel, BorderLayout.LINE_START); setDropHackEnabled(dropHackEnabled); }
/** * Instantiates and configures a WrappingIconPanel with the dropHack * property set as indicated by the boolean. * * @param dropHackEnabled a boolean indicating whether the drop hack should * be enabled. * * @see #isVisible() */ public WrappingIconPanel(boolean dropHackEnabled) { setOpaque(false); iconLabel = new JRendererLabel(); iconLabelGap = iconLabel.getIconTextGap(); iconLabel.setOpaque(false); updateIconBorder(); setBorder(null); setLayout(new BorderLayout()); add(iconLabel, BorderLayout.LINE_START); setDropHackEnabled(dropHackEnabled); }
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() ); }
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(); }
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(); }
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); }
@Test public void iconTextGap() { final int value = 42; final JLabel label = JLabelBuilder.builder() .text("value") .iconTextGap(value) .build(); MatcherAssert.assertThat(label.getIconTextGap(), is(value)); }
public LabelRenderer(boolean plain) { setEnabled(true); setHorizontalAlignment(LEADING); setVerticalAlignment(TOP); setSize(Integer.MAX_VALUE, Integer.MAX_VALUE); if (plain) { setOpaque(false); } else { setOpaque(true); setMargin(3, 3, 3, 3); } iconTextGap = super.getIconTextGap(); }
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; }
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; }
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; }