當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicGraphicsUtils.drawStringUnderlineCharAt方法代碼示例

本文整理匯總了Java中javax.swing.plaf.basic.BasicGraphicsUtils.drawStringUnderlineCharAt方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicGraphicsUtils.drawStringUnderlineCharAt方法的具體用法?Java BasicGraphicsUtils.drawStringUnderlineCharAt怎麽用?Java BasicGraphicsUtils.drawStringUnderlineCharAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.plaf.basic.BasicGraphicsUtils的用法示例。


在下文中一共展示了BasicGraphicsUtils.drawStringUnderlineCharAt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testDrawEmptyString

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
private static void testDrawEmptyString() {
    JLabel label = new JLabel();
    BufferedImage buffImage = createBufferedImage(50, 50);
    Graphics2D g2 = buffImage.createGraphics();
    g2.setColor(DRAW_COLOR);
    BasicGraphicsUtils.drawString(null, g2, null, 0, 0);
    BasicGraphicsUtils.drawString(label, g2, null, 0, 0);
    BasicGraphicsUtils.drawString(null, g2, "", 0, 0);
    BasicGraphicsUtils.drawString(label, g2, "", 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(null, g2, null, 3, 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(label, g2, null, 3, 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(null, g2, "", 3, 0, 0);
    BasicGraphicsUtils.drawStringUnderlineCharAt(label, g2, "", 3, 0, 0);
    g2.dispose();
    checkImageIsEmpty(buffImage);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:bug8132119.java

示例2: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title,
	Rectangle textRect, boolean isSelected)
{
	g.setFont(font);

	View v = getTextViewForTab(tabIndex);
	if( v != null )
	{
		// html
		v.paint(g, textRect);
	}
	else
	{
		// plain text
		int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);

		if( tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex) )
		{
			g.setColor(isSelected ? Color.white : Color.black);
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
		}
		else
		{ // tab disabled
			g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
			g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:FlatterTabbedPaneUI.java

示例3: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
protected void paintText(Graphics g, Rectangle textRect, String text) {
    FontMetrics fm = g.getFontMetrics();

    int mnemonicIndex = -1;

    if(isEnabled()) {
        /*** paint the text normally */
        g.setColor(getPeerForeground());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text,mnemonicIndex , textRect.x , textRect.y + fm.getAscent() );
    }
    else {
        /*** paint the text disabled ***/
        g.setColor(getPeerBackground().brighter());

        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x, textRect.y + fm.getAscent());
        g.setColor(getPeerBackground().darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                     textRect.x - 1, textRect.y + fm.getAscent() - 1);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:XCheckboxPeer.java

示例4: checkNullArgumentsDrawStringUnderlineCharAt

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
private static void checkNullArgumentsDrawStringUnderlineCharAt(
        JComponent comp, Graphics2D g, String text) {

    int x = 50;
    int y = 50;
    BasicGraphicsUtils.drawStringUnderlineCharAt(null, g, text, 1, x, y);
    BasicGraphicsUtils.drawStringUnderlineCharAt(comp, g, null, 1, x, y);

    try {
        BasicGraphicsUtils.drawStringUnderlineCharAt(comp, null, text, 1, x, y);
    } catch (NullPointerException e) {
        return;
    }

    throw new RuntimeException("NPE is not thrown");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:bug8132119.java

示例5: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
public void paintText(Graphics2D g,ButtonInfo info) {
	ButtonModel model = info.button.getModel();
	FontMetrics fm = info.button.getFontMetrics(info.button.getFont());
	int mnemonicIndex = info.button.getDisplayedMnemonicIndex();
	String text = info.button.getText();
	int textShiftOffset = 0;


	g.setComposite(AlphaComposite.SrcOver);
	/* Draw the Text */
	if(isEnabled(info.button)) {
		/*** paint the text normally */
		g.setColor(info.button.getForeground());
		BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
				info.textRect.x + textShiftOffset,
				info.textRect.y + fm.getAscent() + textShiftOffset);
	} else {
		/*** paint the text disabled ***/
		g.setColor(info.button.getBackground().brighter());
		BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
				info.textRect.x, info.textRect.y + fm.getAscent());
		g.setColor(info.button.getBackground().darker());
		BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
				info.textRect.x - 1, info.textRect.y + fm.getAscent() - 1);
	}
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:27,代碼來源:FilledButtonUI.java

示例6: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
@Override
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
    MacFontUtils.enableAntialiasing((Graphics2D) g);
    Graphics2D graphics = (Graphics2D) g.create();

    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    FontMetrics fm = c.getFontMetrics(c.getFont());

    // 1) Draw the emphasis text.
    graphics.setColor(model.isArmed()
            ? MacColorUtils.EMPTY_COLOR
            : EmphasizedLabelUI.DEFAULT_EMPHASIS_COLOR);
    BasicGraphicsUtils.drawStringUnderlineCharAt(graphics, text, -1,
            textRect.x, textRect.y + 1 + fm.getAscent());

    // 2) Draw the text.
    graphics.setColor(model.isEnabled()
            ? EmphasizedLabelUI.DEFAULT_FOCUSED_FONT_COLOR
            : EmphasizedLabelUI.DEFAULT_DISABLED_FONT_COLOR);
    BasicGraphicsUtils.drawStringUnderlineCharAt(graphics, text, -1,
            textRect.x, textRect.y + fm.getAscent());

    graphics.dispose();
}
 
開發者ID:mathieulegoc,項目名稱:SmartTokens,代碼行數:26,代碼來源:UnifiedToolbarButtonUI.java

示例7: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
    super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
    g.setFont(font);
    View v = getTextViewForTab(tabIndex);
    if (v != null) {
        // html
        v.paint(g, textRect);
    } else {
        // plain text
        int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
        if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
            g.setColor(tabPane.getForegroundAt(tabIndex));
            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
        } else { // tab disabled
            g.setColor(Color.BLACK);
            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
            g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);
        }
    }
}
 
開發者ID:ntenhoeve,項目名稱:Introspect-Framework,代碼行數:23,代碼來源:CustomTabbedPaneUI.java

示例8: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
	AbstractButton b = (AbstractButton) c;
	ButtonModel model = b.getModel();
	FontMetrics fm = g.getFontMetrics();
	int mnemIndex = b.getDisplayedMnemonicIndex();

	/* Draw the Text */
	if (model.isEnabled()) {
		/*** paint the text normally */
		g.setColor(b.getForeground());
	} else {
		/*** paint the text disabled ***/
		g.setColor(getDisabledTextColor());
	}
	BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
}
 
開發者ID:qikh,項目名稱:swingbootstrap,代碼行數:17,代碼來源:ButtonUI.java

示例9: drawStringUnderlineCharAt

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
public static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text, int underlinedIndex, int x, int y) {
    Graphics2D g2D = (Graphics2D) g;
    Object savedRenderingHint = null;
    if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
        g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
    }
    if (getJavaVersion() >= 1.6) {
        try {
            Class swingUtilities2Class = Class.forName("sun.swing.SwingUtilities2");
            Class classParams[] = {JComponent.class, Graphics.class, String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE};
            Method m = swingUtilities2Class.getMethod("drawStringUnderlineCharAt", classParams);
            Object methodParams[] = {c, g, text, underlinedIndex, x, y};
            m.invoke(null, methodParams);
        } catch (Exception ex) {
            BasicGraphicsUtils.drawString(g, text, underlinedIndex, x, y);
        }
    } else if (getJavaVersion() >= 1.4) {
        BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y);
    } else {
        BasicGraphicsUtils.drawString(g, text, underlinedIndex, x, y);
    }
    if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
    }
}
 
開發者ID:Gocnak,項目名稱:Botnak,代碼行數:27,代碼來源:JTattooUtilities.java

示例10: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
/**
 * Paints the specified text.
 * 
 * @param g
 *            Graphics context.
 * @param comp
 *            Component.
 * @param textRect
 *            Text rectangle.
 * @param text
 *            Text to paint.
 * @param mnemonicIndex
 *            Mnemonic index.
 * @param font
 *            Font to use.
 * @param color
 *            Color to use.
 * @param clip
 *            Optional clip. Can be <code>null</code>.
 * @param transform
 *            Optional transform to apply. Can be <code>null</code>.
 */
private static void paintText(Graphics g, JComponent comp,
		Rectangle textRect, String text, int mnemonicIndex,
		java.awt.Font font, java.awt.Color color, java.awt.Rectangle clip,
		java.awt.geom.AffineTransform transform) {
	if ((text == null) || (text.length() == 0))
		return;

	Graphics2D g2d = (Graphics2D) g.create();
	// workaroundBug6576507(g2d);
	// RenderingUtils.installDesktopHints(g2d);

	g2d.setFont(font);
	g2d.setColor(color);
	// fix for issue 420 - call clip() instead of setClip() to
	// respect the currently set clip shape
	if (clip != null)
		g2d.clip(clip);
	if (transform != null)
		g2d.transform(transform);
	BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, mnemonicIndex,
			textRect.x, textRect.y + g2d.getFontMetrics().getAscent());
	g2d.dispose();
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:46,代碼來源:SubstanceTextUtilities.java

示例11: testDrawString

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
private static void testDrawString(boolean underlined) {
    String str = "AOB";
    JComponent comp = createComponent(str);

    BufferedImage buffImage = createBufferedImage(WIDTH, HEIGHT);
    Graphics2D g2 = buffImage.createGraphics();

    g2.setColor(DRAW_COLOR);
    g2.setFont(comp.getFont());

    FontMetrics fontMetrices = comp.getFontMetrics(comp.getFont());
    float width = BasicGraphicsUtils.getStringWidth(comp, fontMetrices, str);
    float x = (WIDTH - width) / 2;
    int y = 3 * HEIGHT / 4;

    if (underlined) {
        BasicGraphicsUtils.drawStringUnderlineCharAt(comp, g2, str, 1, x, y);
    } else {
        BasicGraphicsUtils.drawString(comp, g2, str, x, y);
    }
    g2.dispose();

    float xx = BasicGraphicsUtils.getStringWidth(comp, fontMetrices, "A") +
            BasicGraphicsUtils.getStringWidth(comp, fontMetrices, "O")/2;

    checkImageContainsSymbol(buffImage, (int) xx, underlined ? 3 : 2);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:bug8132119.java

示例12: paintEnabledText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
@Override
protected void paintEnabledText(JLabel label, Graphics g, String s,
                                   int textX, int textY) {
   	Graphics2D g2 = (Graphics2D)g.create();
   	g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
   	if(fShadowColor!=null) {
        g2.setColor(fShadowColor);
        g2.setFont(label.getFont());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g2, s, -1, textX, textY + 1);
   	}
   	g2.setColor(isParentWindowFocused(label)
               ? fFocusedTextColor : fUnfocusedTextColor);
       BasicGraphicsUtils.drawStringUnderlineCharAt(g2, s, -1, textX, textY);
       g2.dispose();
   }
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:16,代碼來源:EmphasizedLabelUI.java

示例13: paintDisabledText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
@Override
protected void paintDisabledText(JLabel label, Graphics g, String s, int textX, int textY) {
   	Graphics2D g2 = (Graphics2D)g.create();
   	g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	if(fShadowColor!=null) {
        g2.setColor(fShadowColor);
        g2.setFont(label.getFont());
        BasicGraphicsUtils.drawStringUnderlineCharAt(g2, s, -1, textX, textY + 1);
	}
       g2.setColor(DEFAULT_DISABLED_FONT_COLOR);
       BasicGraphicsUtils.drawStringUnderlineCharAt(g2, s, -1, textX, textY);
       g2.dispose();
   }
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:14,代碼來源:EmphasizedLabelUI.java

示例14: paintText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect,
		boolean isSelected) {

	g.setFont(font);

	View v = getTextViewForTab(tabIndex);
	if (v != null) {
		// html
		v.paint(g, textRect);
	}
	else {
		// plain text
		int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);

		if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
			if (isSelected)
				g.setColor(whiteColor);
			else
				g.setColor(tabPane.getForegroundAt(tabIndex));

			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());

		}
		else { // tab disabled
			g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
			g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);

		}
	}
}
 
開發者ID:MyersResearchGroup,項目名稱:iBioSim,代碼行數:34,代碼來源:CloseTabPaneEnhancedUI.java

示例15: paintDisabledText

import javax.swing.plaf.basic.BasicGraphicsUtils; //導入方法依賴的package包/類
/**
 * Draws the text for a disabled label, using the color defined in the
 * {@link UIManager} defaults with the key
 * <code>Label.disabledForeground</code>.
 *
 * @param l  the label.
 * @param g  the graphics device.
 * @param s  the label text.
 * @param textX  the x-coordinate for the label.
 * @param textY  the y-coordinate for the label.
 */
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX,
                               int textY)
{
  Color savedColor = g.getColor();
  g.setColor(UIManager.getColor("Label.disabledForeground"));
  int mnemIndex = l.getDisplayedMnemonicIndex();
  if (mnemIndex != -1)
    BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
        textY);
  else
    g.drawString(s, textX, textY);

  g.setColor(savedColor);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:26,代碼來源:MetalLabelUI.java


注:本文中的javax.swing.plaf.basic.BasicGraphicsUtils.drawStringUnderlineCharAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。